summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 },