CKEditor Advanced Options - Don't allow same option to be selected twice
authorColeman Watts <coleman@civicrm.org>
Fri, 2 Mar 2018 14:42:40 +0000 (09:42 -0500)
committerColeman Watts <coleman@civicrm.org>
Fri, 2 Mar 2018 14:42:40 +0000 (09:42 -0500)
css/civicrm.css
js/wysiwyg/admin.ckeditor-configurator.js

index c459281324c6b09f3c42b1dd0be0b4ce94745899..6b2fdcd1843ee642af5e6fc55d92febe2acbeba4 100644 (file)
@@ -3124,6 +3124,10 @@ div.m ul#civicrm-menu,
 .crm-container .select2-container[class*=" fa-"]:before {
   display: none;
 }
+.crm-container .select2-results .select2-result.select2-disabled > .select2-result-label {
+  opacity: .6;
+  cursor: default;
+}
 
 /* Restore this property otherwise our css overrides it */
 .select2-search input {
index 17ac199703dd30e823507c46ac1b6bc67717b8c5..b7ff14825b590050ded1bf76887c01e0b35b7df4 100644 (file)
     }
   }
 
+  function getOptionList() {
+    var list = [];
+    _.forEach(options, function(option) {
+      var opt = _.cloneDeep(option);
+      if ($('[name="config_' + opt.id + '"]').length) {
+        opt.disabled = true;
+      }
+      list.push(opt);
+    });
+    return {results: list, text: 'id'};
+  }
+
   function addOption() {
     $('#crm-custom-config-options').append($(configRowTpl({})));
     $('div:last input.crm-config-option-name', '#crm-custom-config-options').crmSelect2({
-      data: {results: options, text: 'id'},
+      data: getOptionList,
       formatSelection: function(field) {
         return '<strong>' + field.id + '</strong> (' + field.type + ')';
       },