actiontable: gracefully clear and improve...
...state preservation refs #13115
This commit is contained in:
parent
e75bfbc197
commit
0f58776b4e
|
@ -255,15 +255,36 @@
|
||||||
* @param url {String} The target url
|
* @param url {String} The target url
|
||||||
*/
|
*/
|
||||||
selectUrl: function(url) {
|
selectUrl: function(url) {
|
||||||
|
var formerHref = this.$el.closest('.container').data('icinga-actiontable-former-href')
|
||||||
|
|
||||||
var $row = this.rows().filter('[href="' + url + '"]');
|
var $row = this.rows().filter('[href="' + url + '"]');
|
||||||
|
|
||||||
if ($row.length) {
|
if ($row.length) {
|
||||||
|
this.clear();
|
||||||
$row.addClass('active');
|
$row.addClass('active');
|
||||||
} else {
|
} else {
|
||||||
|
if (this.col !== 'col2') {
|
||||||
// rows sometimes need to be displayed as active when related actions
|
// rows sometimes need to be displayed as active when related actions
|
||||||
// like command actions are being opened. Do not do this for col2, as it
|
// like command actions are being opened. Do not do this for col2, as it
|
||||||
// would always select the opened URL itself.
|
// would always select the opened URL itself.
|
||||||
if (this.col !== 'col2') {
|
var $row = this.rows().filter('[href$="' + icinga.utils.parseUrl(url).query + '"]');
|
||||||
this.rows().filter('[href$="' + icinga.utils.parseUrl(url).query + '"]').addClass('active');
|
if ($row.length) {
|
||||||
|
this.clear();
|
||||||
|
$row.addClass('active');
|
||||||
|
} else {
|
||||||
|
var $row = this.rows().filter('[href$="' + formerHref + '"]');
|
||||||
|
if ($row.length) {
|
||||||
|
this.clear();
|
||||||
|
$row.addClass('active');
|
||||||
|
} else {
|
||||||
|
var tbl = this.$el;
|
||||||
|
if (ActionTable.prototype.tables(
|
||||||
|
tbl.closest('.dashboard').find('.container')).not(tbl).find('tr.active').length
|
||||||
|
) {
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -298,11 +319,11 @@
|
||||||
* Refresh the displayed active columns using the current page location
|
* Refresh the displayed active columns using the current page location
|
||||||
*/
|
*/
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
this.clear();
|
|
||||||
var hash = icinga.history.getCol2State().replace(/^#!/, '');
|
var hash = icinga.history.getCol2State().replace(/^#!/, '');
|
||||||
if (this.hasMultiselection()) {
|
if (this.hasMultiselection()) {
|
||||||
var query = parseSelectionQuery(hash);
|
var query = parseSelectionQuery(hash);
|
||||||
if (query.length > 1 && this.hasMultiselectionUrl(this.icinga.utils.parseUrl(hash).path)) {
|
if (query.length > 1 && this.hasMultiselectionUrl(this.icinga.utils.parseUrl(hash).path)) {
|
||||||
|
this.clear();
|
||||||
// select all rows with matching filters
|
// select all rows with matching filters
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$.each(query, function(i, selection) {
|
$.each(query, function(i, selection) {
|
||||||
|
@ -330,6 +351,7 @@
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
this.on('rendered', this.onRendered, this);
|
this.on('rendered', this.onRendered, this);
|
||||||
|
this.on('beforerender', this.beforeRender, this);
|
||||||
this.on('click', 'table.action tr[href], table.table-row-selectable tr[href]', this.onRowClicked, this);
|
this.on('click', 'table.action tr[href], table.table-row-selectable tr[href]', this.onRowClicked, this);
|
||||||
};
|
};
|
||||||
ActionTable.prototype = new Icinga.EventListener();
|
ActionTable.prototype = new Icinga.EventListener();
|
||||||
|
@ -451,6 +473,16 @@
|
||||||
$(container).find('.selection-info-count').text(table.selections().size());
|
$(container).find('.selection-info-count').text(table.selections().size());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ActionTable.prototype.beforeRender = function(evt) {
|
||||||
|
var container = evt.target;
|
||||||
|
var _this = evt.data.self;
|
||||||
|
|
||||||
|
var active = _this.tables().find('tr.active');
|
||||||
|
if (active.length) {
|
||||||
|
$(container).data('icinga-actiontable-former-href', active.attr('href'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ActionTable.prototype.clearAll = function () {
|
ActionTable.prototype.clearAll = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.tables().each(function () {
|
this.tables().each(function () {
|
||||||
|
|
|
@ -273,6 +273,7 @@
|
||||||
$('#layout').removeClass('twocols');
|
$('#layout').removeClass('twocols');
|
||||||
this.closeContainer($('#col2'));
|
this.closeContainer($('#col2'));
|
||||||
// one-column layouts never have any selection active
|
// one-column layouts never have any selection active
|
||||||
|
$('#col1').removeData('icinga-actiontable-former-href');
|
||||||
this.icinga.behaviors.actiontable.clearAll();
|
this.icinga.behaviors.actiontable.clearAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue