summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-04-19 17:28:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-19 21:11:25 +0100
commit3036413000786499d38026ae0c16b916a10b7c65 (patch)
tree17693b021faa33b346f2eb13872514e83ea7df47 /bitbake
parent040dbf6988bebf755e60f6102bbc2b9854ce0608 (diff)
downloadpoky-3036413000786499d38026ae0c16b916a10b7c65.tar.gz
bitbake: toaster: disable/enable "Add layer" button according to input's content
In the import layer page, the "Add layer" button in the layer dependencies section doesn't accurately reflect whether the layer name in the corresponding input can be added. A partial or empty layer name can leave the button active, such that when it is clicked, a previously-selected layer can be accidentally added. Fix by keeping track of the items currently available in the typeahead, only activating the "Add layer" button when the input matches the name of one of those items. [YOCTO #8511] (Bitbake rev: dbb4f0282ded361baf9e5a0346e134bece5314b9) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/importlayer.js30
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js5
2 files changed, 34 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
index c68f3669f6..5a59799bc5 100644
--- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js
+++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
@@ -18,10 +18,38 @@ function importLayerPageInit (ctx) {
18 18
19 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ 19 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
20 currentLayerDepSelection = item; 20 currentLayerDepSelection = item;
21 });
22
23 // choices available in the typeahead
24 var layerDepsChoices = {};
25
26 // when the typeahead choices change, store an array of the available layer
27 // choices locally, to use for enabling/disabling the "Add layer" button
28 layerDepInput.on("typeahead-choices-change", function (event, data) {
29 layerDepsChoices = {};
21 30
22 layerDepBtn.removeAttr("disabled"); 31 if (data.choices) {
32 data.choices.forEach(function (item) {
33 layerDepsChoices[item.name] = item;
34 });
35 }
23 }); 36 });
24 37
38 // disable the "Add layer" button when the layer input typeahead is empty
39 // or not in the typeahead choices
40 layerDepInput.on("input change", function () {
41 // get the choices from the typeahead
42 var choice = layerDepsChoices[$(this).val()];
43
44 if (choice) {
45 layerDepBtn.removeAttr("disabled");
46 currentLayerDepSelection = choice;
47 }
48 else {
49 layerDepBtn.attr("disabled", "disabled");
50 currentLayerDepSelection = undefined;
51 }
52 });
25 53
26 /* We automatically add "openembedded-core" layer for convenience as a 54 /* We automatically add "openembedded-core" layer for convenience as a
27 * dependency as pretty much all layers depend on this one 55 * dependency as pretty much all layers depend on this one
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 8d1d20f133..43930a2c30 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -21,6 +21,9 @@ var libtoaster = (function (){
21 var xhrReq; 21 var xhrReq;
22 22
23 jQElement.typeahead({ 23 jQElement.typeahead({
24 // each time the typeahead's choices change, a
25 // "typeahead-choices-change" event is fired with an object
26 // containing the available choices in a "choices" property
24 source: function(query, process){ 27 source: function(query, process){
25 xhrParams.search = query; 28 xhrParams.search = query;
26 29
@@ -36,6 +39,8 @@ var libtoaster = (function (){
36 39
37 xhrReq = null; 40 xhrReq = null;
38 41
42 jQElement.trigger("typeahead-choices-change", {choices: data.results});
43
39 return process(data.results); 44 return process(data.results);
40 }); 45 });
41 }, 46 },