js: Handle collapsed state of multiple trees

fixes #8569
This commit is contained in:
Thomas Gelf 2016-11-24 09:39:44 +01:00
parent b8df6a8823
commit 2fc48f2124
3 changed files with 17 additions and 10 deletions

View file

@ -57,7 +57,7 @@ use Icinga\Module\Businessprocess\BusinessProcess;
<?php endif ?>
</ul>
<?php endif ?>
<div class="bp">
<div id="<?= $this->bp->getHtmlId() ?>" class="bp">
<?= $this->bp->renderHtml($this) ?>
<?php if (! $this->bpconfig->isLocked()): ?>
<?php if ($this->bp instanceof BusinessProcess): /* do not render when showing subtree */ ?>

View file

@ -171,6 +171,11 @@ class BusinessProcess
return $this->name;
}
public function getHtmlId()
{
return 'businessprocess-' . preg_replace('/[\r\n\t\s]/', '_', $this->getName());
}
public function setTitle($title)
{
$this->title = $title;

View file

@ -134,20 +134,20 @@
},
fixOpenedBps: function(event) {
var $container = $(event.currentTarget);
var container_id = $container.attr('id');
var $bpDiv = $(event.currentTarget).find('div.bp');
var bpName = $bpDiv.attr('id');
if (typeof this.idCache[container_id] === 'undefined') {
if (typeof this.idCache[bpName] === 'undefined') {
return;
}
var $procs = $('table.process', $container);
$.each(this.idCache[$container.attr('id')], function(idx, id) {
var $procs = $bpDiv.find('table.process');
$.each(this.idCache[bpName], function(idx, id) {
var $el = $('#' + id);
$procs = $procs.not($el);
$el.parents('table.process').each(function (idx, el) {
$procs = $procs.not($(el));
});
});
@ -160,9 +160,11 @@
* Only get the deepest nodes to keep requests as small as possible
*/
rememberOpenedBps: function (event) {
var $container = $(event.currentTarget);
var ids = [];
$('table.process', $container)
var $bpDiv = $(event.currentTarget).find('div.bp');
var $bpName = $bpDiv.attr('id');
$bpDiv.find('table.process')
.not('table.process.collapsed')
.not('table.process.collapsed table.process')
.each(function (key, el) {
@ -172,7 +174,7 @@
return;
}
this.idCache[$container.attr('id')] = ids;
this.idCache[$bpName] = ids;
}
};