From f2d253f508850c3f87ed7999d381ec2eeb7fa15e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Jul 2015 10:34:17 +0200 Subject: [PATCH 1/3] Assure that rows are refreshed correctly on reload Assure that all links are initialized when the selection is applied after a request. Move action table code into the actiontable behavior. refs #8623 --- public/js/icinga/behavior/actiontable.js | 14 ++++++++++++++ public/js/icinga/events.js | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/public/js/icinga/behavior/actiontable.js b/public/js/icinga/behavior/actiontable.js index d3df54614..6f6521314 100644 --- a/public/js/icinga/behavior/actiontable.js +++ b/public/js/icinga/behavior/actiontable.js @@ -381,6 +381,20 @@ var container = evt.target; var self = evt.data.self; + // Set first links href in a action table tr as row href: + $('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 selections self.tables().each(function(i, el) { new Selection(el, self.icinga).refresh(); diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 000ecf103..9d4e80b15 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -40,20 +40,6 @@ 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); var moduleName = el.data('icingaModule'); From 8dbd671b0dbee3feef16ae9d77633be420e3935b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Jul 2015 10:49:35 +0200 Subject: [PATCH 2/3] Conform to coding guidelines, update docstrings and cleanup unused code refs #8623 --- public/js/icinga/behavior/actiontable.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/public/js/icinga/behavior/actiontable.js b/public/js/icinga/behavior/actiontable.js index 6f6521314..71ca95051 100644 --- a/public/js/icinga/behavior/actiontable.js +++ b/public/js/icinga/behavior/actiontable.js @@ -43,7 +43,7 @@ * Handle the selection of an action table * * @param table {HTMLElement} The table - * @param {Icinga} + * @param icinga {Icinga} * * @constructor */ @@ -158,7 +158,6 @@ return; } var self = this; - var url = this.getMultiselectionUrl(); this.rowActions() .filter( function (i, el) { @@ -283,14 +282,7 @@ var ActionTable = function (icinga) { Icinga.EventListener.call(this, icinga); - - /** - * The hash that is currently being loaded - * - * @var String - */ - this.loadingHash = null; - + /** * If currently loading * @@ -364,7 +356,7 @@ } self.icinga.history.pushUrl(state); - // re draw all table selections + // redraw all table selections self.tables().each(function () { new Selection(this, self.icinga).refresh(); }); @@ -375,13 +367,13 @@ }; /** - * Ensure that + * Render the selection and prepare selection rows */ ActionTable.prototype.onRendered = function(evt) { var container = evt.target; var self = evt.data.self; - // Set first links href in a action table tr as row href: + // 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) { @@ -395,12 +387,12 @@ } }); - // draw all selections + // draw all active selections that have disappeared on reload self.tables().each(function(i, el) { new Selection(el, self.icinga).refresh(); }); - // update displayed selection count + // update displayed selection counter var table = new Selection(self.tables(container).first()); $(container).find('.selection-info-count').text(table.selections().size()); }; From cbb9ef10a26fec293df7fe89f73c114cec42eb41 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 28 Jul 2015 15:21:14 +0200 Subject: [PATCH 3/3] Remove single selections correctly when going back in the history --- public/js/icinga/behavior/actiontable.js | 7 +++++++ public/js/icinga/events.js | 1 - public/js/icinga/ui.js | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/behavior/actiontable.js b/public/js/icinga/behavior/actiontable.js index 71ca95051..b3b409491 100644 --- a/public/js/icinga/behavior/actiontable.js +++ b/public/js/icinga/behavior/actiontable.js @@ -397,6 +397,13 @@ $(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, jQuery); diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 9d4e80b15..3ea40b3d7 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -427,7 +427,6 @@ } else { icinga.ui.layout1col(); } - $('table tr[href].active').removeClass('active'); icinga.history.pushCurrentState(); } } diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index d2f9ab138..4ab802ca7 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -241,6 +241,9 @@ $('#layout').removeClass('twocols'); this.closeContainer($('#col2')); this.disableCloseButtons(); + + // one-column layouts never have any selection active + this.icinga.behaviors.actiontable.clearAll(); }, closeContainer: function($c) {