summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js/table.js
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/table.js')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/table.js83
1 files changed, 48 insertions, 35 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
index 7f76f555fc..749eb8e75c 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -75,14 +75,21 @@ function tableInit(ctx){
75 75
76 if (tableData.total === 0){ 76 if (tableData.total === 0){
77 tableContainer.hide(); 77 tableContainer.hide();
78 if ($("#no-results-special-"+ctx.tableName).length > 0) { 78 /* No results caused by a search returning nothing */
79 /* use this page's special no-results form instead of the default */ 79 if (tableParams.search) {
80 $("#no-results-search-input-"+ctx.tableName).val(tableParams.search); 80 if ($("#no-results-special-"+ctx.tableName).length > 0) {
81 $("#no-results-special-"+ctx.tableName).show(); 81 /* use this page's special no-results form instead of the default */
82 $("#results-found-"+ctx.tableName).hide(); 82 $("#no-results-search-input-"+ctx.tableName).val(tableParams.search);
83 } else { 83 $("#no-results-special-"+ctx.tableName).show();
84 $("#new-search-input-"+ctx.tableName).val(tableParams.search); 84 $("#results-found-"+ctx.tableName).hide();
85 $("#no-results-"+ctx.tableName).show(); 85 } else {
86 $("#new-search-input-"+ctx.tableName).val(tableParams.search);
87 $("#no-results-"+ctx.tableName).show();
88 }
89 }
90 else {
91 /* No results caused by there being no data */
92 $("#empty-state-"+ctx.tableName).show();
86 } 93 }
87 table.trigger("table-done", [tableData.total, tableParams]); 94 table.trigger("table-done", [tableData.total, tableParams]);
88 95
@@ -90,6 +97,7 @@ function tableInit(ctx){
90 } else { 97 } else {
91 tableContainer.show(); 98 tableContainer.show();
92 $("#no-results-"+ctx.tableName).hide(); 99 $("#no-results-"+ctx.tableName).hide();
100 $("#empty-state-"+ctx.tableName).hide();
93 } 101 }
94 102
95 setupTableChrome(tableData); 103 setupTableChrome(tableData);
@@ -169,7 +177,7 @@ function tableInit(ctx){
169 if (tableChromeDone === true) 177 if (tableChromeDone === true)
170 return; 178 return;
171 179
172 var tableHeadRow = table.find("thead"); 180 var tableHeadRow = table.find("thead > tr");
173 var editColMenu = $("#table-chrome-"+ctx.tableName).find(".editcol"); 181 var editColMenu = $("#table-chrome-"+ctx.tableName).find(".editcol");
174 182
175 tableHeadRow.html(""); 183 tableHeadRow.html("");
@@ -190,7 +198,7 @@ function tableInit(ctx){
190 198
191 /* Setup the help text */ 199 /* Setup the help text */
192 if (col.help_text.length > 0) { 200 if (col.help_text.length > 0) {
193 var help_text = $('<i class="icon-question-sign get-help"> </i>'); 201 var help_text = $('<span class="glyphicon glyphicon-question-sign get-help"> </span>');
194 help_text.tooltip({title: col.help_text}); 202 help_text.tooltip({title: col.help_text});
195 header.append(help_text); 203 header.append(help_text);
196 } 204 }
@@ -227,12 +235,12 @@ function tableInit(ctx){
227 } else { 235 } else {
228 /* Not orderable */ 236 /* Not orderable */
229 header.css("font-weight", "normal"); 237 header.css("font-weight", "normal");
230 header.append('<span class="muted">' + col.title + '</span> '); 238 header.append('<span class="text-muted">' + col.title + '</span> ');
231 } 239 }
232 240
233 /* Setup the filter button */ 241 /* Setup the filter button */
234 if (col.filter_name){ 242 if (col.filter_name){
235 var filterBtn = $('<a href="#" role="button" data-filter-on="' + col.filter_name + '" class="pull-right btn btn-mini" data-toggle="modal"><i class="icon-filter filtered"></i></a>'); 243 var filterBtn = $('<a href="#" role="button" data-filter-on="' + col.filter_name + '" class="pull-right btn btn-link btn-xs" data-toggle="modal"><i class="glyphicon glyphicon-filter filtered"></i></a>');
236 244
237 filterBtn.data('filter-name', col.filter_name); 245 filterBtn.data('filter-name', col.filter_name);
238 filterBtn.prop('id', col.filter_name); 246 filterBtn.prop('id', col.filter_name);
@@ -251,7 +259,7 @@ function tableInit(ctx){
251 tableHeadRow.append(header); 259 tableHeadRow.append(header);
252 260
253 /* Now setup the checkbox state and click handler */ 261 /* Now setup the checkbox state and click handler */
254 var toggler = $('<li><label class="checkbox">'+col.title+'<input type="checkbox" id="checkbox-'+ col.field_name +'" class="col-toggle" value="'+col.field_name+'" /></label></li>'); 262 var toggler = $('<li><div class="checkbox"><label><input type="checkbox" id="checkbox-'+ col.field_name +'" class="col-toggle" value="'+col.field_name+'" />'+col.title+'</label></div></li>');
255 263
256 var togglerInput = toggler.find("input"); 264 var togglerInput = toggler.find("input");
257 265
@@ -261,7 +269,8 @@ function tableInit(ctx){
261 if (col.hideable){ 269 if (col.hideable){
262 togglerInput.click(colToggleClicked); 270 togglerInput.click(colToggleClicked);
263 } else { 271 } else {
264 toggler.find("label").addClass("muted"); 272 toggler.find("label").addClass("text-muted");
273 toggler.find("label").parent().addClass("disabled");
265 togglerInput.attr("disabled", "disabled"); 274 togglerInput.attr("disabled", "disabled");
266 } 275 }
267 276
@@ -278,11 +287,12 @@ function tableInit(ctx){
278 /* Toggles the active state of the filter button */ 287 /* Toggles the active state of the filter button */
279 function filterBtnActive(filterBtn, active){ 288 function filterBtnActive(filterBtn, active){
280 if (active) { 289 if (active) {
290 filterBtn.removeClass("btn-link");
281 filterBtn.addClass("btn-primary"); 291 filterBtn.addClass("btn-primary");
282 292
283 filterBtn.tooltip({ 293 filterBtn.tooltip({
284 html: true, 294 html: true,
285 title: '<button class="btn btn-small btn-primary" onClick=\'$("#clear-filter-btn-'+ ctx.tableName +'").click();\'>Clear filter</button>', 295 title: '<button class="btn btn-sm btn-primary" onClick=\'$("#clear-filter-btn-'+ ctx.tableName +'").click();\'>Clear filter</button>',
286 placement: 'bottom', 296 placement: 'bottom',
287 delay: { 297 delay: {
288 hide: 1500, 298 hide: 1500,
@@ -291,6 +301,7 @@ function tableInit(ctx){
291 }); 301 });
292 } else { 302 } else {
293 filterBtn.removeClass("btn-primary"); 303 filterBtn.removeClass("btn-primary");
304 filterBtn.addClass("btn-link");
294 filterBtn.tooltip('destroy'); 305 filterBtn.tooltip('destroy');
295 } 306 }
296 } 307 }
@@ -396,23 +407,23 @@ function tableInit(ctx){
396 var hasNoRecords = (Number(filterActionData.count) == 0); 407 var hasNoRecords = (Number(filterActionData.count) == 0);
397 408
398 var actionStr = '<div class="radio">' + 409 var actionStr = '<div class="radio">' +
399 '<input type="radio" name="filter"' + 410 '<label class="filter-title' +
400 ' value="' + filterName + '"'; 411 (hasNoRecords ? ' text-muted' : '') + '"' +
412 ' for="' + filterName + '">' +
413 '<input type="radio" name="filter"' +
414 ' value="' + filterName + '"';
401 415
402 if (hasNoRecords) { 416 if (hasNoRecords) {
403 actionStr += ' disabled="disabled"'; 417 actionStr += ' disabled="disabled"';
404 } 418 }
405 419
406 actionStr += ' id="' + filterName + '">' + 420 actionStr += ' id="' + filterName + '">' +
407 '<input type="hidden" name="filter_value" value="on"' + 421 '<input type="hidden" name="filter_value" value="on"' +
408 ' data-value-for="' + filterName + '">' + 422 ' data-value-for="' + filterName + '">' +
409 '<label class="filter-title' + 423 filterActionData.title +
410 (hasNoRecords ? ' muted' : '') + '"' + 424 ' (' + filterActionData.count + ')' +
411 ' for="' + filterName + '">' + 425 '</label>' +
412 filterActionData.title + 426 '</div>';
413 ' (' + filterActionData.count + ')' +
414 '</label>' +
415 '</div>';
416 427
417 var action = $(actionStr); 428 var action = $(actionStr);
418 429
@@ -446,22 +457,23 @@ function tableInit(ctx){
446 */ 457 */
447 function createActionDateRange(filterName, filterValue, filterActionData) { 458 function createActionDateRange(filterName, filterValue, filterActionData) {
448 var action = $('<div class="radio">' + 459 var action = $('<div class="radio">' +
460 '<label class="filter-title"' +
461 ' for="' + filterName + '">' +
449 '<input type="radio" name="filter"' + 462 '<input type="radio" name="filter"' +
450 ' value="' + filterName + '" ' + 463 ' value="' + filterName + '" ' +
451 ' id="' + filterName + '">' + 464 ' id="' + filterName + '">' +
452 '<input type="hidden" name="filter_value" value=""' + 465 '<input type="hidden" name="filter_value" value=""' +
453 ' data-value-for="' + filterName + '">' + 466 ' data-value-for="' + filterName + '">' +
454 '<label class="filter-title"' +
455 ' for="' + filterName + '">' +
456 filterActionData.title + 467 filterActionData.title +
457 '</label>' + 468 '</label>' +
458 '<input type="text" maxlength="10" class="input-small"' + 469 '<div class="form-inline form-group date-filter-controls">' +
470 '<input type="text" maxlength="10" class="form-control"' +
459 ' data-date-from-for="' + filterName + '">' + 471 ' data-date-from-for="' + filterName + '">' +
460 '<span class="help-inline">to</span>' + 472 '<span>to</span>' +
461 '<input type="text" maxlength="10" class="input-small"' + 473 '<input type="text" maxlength="10" class="form-control"' +
462 ' data-date-to-for="' + filterName + '">' + 474 ' data-date-to-for="' + filterName + '">' +
463 '<span class="help-inline get-help">(yyyy-mm-dd)</span>' + 475 '<span class="help-inline get-help">(yyyy-mm-dd)</span>' +
464 '</div>'); 476 '</div></div>');
465 477
466 var radio = action.find('[type="radio"]'); 478 var radio = action.find('[type="radio"]');
467 var value = action.find('[data-value-for]'); 479 var value = action.find('[data-value-for]');
@@ -602,7 +614,7 @@ function tableInit(ctx){
602 queryset on the table 614 queryset on the table
603 */ 615 */
604 var filterActionRadios = $('#filter-actions-' + ctx.tableName); 616 var filterActionRadios = $('#filter-actions-' + ctx.tableName);
605 var filterApplyBtn = $('[data-role="filter-apply"]'); 617 var filterApplyBtn = $('[data-cat="filter-apply"]');
606 618
607 var setApplyButtonState = function (e, filterActionValue) { 619 var setApplyButtonState = function (e, filterActionValue) {
608 if (filterActionValue !== undefined) { 620 if (filterActionValue !== undefined) {
@@ -643,7 +655,7 @@ function tableInit(ctx){
643 if (action) { 655 if (action) {
644 // Setup the current selected filter; default to 'all' if 656 // Setup the current selected filter; default to 'all' if
645 // no current filter selected 657 // no current filter selected
646 var radioInput = action.children('input[name="filter"]'); 658 var radioInput = action.find('input[name="filter"]');
647 if ((tableParams.filter && 659 if ((tableParams.filter &&
648 tableParams.filter === radioInput.val()) || 660 tableParams.filter === radioInput.val()) ||
649 filterActionData.action_name == 'all') { 661 filterActionData.action_name == 'all') {
@@ -769,6 +781,7 @@ function tableInit(ctx){
769 781
770 loadData(tableParams); 782 loadData(tableParams);
771 783
772 $(this).parent().modal('hide'); 784
785 $('#filter-modal-'+ctx.tableName).modal('hide');
773 }); 786 });
774} 787}