Skip to content

Commit

Permalink
Merge branch 'bugfix/selected-row-lost-after-autorefresh-8623'
Browse files Browse the repository at this point in the history
fixes #8623
  • Loading branch information
majentsch committed Jul 29, 2015
2 parents ba906d2 + 3e7cc29 commit 20aa17c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 24 deletions.
12 changes: 8 additions & 4 deletions application/controllers/ConfigController.php
Expand Up @@ -32,12 +32,14 @@ public function createApplicationTabs()
$tabs->add('general', array(
'title' => $this->translate('Adjust the general configuration of Icinga Web 2'),
'label' => $this->translate('General'),
'url' => 'config/general'
'url' => 'config/general',
'baseTarget' => '_main'
));
$tabs->add('resource', array(
'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'),
'label' => $this->translate('Resources'),
'url' => 'config/resource'
'url' => 'config/resource',
'baseTarget' => '_main'
));
return $tabs;
}
Expand All @@ -51,12 +53,14 @@ public function createAuthenticationTabs()
$tabs->add('userbackend', array(
'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'),
'label' => $this->translate('User Backends'),
'url' => 'config/userbackend'
'url' => 'config/userbackend',
'baseTarget' => '_main'
));
$tabs->add('usergroupbackend', array(
'title' => $this->translate('Configure how users are associated with groups by Icinga Web 2'),
'label' => $this->translate('User Group Backends'),
'url' => 'usergroupbackend/list'
'url' => 'usergroupbackend/list',
'baseTarget' => '_main'
));
return $tabs;
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/RoleController.php
Expand Up @@ -166,7 +166,8 @@ protected function createListTabs()
'Configure roles to permit or restrict users and groups accessing Icinga Web 2'
),
'label' => $this->translate('Roles'),
'url' => 'role/list'
'url' => 'role/list',
'baseTarget' => '_main'
)
);

Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/config/resource.phtml
@@ -1,4 +1,4 @@
<div class="controls" data-base-target="_main">
<div class="controls">
<?= $tabs; ?>
</div>
<div class="content" data-base-target="_next">
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/config/userbackend/reorder.phtml
@@ -1,4 +1,4 @@
<div class="controls" data-base-target="_main">
<div class="controls">
<?= $tabs; ?>
</div>
<div class="content" data-base-target="_next">
Expand Down
3 changes: 2 additions & 1 deletion application/views/scripts/form/reorder-authbackend.phtml
Expand Up @@ -16,7 +16,8 @@
array('backend' => $backendNames[$i]),
array(
'icon' => 'edit',
'title' => sprintf($this->translate('Edit user backend %s'), $backendNames[$i])
'class' => 'rowaction',
'title' => sprintf($this->translate('rEdit user backend %s'), $backendNames[$i])
)
); ?>
</td>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/role/list.phtml
@@ -1,4 +1,4 @@
<div class="controls" data-base-target="_main">
<div class="controls">
<?= $tabs ?>
</div>
<div class="content">
Expand Down
16 changes: 16 additions & 0 deletions library/Icinga/Web/Widget/Tab.php
Expand Up @@ -91,6 +91,13 @@ class Tab extends AbstractWidget
*/
private $targetBlank = false;

/**
* Data base target that determines if the link will be opened in a side-bar or in the main container
*
* @var null
*/
private $baseTarget = null;

/**
* Sets an icon image for this tab
*
Expand Down Expand Up @@ -210,6 +217,11 @@ public function setTargetBlank($value = true)
$this->targetBlank = $value;
}

public function setBaseTarget($value)
{
$this->baseTarget = $value;
}

/**
* Create a new Tab with the given properties
*
Expand Down Expand Up @@ -274,6 +286,10 @@ public function render()
}
}

if ($this->baseTarget !== null) {
$tagParams['data-base-target'] = $this->baseTarget;
}

if ($this->icon !== null) {
if (strpos($this->icon, '.') === false) {
$caption = $view->icon($this->icon) . $caption;
Expand Down
Expand Up @@ -15,7 +15,7 @@ if (count($servicegroups) === 0) {
return;
}
?>
<table class="groupview" data-base-target="_next">
<table class="groupview action" data-base-target="_next">
<thead>
<th><?= $this->translate('Last Problem'); ?></th>
<th><?= $this->translate('Service Group'); ?></th>
Expand Down
9 changes: 6 additions & 3 deletions public/js/icinga/behavior/actiontable.js
Expand Up @@ -313,13 +313,16 @@
*/
ActionTable.prototype.onRowClicked = function (event) {
var self = event.data.self;
var $tr = $(event.target).closest('tr');
var $target = $(event.target);
var $tr = $target.closest('tr');
var table = new Selection($tr.closest('table.action')[0], self.icinga);

// allow form actions in table rows to pass through
if ($(event.target).closest('form').length) {
// some rows may contain form actions that trigger a different action, pass those through
if (!$target.hasClass('rowaction') && $target.closest('form').length &&
($target.closest('a').length || $target.closest('button').length)) {
return;
}

event.stopPropagation();
event.preventDefault();

Expand Down
10 changes: 4 additions & 6 deletions public/js/icinga/events.js
Expand Up @@ -354,18 +354,16 @@
return true;
}

// Special checks for link clicks in multiselect rows
if (! $a.is('tr[href]') && $a.closest('tr[href]').length > 0 && $a.closest('table.multiselect').length > 0) {
// Special checks for link clicks in action tables
if (! $a.is('tr[href]') && $a.closest('table.action').length > 0) {

// ignoray clicks to ANY link with special key pressed
if (event.ctrlKey || event.metaKey || event.shiftKey)
{
if ($a.closest('table.multiselect').length > 0 && (event.ctrlKey || event.metaKey || event.shiftKey)) {
return true;
}

// ignore inner links matching the row URL
if ($a.attr('href') === $a.closest('tr[href]').attr('href'))
{
if ($a.attr('href') === $a.closest('tr[href]').attr('href')) {
return true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion public/js/icinga/history.js
Expand Up @@ -139,8 +139,10 @@
icinga.logger.debug('History state', event.originalEvent.state);
}

self.applyLocationBar();
// keep the last pushed url in sync with history changes
self.lastPushUrl = location.href;

self.applyLocationBar();
},

applyLocationBar: function (onload) {
Expand Down
4 changes: 0 additions & 4 deletions public/js/icinga/loader.js
Expand Up @@ -587,8 +587,6 @@
if (req.$target[0].id === 'col1') {
self.icinga.behaviors.navigation.resetActive();
}
} else if ($(el).closest('table.action').length) {
$(el).closest('table.action').find('.active').removeClass('active');
}
});

Expand All @@ -604,8 +602,6 @@
}
// Interrupt .each, only on menu item shall be active
return false;
} else if ($(el).closest('table.action').length) {
$el.addClass('active');
}
});
}
Expand Down

0 comments on commit 20aa17c

Please sign in to comment.