Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 0AE13E00DBF; Fri, 9 Dec 2016 08:30:02 -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 * [74.125.82.46 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-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0A12EE00C40 for ; Fri, 9 Dec 2016 08:29:57 -0800 (PST) Received: by mail-wm0-f46.google.com with SMTP id g23so31735336wme.1 for ; Fri, 09 Dec 2016 08:29:57 -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=aUepZ6a1ccRG+rkb3QodU9jPnMPo4oNIeRK/TTgi6K+VWE7RCjcxdq7U7Qcn2ECEX/ gLtaadL6zJSx7Dspc9Bh9o0VToVktqiCUEo2JNOFaalNhqyDejxtbJSQnl24L/m3mfN9 FSv5IPzFyEDbgomcA0G6FAH/uwBt5sPi+rjj45l36MiY+jVlUPRJ5TdmiXUbxOFCwsoA 8VjH5FzKja6ObpqaBEOINt2xRIQrzZnuvFyU1G/TWXNcRNHx5wwsfxvzyhw+uXUgKtUk /fTZkLogJTFAG5eMwyZuOqjWuUJd+W4/CTQkUMEkQY5wgoSFaB81cNTIHm8jfsf+308d gBkQ== 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=bkFfX1zmp32qziL1xWNSiaGhRRyL/zVg8K/zn9ekFHpFp/ZUPASUXsRB2SkYYQmvVc CbtRlYz0hSJO5SOXL2pwqvgLxFsfS3BYh9wLqaXcnkgQrzri/n6PEqEnjpO/2gwJchZR 01nNRdx9wmDJJvnxBhHjOk/P8DQ/wS0eNDrigHhuqFwRm8TnhDBkcz7xMhHP1eM3QlH5 xTxtVAhACBbM04aE5z0vwklMhysN/GmCav/gyDfhcYQDmoMC/m0zHBdVA8fEAIpXJkCG DRCudyiiRsJGk1tbETt0d0yAfDTWpW147Hh2ee16O9UAS/17n+a1XmhO5aXcmxKVhOCA h2DA== X-Gm-Message-State: AKaTC02EHZCKvqH5G+JWxmrOJ1dlfbszCff4NX+9/INkKMC5VWzFKtImANEoIhis9EQsEj1z X-Received: by 10.28.211.72 with SMTP id k69mr7264121wmg.137.1481300996473; Fri, 09 Dec 2016 08:29:56 -0800 (PST) Received: from localhost.localdomain ([192.198.151.62]) by smtp.gmail.com with ESMTPSA id x5sm43051348wje.36.2016.12.09.08.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Dec 2016 08:29:56 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 9 Dec 2016 16:29:40 +0000 Message-Id: <1481300985-7356-10-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481300985-7356-1-git-send-email-michael.g.wood@intel.com> References: <1481300985-7356-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 09/14] 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: Fri, 09 Dec 2016 16:30:02 -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