Hi Michael, I have tested this, and it works when you explicitly select a layer from the offered type-ahead list.
The one thing it will not do is allow manual typing or editing of the layer name. If for example you select "meta-agl-demo", the button will indeed enable. But if you manually remove the "-demo" the button will not re-enable for the valid "meta-agl", nor "meta-agl-demo" if you add back in the "-demo". This may be confusing. My version of the patch did allow for dynamic manual changes (at the cost of being a bit more complicated), but if you are happy with this new functionality then I am fine as well. - David -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Wood Sent: Monday, October 03, 2016 8:59 AM To: [email protected] Subject: [Toaster] [PATCH] toaster: importlayer Fix layer dependencies button state toggle Fix regression introduced by switching typeahead library. Make sure we enable and disable the add button based on whether the selection event has fired or not. [YOCTO #9936] Signed-off-by: Michael Wood <[email protected]> --- .../toaster/toastergui/static/js/importlayer.js | 30 ++++------------------ 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index 570ca33..30dc282 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -21,21 +21,11 @@ function importLayerPageInit (ctx) { libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ currentLayerDepSelection = item; + layerDepBtn.removeAttr("disabled"); }); - // choices available in the typeahead - var layerDepsChoices = {}; - - // when the typeahead choices change, store an array of the available layer - // choices locally, to use for enabling/disabling the "Add layer" button - layerDepInput.on("typeahead-choices-change", function (event, data) { - layerDepsChoices = {}; - - if (data.choices) { - data.choices.forEach(function (item) { - layerDepsChoices[item.name] = item; - }); - } + layerDepInput.on("typeahead:select", function(event, data){ + currentLayerDepSelection = data; }); // Disable local dir repo when page is loaded. @@ -43,18 +33,8 @@ function importLayerPageInit (ctx) { // disable the "Add layer" button when the layer input typeahead is empty // or not in the typeahead choices - layerDepInput.on("input change", function () { - // get the choices from the typeahead - var choice = layerDepsChoices[$(this).val()]; - - if (choice) { - layerDepBtn.removeAttr("disabled"); - currentLayerDepSelection = choice; - } - else { - layerDepBtn.attr("disabled","disabled"); - currentLayerDepSelection = undefined; - } + layerDepInput.on("input change", function(){ + layerDepBtn.attr("disabled","disabled"); }); /* We automatically add "openembedded-core" layer for convenience as a -- 2.7.4 -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
