Skip to content
Snippets Groups Projects
Commit 8dc9981c authored by enured's avatar enured
Browse files

B14506: For sorting and filter tablesorter library is used as first priority,...

B14506: For sorting and filter tablesorter library is used as first priority, second priority is table-view-saver if view is changed over dropdown.  refs #14506
parent b4153338
No related branches found
No related tags found
3 merge requests!504New version 22.12.1,!498B14506: Implemented new default view for tablesorter. Trigger automatic save...,!483B14506: Implemented new default view for tablesorter. Trigger automatic save...
Pipeline #8205 passed
......@@ -57,7 +57,7 @@ var QfqNS = QfqNS || {};
if (hasPager) { this._doPager(table, uniqueIdentifier); }
};
n.TablesorterController.prototype.setTableView = function (table, newView) {
n.TablesorterController.prototype.setTableView = function (table, newView, changedSelect) {
if(newView.hasOwnProperty('columnSelection') && $.tablesorter.hasWidget( table, 'columnSelector')) {
table.trigger('refreshColumnSelector', [ newView.columnSelection ]);
}
......@@ -69,8 +69,15 @@ var QfqNS = QfqNS || {};
var filtersPadded = newView.filters.concat(arrayAppend);
table.trigger( 'search', [ filtersPadded ]);
}
// Get and set last used view if its same from last time, otherwise use the one from setting API if view changed
var config = table[0].config;
if(newView.hasOwnProperty('sortList')) {
table.trigger( 'sorton', [ newView.sortList ] );
if (config.sortList.length !== 0 && !changedSelect) {
table.trigger( 'sorton', [ config.sortList ] );
} else {
table.trigger( 'sorton', [ newView.sortList ] );
}
}
};
......@@ -129,6 +136,10 @@ var QfqNS = QfqNS || {};
that._saveTableViewPrompt(table, view.name, false, false);
}
}
var lastSelect = '';
var changedSelect = false;
// create view select dropdown
var options = '';
tableViews.forEach(function (view) {
......@@ -144,7 +155,15 @@ var QfqNS = QfqNS || {};
var view = tableViews.find(function (v) {
return v.name === viewFromSelect.name && v.public === viewFromSelect.public;
});
that.setTableView(table, view.view);
// check for changed select (used dropdown)
var actualSelect = $(this).val();
if (actualSelect !== lastSelect) {
changedSelect = true;
}
lastSelect = actualSelect;
that.setTableView(table, view.view, changedSelect);
that._updateTablesorterUrlHash(table, $(this).val());
// save view choice in local storage
......@@ -169,6 +188,10 @@ var QfqNS = QfqNS || {};
setValue = value;
}
// apply view change and get last view
lastSelect = setValue;
select.val(setValue).change();
// create edit view dropdown
var viewDropdownHtml = '<div class="btn-group qfq-tablesorter-menu-item" style="right: 53px;">' +
'<button type="button" class="btn btn-default form-control qfq-view-editor dropdown-toggle" data-toggle="dropdown">' +
......@@ -206,7 +229,7 @@ var QfqNS = QfqNS || {};
});
});
$(table).trigger('update');
};
n.TablesorterController.prototype._doColumnSelector = function (table, tablesorterMenuWrapper, uniqueIdentifier) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment