From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B3D6FE00F89; Tue, 19 Apr 2016 09:32:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.52 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 2B531E00AE4 for ; Tue, 19 Apr 2016 09:32:37 -0700 (PDT) Received: by mail-wm0-f52.google.com with SMTP id e201so20623615wme.0 for ; Tue, 19 Apr 2016 09:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=hP43AVj+OUx/opzW7iP5UWphBuKmFUAat7dLtweI8E0=; b=xj+JgmNhlZPQNeKlps/xUK0M+ZsVtYiDK5CgSUI4kSURyrOn3xc0xCwBzTlxq8c2fw cRyQp1s/l+2F0AR9OPfN4eqZzKKiPTZqliiipxVD9jdb3DEYjEyLII0ce1OadS258fAJ SXca4eQ5S0G36UiR45o1RBsYpdRtYlFQVXDLipEooENYWeZh5jx9ACWfSu9QFBwoIWcL SZ5TZZHkESWuWP68mfpycHmkJPHz0zsE2/d2DRcpFPcQwog4SlTLyUaXA22agsY5JNPr YgcgK1pcgCuQ09TNL6WeNbUI1BC37mikKxoL815n3HOcaFYLYMxR0H6j3oU+g7dCxnyi x0Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=hP43AVj+OUx/opzW7iP5UWphBuKmFUAat7dLtweI8E0=; b=NjnYhSkMpsbAC26ZMYpITuDiSHv/XejUTDelSAV8ci8yOnhkJkpSB0jdtnCm42LaJD MZ2y8xd4DryXZDgPhmnPwJcqXe30jOPwQU98fwZ/L/K2uKVDAQGoO7herPWXDiDiSEVk klQSJ2asMvYnLcYGWRGGpizpn8Biw7SzHlBgiuRTw/oSuVp/cXE5nkEzCZcWt+TmXI3R mOJG3Goeb9ebM7a24ZubRiOwynLWbK7z6cwubdz4qo+DjFIg1ocgcAtY5kn0GYUvn+sF RN8V0a+6m+9TTG6wsoV2ftjcrYqj/mrGZyRoZpCGnY7m8AIaiT8plWTj4rKRBDb+AVCH um8w== X-Gm-Message-State: AOPr4FXdai2ACY172PijqfWTgKYUXS2UM0C85JzOGbd3+jJJ6EL8wbdj0kO69fw1lRwSKDpU X-Received: by 10.28.102.8 with SMTP id a8mr2431783wmc.54.1461083556977; Tue, 19 Apr 2016 09:32:36 -0700 (PDT) Received: from [192.168.0.83] (host109-150-176-203.range109-150.btcentralplus.com. [109.150.176.203]) by smtp.googlemail.com with ESMTPSA id d131sm5167727wmd.12.2016.04.19.09.32.36 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Apr 2016 09:32:36 -0700 (PDT) To: toaster@yoctoproject.org References: <1459329025-8619-1-git-send-email-elliot.smith@intel.com> <1460470232.3309.15.camel@linux.intel.com> From: Michael Wood Message-ID: <57165DA3.6080300@intel.com> Date: Tue, 19 Apr 2016 17:32:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [PATCH] toaster: disable/enable "Add layer" button according to input's content X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Apr 2016 16:32:40 -0000 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sent to bitbake-devel and added to toaster-next Thanks, Michael On 12/04/16 15:23, Smith, Elliot wrote: > Thanks for the review. > > Yes, that should be possible. > > Note that I have to rework this a bit anyway because of the bootstrap > 3 changes, which will have an impact on it. It might be best to hold > off from sending this patch upstream until those changes are done. > > Elliot > > On 12 April 2016 at 15:10, Joshua G Lock > > > wrote: > > Hi Elliot, > > On Wed, 2016-03-30 at 10:10 +0100, Elliot Smith wrote: > > 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. > > I tried your patch out and it seems to work nicely. > > The only minor surprise is that if I select a matched layer from the > typeahead, then change my mind and begin deleting that layer text the > Add button remains active (with the same selection) until I've > completely deleted from the layer name field. > > Is it possible to unselect from the typeahead when deletion begins? > > Regards, > > Joshua > > > > > [YOCTO #8511] > > > > Signed-off-by: Elliot Smith > > > --- > > .../toaster/toastergui/static/js/importlayer.js | 30 > > +++++++++++++++++++++- > > .../lib/toaster/toastergui/static/js/libtoaster.js | 5 ++++ > > 2 files changed, 34 insertions(+), 1 deletion(-) > > > > diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js > > b/bitbake/lib/toaster/toastergui/static/js/importlayer.js > > index c68f366..5a59799 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) { > > > > libtoaster.makeTypeahead(layerDepInput, > > libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, > > function(item){ > > currentLayerDepSelection = item; > > + }); > > + > > + // 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 = {}; > > > > - layerDepBtn.removeAttr("disabled"); > > + if (data.choices) { > > + data.choices.forEach(function (item) { > > + layerDepsChoices[item.name ] = item; > > + }); > > + } > > }); > > > > + // 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; > > + } > > + }); > > > > /* We automatically add "openembedded-core" layer for convenience > > as a > > * 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 b6b49b6..0e81f67 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 (){ > > var xhrReq; > > > > jQElement.typeahead({ > > + // each time the typeahead's choices change, a > > + // "typeahead-choices-change" event is fired with an object > > + // containing the available choices in a "choices" property > > source: function(query, process){ > > xhrParams.search = query; > > > > @@ -36,6 +39,8 @@ var libtoaster = (function (){ > > > > xhrReq = null; > > > > + jQElement.trigger("typeahead-choices-change", {choices: > > data.results}); > > + > > return process(data.results); > > }); > > }, > > -- > > 1.9.3 > > > > > --------------------------------------------------------------------- > > Intel Corporation (UK) Limited > > Registered No. 1134945 (England) > > Registered Office: Pipers Way, Swindon SN3 1RJ > > VAT No: 860 2173 47 > > > > This e-mail and any attachments may contain confidential > material for > > the sole use of the intended recipient(s). Any review or > distribution > > by others is strictly prohibited. If you are not the intended > > recipient, please contact the sender and delete all copies. > > > > > > > -- > Elliot Smith > Software Engineer > Intel Open Source Technology Centre > >