mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -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
(cherry picked from commit 9cabfd5968)
This commit is contained in:
parent
2963fd60b8
commit
92a28df146
8 changed files with 37 additions and 15 deletions
|
|
@ -83,10 +83,11 @@ class CommentsController extends Controller
|
|||
$this->addControl($limitControl);
|
||||
$this->addControl($viewModeSwitcher);
|
||||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar);
|
||||
|
||||
$results = $comments->execute();
|
||||
|
||||
$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar, $results->hasResult());
|
||||
|
||||
$this->addContent(
|
||||
(new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode())
|
||||
|
|
|
|||
|
|
@ -89,10 +89,11 @@ class DowntimesController extends Controller
|
|||
$this->addControl($limitControl);
|
||||
$this->addControl($viewModeSwitcher);
|
||||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar);
|
||||
|
||||
$results = $downtimes->execute();
|
||||
|
||||
$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar, $results->hasResult());
|
||||
|
||||
$this->addContent(
|
||||
(new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode())
|
||||
|
|
|
|||
|
|
@ -286,7 +286,9 @@ class HostController extends Controller
|
|||
|
||||
yield $this->export($services);
|
||||
|
||||
$serviceList = (new ObjectList($services))
|
||||
$results = $services->execute();
|
||||
|
||||
$serviceList = (new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode())
|
||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||
|
||||
|
|
@ -297,7 +299,8 @@ class HostController extends Controller
|
|||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(
|
||||
Links::servicesDetails()->setFilter(Filter::equal('host.name', $this->host->name)),
|
||||
$searchBar
|
||||
$searchBar,
|
||||
$results->hasResult()
|
||||
);
|
||||
|
||||
$this->addContent($serviceList);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,9 @@ class HostgroupController extends Controller
|
|||
|
||||
yield $this->export($hosts);
|
||||
|
||||
$hostList = (new ObjectList($hosts))
|
||||
$results = $hosts->execute();
|
||||
|
||||
$hostList = (new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode())
|
||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||
|
||||
|
|
@ -122,7 +124,8 @@ class HostgroupController extends Controller
|
|||
$continueWith = $this->createContinueWith(
|
||||
Links::hostsDetails()
|
||||
->setFilter(Filter::equal('hostgroup.name', $hostgroup->name)),
|
||||
$searchBar
|
||||
$searchBar,
|
||||
$results->hasResult()
|
||||
);
|
||||
|
||||
$this->addContent($hostList);
|
||||
|
|
|
|||
|
|
@ -97,10 +97,10 @@ class HostsController extends Controller
|
|||
$this->addControl($limitControl);
|
||||
$this->addControl($viewModeSwitcher);
|
||||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar);
|
||||
|
||||
$results = $hosts->execute();
|
||||
|
||||
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar, $results->hasResult());
|
||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||
$hostList = (new HostItemTable($results, HostItemTable::applyColumnMetaData($hosts, $columns)))
|
||||
->setSort($sortControl->getSort());
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ class ServicegroupController extends Controller
|
|||
|
||||
yield $this->export($services);
|
||||
|
||||
$serviceList = (new ObjectList($services))
|
||||
$results = $services->execute();
|
||||
|
||||
$serviceList = (new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode())
|
||||
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());
|
||||
|
||||
|
|
@ -129,7 +131,8 @@ class ServicegroupController extends Controller
|
|||
$continueWith = $this->createContinueWith(
|
||||
Links::servicesDetails()
|
||||
->setFilter(Filter::equal('servicegroup.name', $servicegroup->name)),
|
||||
$searchBar
|
||||
$searchBar,
|
||||
$results->hasResult()
|
||||
);
|
||||
|
||||
$this->addContent($serviceList);
|
||||
|
|
|
|||
|
|
@ -108,10 +108,11 @@ class ServicesController extends Controller
|
|||
$this->addControl($limitControl);
|
||||
$this->addControl($viewModeSwitcher);
|
||||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);
|
||||
|
||||
$results = $services->execute();
|
||||
|
||||
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar, $results->hasResult());
|
||||
|
||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||
$serviceList = (new ServiceItemTable($results, ServiceItemTable::applyColumnMetaData($services, $columns)))
|
||||
->setSort($sortControl->getSort());
|
||||
|
|
@ -279,7 +280,6 @@ class ServicesController extends Controller
|
|||
$this->addControl($problemToggle);
|
||||
$this->addControl($sortControl);
|
||||
$this->addControl($searchBar);
|
||||
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);
|
||||
|
||||
$pivotFilter = $problemToggle->isChecked() ?
|
||||
Filter::equal('service.state.is_problem', 'y') : null;
|
||||
|
|
@ -316,6 +316,7 @@ class ServicesController extends Controller
|
|||
$this->view->pivotData = $pivotData;
|
||||
$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 -.-) */
|
||||
$this->view->baseUrl = Url::fromRequest()
|
||||
->onlyWith([
|
||||
|
|
|
|||
|
|
@ -51,14 +51,24 @@ trait SearchControls
|
|||
*
|
||||
* @param Url $detailsUrl
|
||||
* @param SearchBar $searchBar
|
||||
* @param bool $hasResults Whether the current query has results
|
||||
*
|
||||
* @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']);
|
||||
$continueWith->setTitle(t('Show bulk processing actions for all filtered results'));
|
||||
$continueWith->setBaseTarget('_next');
|
||||
if ($hasResults) {
|
||||
$continueWith = ContinueWith::create(
|
||||
$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()
|
||||
->set('id', $this->getRequest()->protectId('continue-with'));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue