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>
This commit is contained in:
Michael Wood 2015-08-04 22:46:34 +03:00 committed by Richard Purdie
parent 73367c2ca8
commit aff29d2cd8
7 changed files with 37 additions and 26 deletions

View File

@ -89,8 +89,8 @@ function basePageInit(ctx) {
}
/* If we have a project setup the typeahead */
if (selectedProject.projectTargetsUrl){
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) {
if (selectedProject.recipesTypeAheadUrl){
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
selectedTarget = item;
newBuildTargetBuildBtn.removeAttr("disabled");
});
@ -156,7 +156,7 @@ function basePageInit(ctx) {
$('#project .icon-pencil').hide();
}
libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) {
libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsTypeAheadUrl, { format : "json" }, function (item) {
/* successfully selected a project */
newBuildProjectSaveBtn.removeAttr("disabled");
selectedProject = item;
@ -180,13 +180,21 @@ function basePageInit(ctx) {
newBuildTargetInput.removeAttr("disabled");
/* Update the typeahead to use the new selectedProject */
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) {
/* successfully selected a target */
selectedTarget = item;
newBuildTargetBuildBtn.removeAttr("disabled");
});
/* We've got a new project so now we need to update the
* target urls. We can get this from the new project's info
*/
$.getJSON(selectedProject.projectPageUrl, { format: "json" },
function(projectInfo){
/* Update the typeahead to use the new selectedProject */
selectedProject = projectInfo;
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
/* successfully selected a target */
selectedTarget = item;
newBuildTargetBuildBtn.removeAttr("disabled");
});
});
newBuildTargetInput.val("");
/* set up new form aspect */

View File

@ -16,7 +16,7 @@ function importLayerPageInit (ctx) {
var currentLayerDepSelection;
var validLayerName = /^(\w|-)+$/;
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
currentLayerDepSelection = item;
layerDepBtn.removeAttr("disabled");
@ -26,11 +26,11 @@ function importLayerPageInit (ctx) {
/* We automatically add "openembedded-core" layer for convenience as a
* dependency as pretty much all layers depend on this one
*/
$.getJSON(libtoaster.ctx.projectLayersUrl,
{ include_added: "true" , search: "openembedded-core", format: "json" },
$.getJSON(libtoaster.ctx.layersTypeAheadUrl,
{ include_added: "true" , search: "openembedded-core" },
function(layer) {
if (layer.rows.length > 0) {
currentLayerDepSelection = layer.rows[0];
if (layer.results.length > 0) {
currentLayerDepSelection = layer.results[0];
layerDepBtn.click();
}
});
@ -211,7 +211,7 @@ function importLayerPageInit (ctx) {
var name = $(this).val();
/* Check if the layer name exists */
$.getJSON(libtoaster.ctx.projectLayersUrl,
$.getJSON(libtoaster.ctx.layersTypeAheadUrl,
{ include_added: "true" , search: name, format: "json" },
function(layer) {
if (layer.rows.length > 0) {

View File

@ -9,7 +9,7 @@ function layerDetailsPageInit (ctx) {
var addRmLayerBtn = $("#add-remove-layer-btn");
/* setup the dependencies typeahead */
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
currentLayerDepSelection = item;
layerDepBtn.removeAttr("disabled");

View File

@ -19,14 +19,13 @@ var libtoaster = (function (){
jQElement.typeahead({
source: function(query, process){
xhrParams.search = query;
xhrParams.format = "json";
$.getJSON(xhrUrl, this.options.xhrParams, function(data){
if (data.error !== "ok") {
console.log("Error getting data from server "+data.error);
return;
}
return process (data.rows);
return process(data.results);
});
},
updater: function(item) {
@ -40,7 +39,7 @@ var libtoaster = (function (){
return 0;
}
return ~item.name.toLowerCase().indexOf(this.query.toLowerCase());
return 1;
},
highlighter: function (item) {
if (item.hasOwnProperty('detail'))

View File

@ -98,7 +98,7 @@ function projectPageInit(ctx) {
/* Add/Rm layer functionality */
libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.projectLayersUrl, { include_added: "false" }, function(item){
libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "false" }, function(item){
currentLayerAddSelection = item;
layerAddBtn.removeAttr("disabled");
});
@ -251,7 +251,7 @@ function projectPageInit(ctx) {
machineNameTitle.text(machineName);
}
libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.projectMachinesUrl, { }, function(item){
libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.machinesTypeAheadUrl, { }, function(item){
currentMachineAddSelection = item;
machineChangeBtn.removeAttr("disabled");
});

View File

@ -32,14 +32,16 @@
jsUrl : "{% static 'js/' %}",
htmlUrl : "{% static 'html/' %}",
projectsUrl : "{% url 'all-projects' %}",
projectsTypeAheadUrl: {% url 'xhr_projectstypeahead' as prjurl%}{{prjurl|json}},
{% if project.id %}
projectId : {{project.id}},
projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}},
projectName : {{project.name|json}},
projectTargetsUrl: {% url 'projectavailabletargets' project.id as paturl%}{{paturl|json}},
recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}},
layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}},
machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}},
projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
projectLayersUrl: {% url 'projectlayers' project.id as plurl %}{{plurl|json}},
projectMachinesUrl: {% url 'projectmachines' project.id as pmurl %}{{pmurl|json}},
projectId : {{project.id}},
{% else %}
projectId : undefined,

View File

@ -2235,6 +2235,8 @@ if True:
"freqtargets": freqtargets[:5],
"releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
"project_html": 1,
"recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),
"projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)),
}
if prj.release is not None:
@ -2784,9 +2786,9 @@ if True:
for p in project_info.object_list:
p.id = p.pk
p.projectPageUrl = reverse('project', args=(p.id,))
p.projectLayersUrl = reverse('projectlayers', args=(p.id,))
p.layersTypeAheadUrl = reverse('xhr_layerstypeahead', args=(p.id,))
p.recipesTypeAheadUrl = reverse('xhr_recipestypeahead', args=(p.id,))
p.projectBuildsUrl = reverse('projectbuilds', args=(p.id,))
p.projectTargetsUrl = reverse('projectavailabletargets', args=(p.id,))
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
build_mru = _get_latest_builds()