Add selection count hint in grids with help for hosts and services

refs #7654
This commit is contained in:
Alexander Fuhr 2014-11-13 12:50:39 +01:00
parent f427577067
commit 46df428e28
6 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?php
$helpMessage = $this->translate('Press and hold the Ctrl key while clicking on rows to select multiple rows or press and hold the Shift key to select a range of rows.', 'multiselection');
?>
<div class="selection-info">
<span class="selection-info-count">0</span> <?= $this->translate('row(s) selected', 'multiselection') ?> <?= $this->icon('unhandled.png', $helpMessage) ?>
</div>

View File

@ -16,6 +16,7 @@ if ($this->compact): ?>
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())) ?>
<?= $this->render('list/components/selectioninfo.phtml') ?>
</div>
<div class="content">

View File

@ -20,6 +20,7 @@ if (!$this->compact): ?>
<?= $this->paginationControl($services, null, null, array('preserve' => $this->preserve)) ?>
<?php endif ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/services/show?' . $this->filter->toQueryString())) ?>
<?= $this->render('list/components/selectioninfo.phtml') ?>
</div>
<div class="content">

View File

@ -141,3 +141,7 @@ table.avp .customvar ul {
padding: 0;
padding-left: 1.5em;
}
div.selection-info {
padding-top:1em;
}

View File

@ -306,17 +306,20 @@
var query = icinga.ui.selectionDataToQuery(selectionData);
icinga.loader.loadUrl(url + '?' + query, $target);
icinga.ui.storeSelectionData(selectionData);
icinga.ui.provideSelectionCount();
} else if ($trs.length === 1) {
// display a single row
$tr = $trs.first();
icinga.loader.loadUrl($tr.attr('href'), $target);
icinga.ui.storeSelectionData($tr.attr('href'));
icinga.ui.provideSelectionCount();
} else {
// display nothing
if ($target.attr('id') === 'col2') {
icinga.ui.layout1col();
}
icinga.ui.storeSelectionData(null);
icinga.ui.provideSelectionCount();
}
return false;

View File

@ -470,9 +470,25 @@
* (when only a single row was selected) or Null when nothing was selected.
*/
loadSelectionData: function() {
this.provideSelectionCount();
return selectionData;
},
/**
* Set the selections row count hint info
*/
provideSelectionCount: function() {
var $count = $('.selection-info-count');
if (typeof selectionData === 'string') {
$count.text(1);
} else if (selectionData.length > 1) {
$count.text(selectionData.length);
} else {
$count.text(0);
}
},
/**
* Focus the given table by deselecting all selections on all other tables.
*