diff options
| author | Michael Wood <michael.g.wood@intel.com> | 2015-08-04 22:46:34 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-06 16:04:45 -0500 |
| commit | aff29d2cd837df90a2897b9b75753e4af30f132e (patch) | |
| tree | ed512f81667282dd478b43f3f90c06b05bbcb06f /bitbake/lib/toaster/toastergui/static/js | |
| parent | 73367c2ca82143c618a22f9faaa101761f192397 (diff) | |
| download | poky-aff29d2cd837df90a2897b9b75753e4af30f132e.tar.gz | |
bitbake: toastergui: Switch to using the new toaster typeahead widget
Switch the existing typeahead inputs to use the new typeahead widget.
This means we have a defined mechanism and end point for typeaheads
which meets the design specification.
(Bitbake rev: 31a8ae7909347f7b6edde5bbdf02b86dc1b32ed0)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js')
5 files changed, 28 insertions, 21 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index f25336110a..eba9c16783 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js | |||
| @@ -89,8 +89,8 @@ function basePageInit(ctx) { | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /* If we have a project setup the typeahead */ | 91 | /* If we have a project setup the typeahead */ |
| 92 | if (selectedProject.projectTargetsUrl){ | 92 | if (selectedProject.recipesTypeAheadUrl){ |
| 93 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { | 93 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) { |
| 94 | selectedTarget = item; | 94 | selectedTarget = item; |
| 95 | newBuildTargetBuildBtn.removeAttr("disabled"); | 95 | newBuildTargetBuildBtn.removeAttr("disabled"); |
| 96 | }); | 96 | }); |
| @@ -156,7 +156,7 @@ function basePageInit(ctx) { | |||
| 156 | $('#project .icon-pencil').hide(); | 156 | $('#project .icon-pencil').hide(); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) { | 159 | libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsTypeAheadUrl, { format : "json" }, function (item) { |
| 160 | /* successfully selected a project */ | 160 | /* successfully selected a project */ |
| 161 | newBuildProjectSaveBtn.removeAttr("disabled"); | 161 | newBuildProjectSaveBtn.removeAttr("disabled"); |
| 162 | selectedProject = item; | 162 | selectedProject = item; |
| @@ -180,13 +180,21 @@ function basePageInit(ctx) { | |||
| 180 | 180 | ||
| 181 | newBuildTargetInput.removeAttr("disabled"); | 181 | newBuildTargetInput.removeAttr("disabled"); |
| 182 | 182 | ||
| 183 | /* Update the typeahead to use the new selectedProject */ | 183 | /* We've got a new project so now we need to update the |
| 184 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { | 184 | * target urls. We can get this from the new project's info |
| 185 | /* successfully selected a target */ | 185 | */ |
| 186 | selectedTarget = item; | 186 | $.getJSON(selectedProject.projectPageUrl, { format: "json" }, |
| 187 | newBuildTargetBuildBtn.removeAttr("disabled"); | 187 | function(projectInfo){ |
| 188 | }); | 188 | /* Update the typeahead to use the new selectedProject */ |
| 189 | selectedProject = projectInfo; | ||
| 190 | |||
| 191 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) { | ||
| 192 | /* successfully selected a target */ | ||
| 193 | selectedTarget = item; | ||
| 194 | newBuildTargetBuildBtn.removeAttr("disabled"); | ||
| 195 | }); | ||
| 189 | 196 | ||
| 197 | }); | ||
| 190 | newBuildTargetInput.val(""); | 198 | newBuildTargetInput.val(""); |
| 191 | 199 | ||
| 192 | /* set up new form aspect */ | 200 | /* set up new form aspect */ |
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index 50bc4ddd7c..2fadbc0978 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js | |||
| @@ -16,7 +16,7 @@ function importLayerPageInit (ctx) { | |||
| 16 | var currentLayerDepSelection; | 16 | var currentLayerDepSelection; |
| 17 | var validLayerName = /^(\w|-)+$/; | 17 | var validLayerName = /^(\w|-)+$/; |
| 18 | 18 | ||
| 19 | libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ | 19 | libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ |
| 20 | currentLayerDepSelection = item; | 20 | currentLayerDepSelection = item; |
| 21 | 21 | ||
| 22 | layerDepBtn.removeAttr("disabled"); | 22 | layerDepBtn.removeAttr("disabled"); |
| @@ -26,11 +26,11 @@ function importLayerPageInit (ctx) { | |||
| 26 | /* We automatically add "openembedded-core" layer for convenience as a | 26 | /* We automatically add "openembedded-core" layer for convenience as a |
| 27 | * dependency as pretty much all layers depend on this one | 27 | * dependency as pretty much all layers depend on this one |
| 28 | */ | 28 | */ |
| 29 | $.getJSON(libtoaster.ctx.projectLayersUrl, | 29 | $.getJSON(libtoaster.ctx.layersTypeAheadUrl, |
| 30 | { include_added: "true" , search: "openembedded-core", format: "json" }, | 30 | { include_added: "true" , search: "openembedded-core" }, |
| 31 | function(layer) { | 31 | function(layer) { |
| 32 | if (layer.rows.length > 0) { | 32 | if (layer.results.length > 0) { |
| 33 | currentLayerDepSelection = layer.rows[0]; | 33 | currentLayerDepSelection = layer.results[0]; |
| 34 | layerDepBtn.click(); | 34 | layerDepBtn.click(); |
| 35 | } | 35 | } |
| 36 | }); | 36 | }); |
| @@ -211,7 +211,7 @@ function importLayerPageInit (ctx) { | |||
| 211 | var name = $(this).val(); | 211 | var name = $(this).val(); |
| 212 | 212 | ||
| 213 | /* Check if the layer name exists */ | 213 | /* Check if the layer name exists */ |
| 214 | $.getJSON(libtoaster.ctx.projectLayersUrl, | 214 | $.getJSON(libtoaster.ctx.layersTypeAheadUrl, |
| 215 | { include_added: "true" , search: name, format: "json" }, | 215 | { include_added: "true" , search: name, format: "json" }, |
| 216 | function(layer) { | 216 | function(layer) { |
| 217 | if (layer.rows.length > 0) { | 217 | if (layer.rows.length > 0) { |
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index be6bbcd20f..96372f06f4 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js | |||
| @@ -9,7 +9,7 @@ function layerDetailsPageInit (ctx) { | |||
| 9 | var addRmLayerBtn = $("#add-remove-layer-btn"); | 9 | var addRmLayerBtn = $("#add-remove-layer-btn"); |
| 10 | 10 | ||
| 11 | /* setup the dependencies typeahead */ | 11 | /* setup the dependencies typeahead */ |
| 12 | libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ | 12 | libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ |
| 13 | currentLayerDepSelection = item; | 13 | currentLayerDepSelection = item; |
| 14 | 14 | ||
| 15 | layerDepBtn.removeAttr("disabled"); | 15 | layerDepBtn.removeAttr("disabled"); |
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 7edd0190f3..c9ff6507ef 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
| @@ -19,14 +19,13 @@ var libtoaster = (function (){ | |||
| 19 | jQElement.typeahead({ | 19 | jQElement.typeahead({ |
| 20 | source: function(query, process){ | 20 | source: function(query, process){ |
| 21 | xhrParams.search = query; | 21 | xhrParams.search = query; |
| 22 | xhrParams.format = "json"; | ||
| 23 | $.getJSON(xhrUrl, this.options.xhrParams, function(data){ | 22 | $.getJSON(xhrUrl, this.options.xhrParams, function(data){ |
| 24 | if (data.error !== "ok") { | 23 | if (data.error !== "ok") { |
| 25 | console.log("Error getting data from server "+data.error); | 24 | console.log("Error getting data from server "+data.error); |
| 26 | return; | 25 | return; |
| 27 | } | 26 | } |
| 28 | 27 | ||
| 29 | return process (data.rows); | 28 | return process(data.results); |
| 30 | }); | 29 | }); |
| 31 | }, | 30 | }, |
| 32 | updater: function(item) { | 31 | updater: function(item) { |
| @@ -40,7 +39,7 @@ var libtoaster = (function (){ | |||
| 40 | return 0; | 39 | return 0; |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | return ~item.name.toLowerCase().indexOf(this.query.toLowerCase()); | 42 | return 1; |
| 44 | }, | 43 | }, |
| 45 | highlighter: function (item) { | 44 | highlighter: function (item) { |
| 46 | if (item.hasOwnProperty('detail')) | 45 | if (item.hasOwnProperty('detail')) |
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js index b7cb074f11..b82f7408e7 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js | |||
| @@ -98,7 +98,7 @@ function projectPageInit(ctx) { | |||
| 98 | 98 | ||
| 99 | /* Add/Rm layer functionality */ | 99 | /* Add/Rm layer functionality */ |
| 100 | 100 | ||
| 101 | libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.projectLayersUrl, { include_added: "false" }, function(item){ | 101 | libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "false" }, function(item){ |
| 102 | currentLayerAddSelection = item; | 102 | currentLayerAddSelection = item; |
| 103 | layerAddBtn.removeAttr("disabled"); | 103 | layerAddBtn.removeAttr("disabled"); |
| 104 | }); | 104 | }); |
| @@ -251,7 +251,7 @@ function projectPageInit(ctx) { | |||
| 251 | machineNameTitle.text(machineName); | 251 | machineNameTitle.text(machineName); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.projectMachinesUrl, { }, function(item){ | 254 | libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.machinesTypeAheadUrl, { }, function(item){ |
| 255 | currentMachineAddSelection = item; | 255 | currentMachineAddSelection = item; |
| 256 | machineChangeBtn.removeAttr("disabled"); | 256 | machineChangeBtn.removeAttr("disabled"); |
| 257 | }); | 257 | }); |
