mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-06-09 00:32:05 -04:00
ContinueWith: Disable button if the query with filter returns no results (#1300)
fixes #1299 requires https://github.com/Icinga/ipl-web/pull/334
This commit is contained in:
parent
f70f60bf66
commit
9cabfd5968
8 changed files with 37 additions and 15 deletions
|
|
@ -83,10 +83,11 @@ class CommentsController extends Controller
|
||||||
$this->addControl($limitControl);
|
$this->addControl($limitControl);
|
||||||
$this->addControl($viewModeSwitcher);
|
$this->addControl($viewModeSwitcher);
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar);
|
|
||||||
|
|
||||||
$results = $comments->execute();
|
$results = $comments->execute();
|
||||||
|
|
||||||
|
$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar, $results->hasResult());
|
||||||
|
|
||||||
$this->addContent(
|
$this->addContent(
|
||||||
(new ObjectList($results))
|
(new ObjectList($results))
|
||||||
->setViewMode($viewModeSwitcher->getViewMode())
|
->setViewMode($viewModeSwitcher->getViewMode())
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,11 @@ class DowntimesController extends Controller
|
||||||
$this->addControl($limitControl);
|
$this->addControl($limitControl);
|
||||||
$this->addControl($viewModeSwitcher);
|
$this->addControl($viewModeSwitcher);
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar);
|
|
||||||
|
|
||||||
$results = $downtimes->execute();
|
$results = $downtimes->execute();
|
||||||
|
|
||||||
|
$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar, $results->hasResult());
|
||||||
|
|
||||||
$this->addContent(
|
$this->addContent(
|
||||||
(new ObjectList($results))
|
(new ObjectList($results))
|
||||||
->setViewMode($viewModeSwitcher->getViewMode())
|
->setViewMode($viewModeSwitcher->getViewMode())
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,9 @@ class HostController extends Controller
|
||||||
|
|
||||||
yield $this->export($services);
|
yield $this->export($services);
|
||||||
|
|
||||||
$serviceList = (new ObjectList($services))
|
$results = $services->execute();
|
||||||
|
|
||||||
|
$serviceList = (new ObjectList($results))
|
||||||
->setViewMode($viewModeSwitcher->getViewMode())
|
->setViewMode($viewModeSwitcher->getViewMode())
|
||||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||||
|
|
||||||
|
|
@ -297,7 +299,8 @@ class HostController extends Controller
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(
|
$continueWith = $this->createContinueWith(
|
||||||
Links::servicesDetails()->setFilter(Filter::equal('host.name', $this->host->name)),
|
Links::servicesDetails()->setFilter(Filter::equal('host.name', $this->host->name)),
|
||||||
$searchBar
|
$searchBar,
|
||||||
|
$results->hasResult()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addContent($serviceList);
|
$this->addContent($serviceList);
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,9 @@ class HostgroupController extends Controller
|
||||||
|
|
||||||
yield $this->export($hosts);
|
yield $this->export($hosts);
|
||||||
|
|
||||||
$hostList = (new ObjectList($hosts))
|
$results = $hosts->execute();
|
||||||
|
|
||||||
|
$hostList = (new ObjectList($results))
|
||||||
->setViewMode($viewModeSwitcher->getViewMode())
|
->setViewMode($viewModeSwitcher->getViewMode())
|
||||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||||
|
|
||||||
|
|
@ -122,7 +124,8 @@ class HostgroupController extends Controller
|
||||||
$continueWith = $this->createContinueWith(
|
$continueWith = $this->createContinueWith(
|
||||||
Links::hostsDetails()
|
Links::hostsDetails()
|
||||||
->setFilter(Filter::equal('hostgroup.name', $hostgroup->name)),
|
->setFilter(Filter::equal('hostgroup.name', $hostgroup->name)),
|
||||||
$searchBar
|
$searchBar,
|
||||||
|
$results->hasResult()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addContent($hostList);
|
$this->addContent($hostList);
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,10 @@ class HostsController extends Controller
|
||||||
$this->addControl($limitControl);
|
$this->addControl($limitControl);
|
||||||
$this->addControl($viewModeSwitcher);
|
$this->addControl($viewModeSwitcher);
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar);
|
|
||||||
|
|
||||||
$results = $hosts->execute();
|
$results = $hosts->execute();
|
||||||
|
|
||||||
|
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar, $results->hasResult());
|
||||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||||
$hostList = (new HostItemTable($results, HostItemTable::applyColumnMetaData($hosts, $columns)))
|
$hostList = (new HostItemTable($results, HostItemTable::applyColumnMetaData($hosts, $columns)))
|
||||||
->setSort($sortControl->getSort());
|
->setSort($sortControl->getSort());
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,9 @@ class ServicegroupController extends Controller
|
||||||
|
|
||||||
yield $this->export($services);
|
yield $this->export($services);
|
||||||
|
|
||||||
$serviceList = (new ObjectList($services))
|
$results = $services->execute();
|
||||||
|
|
||||||
|
$serviceList = (new ObjectList($results))
|
||||||
->setViewMode($viewModeSwitcher->getViewMode())
|
->setViewMode($viewModeSwitcher->getViewMode())
|
||||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||||
|
|
||||||
|
|
@ -129,7 +131,8 @@ class ServicegroupController extends Controller
|
||||||
$continueWith = $this->createContinueWith(
|
$continueWith = $this->createContinueWith(
|
||||||
Links::servicesDetails()
|
Links::servicesDetails()
|
||||||
->setFilter(Filter::equal('servicegroup.name', $servicegroup->name)),
|
->setFilter(Filter::equal('servicegroup.name', $servicegroup->name)),
|
||||||
$searchBar
|
$searchBar,
|
||||||
|
$results->hasResult()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addContent($serviceList);
|
$this->addContent($serviceList);
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,11 @@ class ServicesController extends Controller
|
||||||
$this->addControl($limitControl);
|
$this->addControl($limitControl);
|
||||||
$this->addControl($viewModeSwitcher);
|
$this->addControl($viewModeSwitcher);
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);
|
|
||||||
|
|
||||||
$results = $services->execute();
|
$results = $services->execute();
|
||||||
|
|
||||||
|
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar, $results->hasResult());
|
||||||
|
|
||||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||||
$serviceList = (new ServiceItemTable($results, ServiceItemTable::applyColumnMetaData($services, $columns)))
|
$serviceList = (new ServiceItemTable($results, ServiceItemTable::applyColumnMetaData($services, $columns)))
|
||||||
->setSort($sortControl->getSort());
|
->setSort($sortControl->getSort());
|
||||||
|
|
@ -279,7 +280,6 @@ class ServicesController extends Controller
|
||||||
$this->addControl($problemToggle);
|
$this->addControl($problemToggle);
|
||||||
$this->addControl($sortControl);
|
$this->addControl($sortControl);
|
||||||
$this->addControl($searchBar);
|
$this->addControl($searchBar);
|
||||||
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);
|
|
||||||
|
|
||||||
$pivotFilter = $problemToggle->isChecked() ?
|
$pivotFilter = $problemToggle->isChecked() ?
|
||||||
Filter::equal('service.state.is_problem', 'y') : null;
|
Filter::equal('service.state.is_problem', 'y') : null;
|
||||||
|
|
@ -316,6 +316,7 @@ class ServicesController extends Controller
|
||||||
$this->view->pivotData = $pivotData;
|
$this->view->pivotData = $pivotData;
|
||||||
$this->view->pivotHeader = $pivotHeader;
|
$this->view->pivotHeader = $pivotHeader;
|
||||||
|
|
||||||
|
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar, ! empty($pivotData));
|
||||||
/** Preserve filter and params in view links (the `BaseFilter` implementation for view scripts -.-) */
|
/** Preserve filter and params in view links (the `BaseFilter` implementation for view scripts -.-) */
|
||||||
$this->view->baseUrl = Url::fromRequest()
|
$this->view->baseUrl = Url::fromRequest()
|
||||||
->onlyWith([
|
->onlyWith([
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,24 @@ trait SearchControls
|
||||||
*
|
*
|
||||||
* @param Url $detailsUrl
|
* @param Url $detailsUrl
|
||||||
* @param SearchBar $searchBar
|
* @param SearchBar $searchBar
|
||||||
|
* @param bool $hasResults Whether the current query has results
|
||||||
*
|
*
|
||||||
* @return ContinueWith
|
* @return ContinueWith
|
||||||
*/
|
*/
|
||||||
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar): ContinueWith
|
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar, bool $hasResults = true): ContinueWith
|
||||||
{
|
{
|
||||||
$continueWith = new ContinueWith($detailsUrl, [$searchBar, 'getFilter']);
|
if ($hasResults) {
|
||||||
$continueWith->setTitle(t('Show bulk processing actions for all filtered results'));
|
$continueWith = ContinueWith::create(
|
||||||
$continueWith->setBaseTarget('_next');
|
$detailsUrl,
|
||||||
|
[$searchBar, 'getFilter'],
|
||||||
|
t('Show bulk processing actions for all filtered results'),
|
||||||
|
t('A filter is required to show bulk processing actions'),
|
||||||
|
);
|
||||||
|
$continueWith->setBaseTarget('_next');
|
||||||
|
} else {
|
||||||
|
$continueWith = ContinueWith::createDisabled(t('No items found'));
|
||||||
|
}
|
||||||
|
|
||||||
$continueWith->getAttributes()
|
$continueWith->getAttributes()
|
||||||
->set('id', $this->getRequest()->protectId('continue-with'));
|
->set('id', $this->getRequest()->protectId('continue-with'));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue