Fix multi-selection in combination with anchors

refs #9844
This commit is contained in:
Matthias Jentsch 2015-09-10 16:49:18 +02:00
parent a5351933fc
commit 8e554684af
2 changed files with 23 additions and 12 deletions

View File

@ -261,10 +261,10 @@
*/
refresh: function() {
this.clear();
var hash = this.icinga.utils.parseUrl(window.location.href).hash;
var hash = icinga.history.getCol2State().replace(/^#!/, '');
if (this.hasMultiselection()) {
var query = parseSelectionQuery(hash);
if (query.length > 1 && this.getMultiselectionUrl() === this.icinga.utils.parseUrl(hash.substr(1)).path) {
if (query.length > 1 && this.getMultiselectionUrl() === this.icinga.utils.parseUrl(hash).path) {
// select all rows with matching filters
var self = this;
$.each(query, function(i, selection) {
@ -275,7 +275,7 @@
return;
}
}
this.selectUrl(hash.substr(1));
this.selectUrl(hash);
}
};
@ -348,13 +348,12 @@
}
// update history
var url = self.icinga.utils.parseUrl(window.location.href.split('#')[0]);
var state = icinga.history.getCol1State();
var count = table.selections().length;
var state = url.path + url.query;
if (count > 0) {
var query = table.toQuery();
self.icinga.loader.loadUrl(query, self.icinga.events.getLinkTargetFor($tr));
state += '#!' + query;
state += '#!' + query;
} else {
if (self.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') {
self.icinga.ui.layout1col();

View File

@ -191,7 +191,7 @@
$('#col1').data('icingaUrl', $('#col1').data('icingaUrl') + '#' + this.getPaneAnchor(0));
}
var hash = this.getPaneFragment();
var hash = this.getCol2State();
if (hash && hash.match(/^#!/)) {
parts = hash.split(/#!/);
@ -231,15 +231,15 @@
throw 'Trying to get anchor for non-existing column: ' + col;
}
var panes = document.location.toString().split('#!')[col];
return panes && panes.split('#')[1];
return panes && panes.split('#')[1] || '';
},
/**
* Get the side-pane state fragment after (and including) the #!
* Get the side pane state after (and including) the #!
*
* @returns {String} The pane url containing the '#!'
* @returns {string} The pane url
*/
getPaneFragment: function () {
getCol2State: function () {
var hash = document.location.hash;
if (hash) {
if (hash.match(/^#[^!]/)) {
@ -249,7 +249,19 @@
hash = '#' + hashs.join('#');
}
}
return hash;
return hash || '';
},
/**
* Return the main pane state fragment
*
* @returns {string} The main url including anchors, without #!
*/
getCol1State: function () {
var anchor = this.getPaneAnchor(0);
var hash = window.location.pathname + window.location.search +
(anchor.length ? ('#' + anchor) : '');
return hash || '';
},
/**