default value fixes
authorkurund <kurund@civicrm.org>
Fri, 24 Jan 2014 22:58:12 +0000 (14:58 -0800)
committerkurund <kurund@civicrm.org>
Fri, 24 Jan 2014 22:58:12 +0000 (14:58 -0800)
js/view/crm.designer.js

index dccef6abda2f62c6483e9e92bc428333112f4f0c..26b93d076dba0e4a4d190e9fc83a8085c0a7d53f 100644 (file)
 
       paletteView.model.getRel('ufEntityCollection').each(function(ufEntityModel){
         _.each(ufEntityModel.getSections(), function(section, sectionKey){
+          var defaultValue = paletteView.selectedContactType;
+          if (!defaultValue) {
+            defaultValue = paletteView.model.getUFGroupModel();
+          }
 
           // set selected option as default, since we are rebuilding palette
-          paletteView.$('.crm-contact-types').val(ufEntityModel.attributes.entity_type).prop('selected','selected');
+          paletteView.$('.crm-contact-types').val(defaultValue).prop('selected','selected');
 
           var entitySection = ufEntityModel.get('entity_name') + '-' + sectionKey;
           var items = [];
       $('.crm-designer-palette-tree').jstree("search", $(event.target).val());
     },
     doSetPaletteEntity: function(event) {
+      this.selectedContactType = $('.crm-contact-types :selected').val();
       // loop through entity collection and remove non-valid entity section's
       var newUfEntityModels = [];
       this.model.getRel('ufEntityCollection').each(function(oldUfEntityModel){