aboutsummaryrefslogtreecommitdiffstats
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.js80
1 files changed, 59 insertions, 21 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
index c69c205d50..fa01ddf47e 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -415,38 +415,76 @@ function tableInit(ctx){
data: params,
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
success: function (filterData) {
- var filterActionRadios = $('#filter-actions-'+ctx.tableName);
+ /*
+ filterData structure:
+
+ {
+ title: '<title for the filter popup>',
+ filter_actions: [
+ {
+ title: '<label for radio button inside the popup>',
+ name: '<name of the filter action>',
+ count: <number of items this filter will show>
+ }
+ ]
+ }
- $('#filter-modal-title-'+ctx.tableName).text(filterData.title);
+ each filter_action gets a radio button; the value of this is
+ set to filterName + ':' + filter_action.name; e.g.
- filterActionRadios.text("");
+ in_current_project:in_project
- for (var i in filterData.filter_actions){
- var filterAction = filterData.filter_actions[i];
+ specifies the "in_project" action of the "in_current_project"
+ filter
- var action = $('<label class="radio"><input type="radio" name="filter" value=""><span class="filter-title"></span></label>');
- var actionTitle = filterAction.title + ' (' + filterAction.count + ')';
+ the filterName is set on the column filter icon, and corresponds
+ to a value in the table's filters property
- var radioInput = action.children("input");
+ 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
+ */
- if (Number(filterAction.count) == 0){
- radioInput.attr("disabled", "disabled");
- }
+ var filterActionRadios = $('#filter-actions-'+ctx.tableName);
- action.children(".filter-title").text(actionTitle);
+ $('#filter-modal-title-'+ctx.tableName).text(filterData.title);
- radioInput.val(filterName + ':' + filterAction.name);
+ filterActionRadios.text("");
- /* Setup the current selected filter, default to 'all' if
- * no current filter selected.
- */
- if ((tableParams.filter &&
- tableParams.filter === radioInput.val()) ||
- filterAction.name == 'all') {
- radioInput.attr("checked", "checked");
+ for (var i in filterData.filter_actions) {
+ var filterAction = filterData.filter_actions[i];
+ var action = null;
+
+ if (filterAction.type === 'toggle') {
+ var actionTitle = filterAction.title + ' (' + filterAction.count + ')';
+
+ action = $('<label class="radio">' +
+ '<input type="radio" name="filter" value="">' +
+ '<span class="filter-title">' +
+ actionTitle +
+ '</span>' +
+ '</label>');
+
+ var radioInput = action.children("input");
+ if (Number(filterAction.count) == 0) {
+ radioInput.attr("disabled", "disabled");
+ }
+
+ radioInput.val(filterData.name + ':' + filterAction.action_name);
+
+ /* Setup the current selected filter, default to 'all' if
+ * no current filter selected.
+ */
+ if ((tableParams.filter &&
+ tableParams.filter === radioInput.val()) ||
+ filterAction.action_name == 'all') {
+ radioInput.attr("checked", "checked");
+ }
}
- filterActionRadios.append(action);
+ if (action) {
+ filterActionRadios.append(action);
+ }
}
$('#filter-modal-'+ctx.tableName).modal('show');