Merge pull request #11071 from mukeshcompucorp/HW-380-civicase-settings-page
[civicrm-core.git] / js / view / crm.designer.js
index 5614e5222c61d66cf25b7d0f6be0a6b533090725..a92ac6d60676ef703cee77c3025aaab470eb14ef 100644 (file)
           if (designerDialog.undoAlert && designerDialog.undoAlert.close) designerDialog.undoAlert.close();
           if (designerDialog.isUfUnsaved) {
             designerDialog.undoAlert = CRM.alert('<p>' + ts('%1 has not been saved.', {1: designerDialog.model.get('title')}) + '</p><a href="#" class="crm-undo">' + ts('Restore') + '</a>', ts('Unsaved Changes'), 'alert', {expires: 60000});
-            $('.ui-notify-message a.crm-undo').button({icons: {primary: 'ui-icon-arrowreturnthick-1-w'}}).click(function(e) {
+            $('.ui-notify-message a.crm-undo').button({icons: {primary: 'fa-undo'}}).click(function(e) {
               e.preventDefault();
               designerDialog.undoState = true;
               designerDialog.$el.dialog('open');
       'click .crm-designer-preview': 'doPreview'
     },
     onRender: function() {
-      this.$('.crm-designer-save').button({icons: {primary: 'ui-icon-check'}}).attr({
+      this.$('.crm-designer-save').button({icons: {primary: 'fa-check'}}).attr({
         disabled: 'disabled',
         style: 'opacity:.5; cursor:default;'
       });
-      this.$('.crm-designer-preview').button({icons: {primary: 'ui-icon-search'}});
+      this.$('.crm-designer-preview').button({icons: {primary: 'fa-television'}});
     },
     initialize: function(options) {
       CRM.designerApp.vent.on('ufUnsaved', this.onUfChanged, this);
       if (!this.previewMode) {
         $('.crm-designer-preview-canvas').html('');
         $('.crm-designer-canvas > *, .crm-designer-palette-region').show();
-        $('.crm-designer-preview').button('option', {icons: {primary: 'ui-icon-search'}}).find('span').text(ts('Preview'));
+        $('.crm-designer-preview').button('option', {icons: {primary: 'fa-television'}}).find('span').text(ts('Preview'));
         return;
       }
       if (this.model.getRel('ufFieldCollection').hasDuplicates()) {
         $dialog.unblock();
         $('.crm-designer-canvas > *, .crm-designer-palette-region').hide();
         $('.crm-designer-preview-canvas').html(data).show().trigger('crmLoad').find(':input').prop('readOnly', true);
-        $('.crm-designer-preview').button('option', {icons: {primary: 'ui-icon-pencil'}}).find('span').text(ts('Edit'));
+        $('.crm-designer-preview').button('option', {icons: {primary: 'fa-pencil'}}).find('span').text(ts('Edit'));
       });
     }
   });
       }).bind('loaded.jstree', function () {
         $('.crm-designer-palette-field', this).draggable({
           appendTo: '.crm-designer',
-          zIndex: $(this.$el).zIndex() + 5000,
+          zIndex: $(this.$el).css("zIndex") + 5000,
           helper: 'clone',
           connectToSortable: '.crm-designer-fields' // FIXME: tight canvas/palette coupling
         });
       this.$(".crm-designer-fields").sortable({
         placeholder: 'crm-designer-row-placeholder',
         forcePlaceholderSize: true,
+        cancel: 'input,textarea,button,select,option,a,.crm-designer-open',
         receive: function(event, ui) {
           var paletteFieldModel = ufFieldCanvasView.model.getRel('paletteFieldCollection').get(ui.item.attr('data-plm-cid'));
           var ufFieldModel = paletteFieldModel.addToUFCollection(
         });
         if (this.model.get('field_name').split('_')[0] == 'custom') {
           this.$('.crm-designer-field-summary > div').append('<button class="crm-designer-edit-custom">' + ts('Edit Custom Field') + '</button>');
-          this.$('button.crm-designer-edit-custom').button({icons: {primary: 'ui-icon-pencil'}}).attr('title', ts('Edit global settings for this custom field.'));
+          this.$('button.crm-designer-edit-custom').button({icons: {primary: 'fa-pencil'}}).attr('title', ts('Edit global settings for this custom field.'));
         }
       }
     },
       });
       var form1 = CRM.loadForm(url)
         .on('crmFormLoad', function() {
-          $(this).prepend('<div class="messages status"><div class="icon inform-icon"></div>' + ts('Note: This will modify the field system-wide, not just in this profile form.') + '</div>');
+          $(this).prepend('<div class="messages status"><i class="crm-i fa-info-circle"></i> ' + ts('Note: This will modify the field system-wide, not just in this profile form.') + '</div>');
         });
     },
     onChangeIsDuplicate: function(model, value, options) {
       if (!this.options.fieldSchema.civiIsMultiple) {
         fields = _.without(fields, 'is_multi_summary');
       }
+      if (this.options.fieldSchema.type == 'Markup') {
+        fields = _.without(fields, 'is_required', 'is_view', 'visibility', 'in_selector', 'is_searchable', 'help_post');
+      }
 
       this.form = new Backbone.Form({
         model: this.model,
 
       if (!this.model.isInSelectorAllowed() && this.model.get('in_selector') != "0") {
         this.model.set('in_selector', "0");
-        this.form.setValue('in_selector', "0");
+        if (this.form.fields.in_selector) {
+          this.form.setValue('in_selector', "0");
+        }
         // TODO: It might be nicer if we didn't completely discard in_selector -- e.g.
         // if the value could be restored when the user isInSelectorAllowed becomes true
         // again. However, I haven't found a simple way to do this.