diff options
author | Elliot Smith <elliot.smith@intel.com> | 2016-01-15 13:00:54 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-15 16:30:00 +0000 |
commit | 33b011c1589519db8176c9f5a4abb540698902e6 (patch) | |
tree | 104367160098dffb4c05c2120db1c2c8ef470449 /bitbake/lib/toaster/toastergui/static | |
parent | f8d383d87f0b9d4a4c9ae7b1a6c8ceebf90ef9b0 (diff) | |
download | poky-33b011c1589519db8176c9f5a4abb540698902e6.tar.gz |
bitbake: toastergui: implement "today" and "yesterday" filters
Add the "today" and "yesterday" filters to the started_on
and completed_on columns in the builds table.
During this work, some minor adjustments were made to the
behaviour of the builds table:
* Amend filter action variable names so they're more succinct.
* Retain order in which actions are added to a filter, as this
ordering is used in the UI when displaying the filter actions.
* Always show the table chrome, otherwise it's not possible
to edit the columns shown until there are 10 or more results.
* Because date range searches may return no results, make sure
that the search bar and "show all results" link are visible
when the query returns no results.
[YOCTO #8738]
(Bitbake rev: f17cfa009e58833e0e55884fa04de8abd522b6bc)
Signed-off-by: Elliot Smith <elliot.smith@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')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/table.js | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js index b0a8ffb8f9..afe16b5e1b 100644 --- a/bitbake/lib/toaster/toastergui/static/js/table.js +++ b/bitbake/lib/toaster/toastergui/static/js/table.js | |||
@@ -71,22 +71,11 @@ function tableInit(ctx){ | |||
71 | 71 | ||
72 | if (tableData.total === 0){ | 72 | if (tableData.total === 0){ |
73 | tableContainer.hide(); | 73 | tableContainer.hide(); |
74 | /* If we were searching show the new search bar and return */ | 74 | $("#new-search-input-"+ctx.tableName).val(tableParams.search); |
75 | if (tableParams.search){ | 75 | $("#no-results-"+ctx.tableName).show(); |
76 | $("#new-search-input-"+ctx.tableName).val(tableParams.search); | ||
77 | $("#no-results-"+ctx.tableName).show(); | ||
78 | } | ||
79 | table.trigger("table-done", [tableData.total, tableParams]); | 76 | table.trigger("table-done", [tableData.total, tableParams]); |
80 | 77 | ||
81 | return; | 78 | return; |
82 | |||
83 | /* We don't want to clutter the place with the table chrome if there | ||
84 | * are only a few results */ | ||
85 | } else if (tableData.total <= 10 && | ||
86 | !tableParams.filter && | ||
87 | !tableParams.search){ | ||
88 | $("#table-chrome-"+ctx.tableName).hide(); | ||
89 | pagination.hide(); | ||
90 | } else { | 79 | } else { |
91 | tableContainer.show(); | 80 | tableContainer.show(); |
92 | $("#no-results-"+ctx.tableName).hide(); | 81 | $("#no-results-"+ctx.tableName).hide(); |
@@ -399,13 +388,14 @@ function tableInit(ctx){ | |||
399 | 388 | ||
400 | /** | 389 | /** |
401 | * Create the DOM/JS for the client side of a TableFilterActionToggle | 390 | * Create the DOM/JS for the client side of a TableFilterActionToggle |
391 | * or TableFilterActionDay | ||
402 | * | 392 | * |
403 | * filterName: (string) internal name for the filter action | 393 | * filterName: (string) internal name for the filter action |
404 | * filterActionData: (object) | 394 | * filterActionData: (object) |
405 | * filterActionData.count: (number) The number of items this filter will | 395 | * filterActionData.count: (number) The number of items this filter will |
406 | * show when selected | 396 | * show when selected |
407 | */ | 397 | */ |
408 | function createActionToggle(filterName, filterActionData) { | 398 | function createActionRadio(filterName, filterActionData) { |
409 | var actionStr = '<div class="radio">' + | 399 | var actionStr = '<div class="radio">' + |
410 | '<input type="radio" name="filter"' + | 400 | '<input type="radio" name="filter"' + |
411 | ' value="' + filterName + '"'; | 401 | ' value="' + filterName + '"'; |
@@ -471,8 +461,7 @@ function tableInit(ctx){ | |||
471 | minDate: new Date(filterActionData.min) | 461 | minDate: new Date(filterActionData.min) |
472 | }; | 462 | }; |
473 | 463 | ||
474 | // create date pickers, setting currently-selected from and to | 464 | // create date pickers, setting currently-selected from and to dates |
475 | // dates | ||
476 | var selectedFrom = null; | 465 | var selectedFrom = null; |
477 | var selectedTo = null; | 466 | var selectedTo = null; |
478 | 467 | ||
@@ -496,6 +485,20 @@ function tableInit(ctx){ | |||
496 | action.find('[data-date-to-for]').datepicker(options); | 485 | action.find('[data-date-to-for]').datepicker(options); |
497 | inputTo.val(selectedTo); | 486 | inputTo.val(selectedTo); |
498 | 487 | ||
488 | // if the radio button is checked and one or both of the datepickers are | ||
489 | // empty, populate them with today's date | ||
490 | radio.change(function () { | ||
491 | var now = new Date(); | ||
492 | |||
493 | if (inputFrom.val() === '') { | ||
494 | inputFrom.datepicker('setDate', now); | ||
495 | } | ||
496 | |||
497 | if (inputTo.val() === '') { | ||
498 | inputTo.datepicker('setDate', now); | ||
499 | } | ||
500 | }); | ||
501 | |||
499 | // set filter_value based on date pickers when | 502 | // set filter_value based on date pickers when |
500 | // one of their values changes | 503 | // one of their values changes |
501 | var changeHandler = function () { | 504 | var changeHandler = function () { |
@@ -553,7 +556,8 @@ function tableInit(ctx){ | |||
553 | { | 556 | { |
554 | title: '<label for radio button inside the popup>', | 557 | title: '<label for radio button inside the popup>', |
555 | name: '<name of the filter action>', | 558 | name: '<name of the filter action>', |
556 | count: <number of items this filter will show> | 559 | count: <number of items this filter will show>, |
560 | ... additional data for the action ... | ||
557 | } | 561 | } |
558 | ] | 562 | ] |
559 | } | 563 | } |
@@ -567,11 +571,12 @@ function tableInit(ctx){ | |||
567 | filter | 571 | filter |
568 | 572 | ||
569 | the filterName is set on the column filter icon, and corresponds | 573 | the filterName is set on the column filter icon, and corresponds |
570 | to a value in the table's filters property | 574 | to a value in the table's filter map |
571 | 575 | ||
572 | when the filter popup's "Apply" button is clicked, the | 576 | when the filter popup's "Apply" button is clicked, the |
573 | value for the radio button which is checked is passed in the | 577 | value for the radio button which is checked is passed in the |
574 | querystring and applied to the queryset on the table | 578 | querystring, along with a filter_value, and applied to the |
579 | queryset on the table | ||
575 | */ | 580 | */ |
576 | var filterActionRadios = $('#filter-actions-' + ctx.tableName); | 581 | var filterActionRadios = $('#filter-actions-' + ctx.tableName); |
577 | 582 | ||
@@ -587,10 +592,12 @@ function tableInit(ctx){ | |||
587 | var filterName = filterData.name + ':' + | 592 | var filterName = filterData.name + ':' + |
588 | filterActionData.action_name; | 593 | filterActionData.action_name; |
589 | 594 | ||
590 | if (filterActionData.type === 'toggle') { | 595 | if (filterActionData.type === 'toggle' || |
591 | action = createActionToggle(filterName, filterActionData); | 596 | filterActionData.type === 'day') { |
597 | action = createActionRadio(filterName, filterActionData); | ||
592 | } | 598 | } |
593 | else if (filterActionData.type === 'daterange') { | 599 | else if (filterActionData.type === 'daterange') { |
600 | // current values for the from/to dates | ||
594 | var filterValue = tableParams.filter_value; | 601 | var filterValue = tableParams.filter_value; |
595 | 602 | ||
596 | action = createActionDateRange( | 603 | action = createActionDateRange( |
@@ -601,7 +608,7 @@ function tableInit(ctx){ | |||
601 | } | 608 | } |
602 | 609 | ||
603 | if (action) { | 610 | if (action) { |
604 | // Setup the current selected filter, default to 'all' if | 611 | // Setup the current selected filter; default to 'all' if |
605 | // no current filter selected | 612 | // no current filter selected |
606 | var radioInput = action.children('input[name="filter"]'); | 613 | var radioInput = action.children('input[name="filter"]'); |
607 | if ((tableParams.filter && | 614 | if ((tableParams.filter && |
@@ -707,13 +714,12 @@ function tableInit(ctx){ | |||
707 | tableParams.filter + "']"); | 714 | tableParams.filter + "']"); |
708 | tableParams.filter_value = checkedFilterValue.val(); | 715 | tableParams.filter_value = checkedFilterValue.val(); |
709 | 716 | ||
710 | var filterBtn = $("#" + tableParams.filter.split(":")[0]); | ||
711 | |||
712 | /* All === remove filter */ | 717 | /* All === remove filter */ |
713 | if (tableParams.filter.match(":all$")) { | 718 | if (tableParams.filter.match(":all$")) { |
714 | tableParams.filter = null; | 719 | tableParams.filter = null; |
715 | filterBtnActive(filterBtn, false); | 720 | tableParams.filter_value = null; |
716 | } else { | 721 | } else { |
722 | var filterBtn = $("#" + tableParams.filter.split(":")[0]); | ||
717 | filterBtnActive(filterBtn, true); | 723 | filterBtnActive(filterBtn, true); |
718 | } | 724 | } |
719 | 725 | ||