aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js/table.js
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-01-15 13:00:54 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-15 16:30:00 +0000
commit33b011c1589519db8176c9f5a4abb540698902e6 (patch)
tree104367160098dffb4c05c2120db1c2c8ef470449 /bitbake/lib/toaster/toastergui/static/js/table.js
parentf8d383d87f0b9d4a4c9ae7b1a6c8ceebf90ef9b0 (diff)
downloadopenembedded-core-contrib-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/js/table.js')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/table.js56
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){
if (tableData.total === 0){
tableContainer.hide();
- /* If we were searching show the new search bar and return */
- if (tableParams.search){
- $("#new-search-input-"+ctx.tableName).val(tableParams.search);
- $("#no-results-"+ctx.tableName).show();
- }
+ $("#new-search-input-"+ctx.tableName).val(tableParams.search);
+ $("#no-results-"+ctx.tableName).show();
table.trigger("table-done", [tableData.total, tableParams]);
return;
-
- /* We don't want to clutter the place with the table chrome if there
- * are only a few results */
- } else if (tableData.total <= 10 &&
- !tableParams.filter &&
- !tableParams.search){
- $("#table-chrome-"+ctx.tableName).hide();
- pagination.hide();
} else {
tableContainer.show();
$("#no-results-"+ctx.tableName).hide();
@@ -399,13 +388,14 @@ function tableInit(ctx){
/**
* Create the DOM/JS for the client side of a TableFilterActionToggle
+ * or TableFilterActionDay
*
* filterName: (string) internal name for the filter action
* filterActionData: (object)
* filterActionData.count: (number) The number of items this filter will
* show when selected
*/
- function createActionToggle(filterName, filterActionData) {
+ function createActionRadio(filterName, filterActionData) {
var actionStr = '<div class="radio">' +
'<input type="radio" name="filter"' +
' value="' + filterName + '"';
@@ -471,8 +461,7 @@ function tableInit(ctx){
minDate: new Date(filterActionData.min)
};
- // create date pickers, setting currently-selected from and to
- // dates
+ // create date pickers, setting currently-selected from and to dates
var selectedFrom = null;
var selectedTo = null;
@@ -496,6 +485,20 @@ function tableInit(ctx){
action.find('[data-date-to-for]').datepicker(options);
inputTo.val(selectedTo);
+ // if the radio button is checked and one or both of the datepickers are
+ // empty, populate them with today's date
+ radio.change(function () {
+ var now = new Date();
+
+ if (inputFrom.val() === '') {
+ inputFrom.datepicker('setDate', now);
+ }
+
+ if (inputTo.val() === '') {
+ inputTo.datepicker('setDate', now);
+ }
+ });
+
// set filter_value based on date pickers when
// one of their values changes
var changeHandler = function () {
@@ -553,7 +556,8 @@ function tableInit(ctx){
{
title: '<label for radio button inside the popup>',
name: '<name of the filter action>',
- count: <number of items this filter will show>
+ count: <number of items this filter will show>,
+ ... additional data for the action ...
}
]
}
@@ -567,11 +571,12 @@ function tableInit(ctx){
filter
the filterName is set on the column filter icon, and corresponds
- to a value in the table's filters property
+ to a value in the table's filter map
when the filter popup's "Apply" button is clicked, the
value for the radio button which is checked is passed in the
- querystring and applied to the queryset on the table
+ querystring, along with a filter_value, and applied to the
+ queryset on the table
*/
var filterActionRadios = $('#filter-actions-' + ctx.tableName);
@@ -587,10 +592,12 @@ function tableInit(ctx){
var filterName = filterData.name + ':' +
filterActionData.action_name;
- if (filterActionData.type === 'toggle') {
- action = createActionToggle(filterName, filterActionData);
+ if (filterActionData.type === 'toggle' ||
+ filterActionData.type === 'day') {
+ action = createActionRadio(filterName, filterActionData);
}
else if (filterActionData.type === 'daterange') {
+ // current values for the from/to dates
var filterValue = tableParams.filter_value;
action = createActionDateRange(
@@ -601,7 +608,7 @@ function tableInit(ctx){
}
if (action) {
- // Setup the current selected filter, default to 'all' if
+ // Setup the current selected filter; default to 'all' if
// no current filter selected
var radioInput = action.children('input[name="filter"]');
if ((tableParams.filter &&
@@ -707,13 +714,12 @@ function tableInit(ctx){
tableParams.filter + "']");
tableParams.filter_value = checkedFilterValue.val();
- var filterBtn = $("#" + tableParams.filter.split(":")[0]);
-
/* All === remove filter */
if (tableParams.filter.match(":all$")) {
tableParams.filter = null;
- filterBtnActive(filterBtn, false);
+ tableParams.filter_value = null;
} else {
+ var filterBtn = $("#" + tableParams.filter.split(":")[0]);
filterBtnActive(filterBtn, true);
}