Merge branch 'bugfix/selected-row-lost-after-autorefresh-8623'

fixes #8623
This commit is contained in:
Matthias Jentsch 2015-07-28 15:30:32 +02:00
commit 40d31d02bd
3 changed files with 30 additions and 29 deletions

View File

@ -43,7 +43,7 @@
* Handle the selection of an action table * Handle the selection of an action table
* *
* @param table {HTMLElement} The table * @param table {HTMLElement} The table
* @param {Icinga} * @param icinga {Icinga}
* *
* @constructor * @constructor
*/ */
@ -158,7 +158,6 @@
return; return;
} }
var self = this; var self = this;
var url = this.getMultiselectionUrl();
this.rowActions() this.rowActions()
.filter( .filter(
function (i, el) { function (i, el) {
@ -284,13 +283,6 @@
var ActionTable = function (icinga) { var ActionTable = function (icinga) {
Icinga.EventListener.call(this, icinga); Icinga.EventListener.call(this, icinga);
/**
* The hash that is currently being loaded
*
* @var String
*/
this.loadingHash = null;
/** /**
* If currently loading * If currently loading
* *
@ -364,7 +356,7 @@
} }
self.icinga.history.pushUrl(state); self.icinga.history.pushUrl(state);
// re draw all table selections // redraw all table selections
self.tables().each(function () { self.tables().each(function () {
new Selection(this, self.icinga).refresh(); new Selection(this, self.icinga).refresh();
}); });
@ -375,22 +367,43 @@
}; };
/** /**
* Ensure that * Render the selection and prepare selection rows
*/ */
ActionTable.prototype.onRendered = function(evt) { ActionTable.prototype.onRendered = function(evt) {
var container = evt.target; var container = evt.target;
var self = evt.data.self; var self = evt.data.self;
// draw all selections // initialize all rows with the correct link, to assure that
$('table.action tr', container).each(function(idx, el) {
var $a = $('a[href].rowaction', el).first();
if ($a.length) {
// TODO: Find out whether we leak memory on IE with this:
$(el).attr('href', $a.attr('href'));
return;
}
$a = $('a[href]', el).first();
if ($a.length) {
$(el).attr('href', $a.attr('href'));
}
});
// draw all active selections that have disappeared on reload
self.tables().each(function(i, el) { self.tables().each(function(i, el) {
new Selection(el, self.icinga).refresh(); new Selection(el, self.icinga).refresh();
}); });
// update displayed selection count // update displayed selection counter
var table = new Selection(self.tables(container).first()); var table = new Selection(self.tables(container).first());
$(container).find('.selection-info-count').text(table.selections().size()); $(container).find('.selection-info-count').text(table.selections().size());
}; };
ActionTable.prototype.clearAll = function () {
var self = this;
this.tables().each(function () {
new Selection(this, self.icinga).clear();
});
};
Icinga.Behaviors.ActionTable = ActionTable; Icinga.Behaviors.ActionTable = ActionTable;
}) (Icinga, jQuery); }) (Icinga, jQuery);

View File

@ -40,20 +40,6 @@
icinga.loader.loadUrl(url, $(el)).autorefresh = true; icinga.loader.loadUrl(url, $(el)).autorefresh = true;
}); });
// Set first links href in a action table tr as row href:
$('table.action tr', el).each(function(idx, el) {
var $a = $('a[href].rowaction', el).first();
if ($a.length) {
// TODO: Find out whether we leak memory on IE with this:
$(el).attr('href', $a.attr('href'));
return;
}
$a = $('a[href]', el).first();
if ($a.length) {
$(el).attr('href', $a.attr('href'));
}
});
$('td.state span.timesince').attr('title', null); $('td.state span.timesince').attr('title', null);
var moduleName = el.data('icingaModule'); var moduleName = el.data('icingaModule');
@ -441,7 +427,6 @@
} else { } else {
icinga.ui.layout1col(); icinga.ui.layout1col();
} }
$('table tr[href].active').removeClass('active');
icinga.history.pushCurrentState(); icinga.history.pushCurrentState();
} }
} }

View File

@ -241,6 +241,9 @@
$('#layout').removeClass('twocols'); $('#layout').removeClass('twocols');
this.closeContainer($('#col2')); this.closeContainer($('#col2'));
this.disableCloseButtons(); this.disableCloseButtons();
// one-column layouts never have any selection active
this.icinga.behaviors.actiontable.clearAll();
}, },
closeContainer: function($c) { closeContainer: function($c) {