diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/importlayer.js')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/importlayer.js | 30 |
1 files changed, 29 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 |