[js] Disable concept selector when no vocabulary is selected
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 17 Mar 2017 07:59:03 +0100
changeset 2512 93a52e1de95c
parent 2503 55d886119a5a
child 2513 660611c16bb1
[js] Disable concept selector when no vocabulary is selected This makes the UX better by adding constraint on what is allowed or not.
cubicweb_seda/data/cubes.skoscomplete.js
--- a/cubicweb_seda/data/cubes.skoscomplete.js	Fri Mar 17 07:56:15 2017 +0100
+++ b/cubicweb_seda/data/cubes.skoscomplete.js	Fri Mar 17 07:59:03 2017 +0100
@@ -20,11 +20,11 @@
         var masterSelect = cw.jqNode(masterSelectId);
         // bind vocabulary select to update concept autocompletion input on value change
         masterSelect.change(function() {
-            concept_autocomplete.updateCurrentSchemeEid(this);
+            concept_autocomplete.updateCurrentSchemeEid(this, slaveSelectId);
             concept_autocomplete.resetConceptFormField(slaveSelectId);
         });
         // initialize currentSchemeEid by looking the value of the master field
-        concept_autocomplete.updateCurrentSchemeEid(masterSelect);
+        concept_autocomplete.updateCurrentSchemeEid(masterSelect, slaveSelectId);
         // also bind the autocompletion widget
         cw.jqNode(slaveSelectId+'Label')
             .autocomplete({
@@ -74,10 +74,13 @@
             resetIfInvalidChoice();
         });
     },
-    updateCurrentSchemeEid: function(masterSelect) {
+    updateCurrentSchemeEid: function(masterSelect, slaveSelectId) {
         concept_autocomplete.currentSchemeEid = $(masterSelect).val();
         if (concept_autocomplete.currentSchemeEid == '__cubicweb_internal_field__') {
             concept_autocomplete.currentSchemeEid = null;
+            cw.jqNode(slaveSelectId+'Label').prop('disabled', true);
+        } else {
+            cw.jqNode(slaveSelectId+'Label').prop('disabled', false);
         }
     },
     resetConceptFormField: function(slaveSelectId) {