Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 58FC6E009A5; Thu, 1 Dec 2016 08:45:47 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [209.85.210.180 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-wj0-f180.google.com (mail-wj0-f180.google.com [209.85.210.180]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id CC215E00503 for ; Thu, 1 Dec 2016 08:45:45 -0800 (PST) Received: by mail-wj0-f180.google.com with SMTP id v7so209654354wjy.2 for ; Thu, 01 Dec 2016 08:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wsxWwqQyMPWWiTEcu9QYwM78b5UZZrGrBHkF4Dfk0ic=; b=YtIACpNACMGsEEFherDWZZpf/ckp+LqWJrp2wmo/ZpmeZg14NH82a3IdRZCHBeHxo9 L0qWqjruZcFu3kZKQxayStbPOKAas+B0Ynb4zfJcRV8yLMKVxJtV3gxLR4P6HDERgCnM wxldmFDymO4ZDajLl/+Oph92bUq06A/0MyZYlWuwjtTQESLXWqJC+VWdeFkH7B3h2hxJ ffEItcMgUhJANjxb/xliPP602AfmjUlI+VrkSunUxwkEX6ZUxpceLG0R28005FkbJMwF MsdYOpz1rOcdOIeG1a7o9wq0ZdApTOyjIDw+D0m8qfKOOWMQI3f6SFMTsFoGotBJDF7g 3u3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wsxWwqQyMPWWiTEcu9QYwM78b5UZZrGrBHkF4Dfk0ic=; b=jyGiULj41xo1X2wIIh2NpEgm0rZCAcPjnSDfBXug5XAhbHmxjYIkKAqZqLbVqnZGvE g37XES4kZ/HjNxzLvmQ8gm3n54aAMWeD8IUUOcW5ywAaBQJVL1bSNnEQrUymb038Cytd ZOCR/HgY93wzpLM7FhxLdba5HyAxyy4CS9eWeYZjrggd2mSYi9twVXi1fX9FeBVo01HE 9uGNB77ow8RCfO7hc3VxvSp68uVJJhSm7ecgNee7AWZYXijYA/qLXoT7aM304g15Q13H rG5jcXFgrtL/t7E0AWvRkpA6arN0K3SdJSCm0KEbxnX8UhwRBk8/q4MkQ4Yebffs7i9l Qlog== X-Gm-Message-State: AKaTC000vfPzkMIeKx3qezpsX75CHZ+7OJ5SIdmBiuebcaJTGDEmwZWuFhAJ958Q8R88B3Eo X-Received: by 10.194.80.42 with SMTP id o10mr40180211wjx.65.1480610744477; Thu, 01 Dec 2016 08:45:44 -0800 (PST) Received: from localhost.localdomain ([192.198.151.62]) by smtp.gmail.com with ESMTPSA id 14sm1801422wmk.1.2016.12.01.08.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Dec 2016 08:45:43 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 1 Dec 2016 16:45:33 +0000 Message-Id: <1480610733-11839-3-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480610733-11839-1-git-send-email-michael.g.wood@intel.com> References: <1480610733-11839-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 3/3] toaster: importlayer Add git revision typeahead to that input field 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: Thu, 01 Dec 2016 16:45:47 -0000 Add the front end mechanism to load the typeahead for the git revision field on importing a layer. Also fix one indentation issue and update the js test. Signed-off-by: Michael Wood --- .../lib/toaster/toastergui/static/css/default.css | 1 - .../toaster/toastergui/static/js/importlayer.js | 29 +++++++++++++++++----- .../lib/toaster/toastergui/static/js/tests/test.js | 2 +- .../toaster/toastergui/templates/importlayer.html | 5 +++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/css/default.css b/bitbake/lib/toaster/toastergui/static/css/default.css index ff24e8c..5cd7e21 100644 --- a/bitbake/lib/toaster/toastergui/static/css/default.css +++ b/bitbake/lib/toaster/toastergui/static/css/default.css @@ -210,7 +210,6 @@ fieldset.fields-apart-from-layer-name { margin-top: 20px; } #import-layer-name, #layer-subdir { width: 20%; } #layer-git-repo-url { width: 40%; } -#layer-git-ref { width: 32%; } #local-dir-path { width: 45%; } #layer-dependency { width: 16em; } #layer-deps-list { margin-top: 0; } diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index 4784c65..b3f094e 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -45,7 +45,7 @@ function importLayerPageInit (ctx) { function(layer) { if (layer.results.length > 0) { currentLayerDepSelection = layer.results[0]; - layerDepBtn.click(); + layerDepBtn.click(); } }); @@ -333,19 +333,36 @@ function importLayerPageInit (ctx) { check_form(); }); - /* Have a guess at the layer name */ + /* Setup 'blank' typeahead */ + libtoaster.makeTypeahead(gitRefInput, + ctx.xhrGitRevTypeAheadUrl, + { git_url: null }, function(){}); + + vcsURLInput.focusout(function (){ + if (!$(this).val()) + return; + /* If we a layer name specified don't overwrite it or if there isn't a * url typed in yet return */ - if (layerNameInput.val() || !$(this).val()) - return; - - if ($(this).val().search("/")){ + if (!layerNameInput.val() && $(this).val().search("/")){ var urlPts = $(this).val().split("/"); + /* Add a suggestion of the layer name */ var suggestion = urlPts[urlPts.length-1].replace(".git",""); layerNameInput.val(suggestion); } + + /* Now actually setup the typeahead properly with the git url entered */ + gitRefInput._typeahead('destroy'); + + libtoaster.makeTypeahead(gitRefInput, + ctx.xhrGitRevTypeAheadUrl, + { git_url: $(this).val() }, + function(selected){ + gitRefInput._typeahead("close"); + }); + }); function radioDisplay() { diff --git a/bitbake/lib/toaster/toastergui/static/js/tests/test.js b/bitbake/lib/toaster/toastergui/static/js/tests/test.js index d7953de..f3bf8d7 100644 --- a/bitbake/lib/toaster/toastergui/static/js/tests/test.js +++ b/bitbake/lib/toaster/toastergui/static/js/tests/test.js @@ -144,7 +144,7 @@ QUnit.test("Make typeaheads", function(assert){ /* Page init functions */ QUnit.test("Import layer page init", function(assert){ - assert.throws(importLayerPageInit()); + assert.throws(importLayerPageInit({ xhrGitRevTypeAheadUrl: "url" })); }); QUnit.test("Project page init", function(assert){ diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html index bd507b5..afbeb94 100644 --- a/bitbake/lib/toaster/toastergui/templates/importlayer.html +++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html @@ -14,6 +14,7 @@ $(document).ready(function (){ var ctx = { xhrLayerUrl : "{% url 'xhr_layer' project.id %}", + xhrGitRevTypeAheadUrl : "{% url 'xhr_gitrevtypeahead' %}", }; try { @@ -112,8 +113,10 @@ Git revision - + + + -- 2.7.4