Skip to content

Commit c55a469

Browse files
RedundancygroupController: Add separated (searchEditor/complete)Action for members & children tab
1 parent b52c219 commit c55a469

File tree

1 file changed

+50
-25
lines changed

1 file changed

+50
-25
lines changed

application/controllers/RedundancygroupController.php

+50-25
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,22 @@ public function childrenAction(): Generator
174174
);
175175
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl);
176176

177-
$searchBar = $this->createSearchBar(
178-
$nodesQuery,
179-
[
180-
$limitControl->getLimitParam(),
181-
$sortControl->getSortParam(),
182-
$viewModeSwitcher->getViewModeParam(),
183-
'id'
184-
]
185-
);
186-
187-
$searchBar->getSuggestionUrl()->setParam('isChildrenTab');
188-
$searchBar->getEditorUrl()
189-
->setParams((clone $searchBar->getEditorUrl()->getParams())->set('isChildrenTab', true));
177+
$preserveParams = [
178+
$limitControl->getLimitParam(),
179+
$sortControl->getSortParam(),
180+
$viewModeSwitcher->getViewModeParam(),
181+
'id'
182+
];
183+
184+
$requestParams = Url::fromRequest()->onlyWith($preserveParams)->getParams();
185+
$searchBar = $this->createSearchBar($nodesQuery, $preserveParams)
186+
->setEditorUrl(
187+
Url::fromPath('icingadb/redundancygroup/children-search-editor')
188+
->setParams($requestParams)
189+
)->setSuggestionUrl(
190+
Url::fromPath('icingadb/redundancygroup/children-complete')
191+
->setParams(clone $requestParams)
192+
);
190193

191194
if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
192195
if ($searchBar->hasBeenSubmitted()) {
@@ -224,27 +227,29 @@ public function childrenAction(): Generator
224227

225228
public function completeAction(): void
226229
{
227-
$isChildrenTab = $this->params->shift('isChildrenTab');
228-
$column = $isChildrenTab ? 'parent' : 'child';
230+
$suggestions = (new ObjectSuggestions())
231+
->setModel(DependencyNode::class)
232+
->setBaseFilter(Filter::equal("child.redundancy_group.id", $this->groupId))
233+
->forRequest($this->getServerRequest());
229234

235+
$this->getDocument()->add($suggestions);
236+
}
237+
238+
public function childrenCompleteAction(): void
239+
{
230240
$suggestions = (new ObjectSuggestions())
231241
->setModel(DependencyNode::class)
232-
->setBaseFilter(Filter::equal("$column.redundancy_group.id", $this->groupId))
242+
->setBaseFilter(Filter::equal("parent.redundancy_group.id", $this->groupId))
233243
->forRequest($this->getServerRequest());
234244

235245
$this->getDocument()->add($suggestions);
236246
}
237247

238248
public function searchEditorAction(): void
239249
{
240-
$isChildrenTab = $this->params->shift('isChildrenTab');
241-
$redirectUrl = $isChildrenTab
242-
? Url::fromPath('icingadb/redundancygroup/children', ['id' => $this->groupId])
243-
: Url::fromPath('icingadb/redundancygroup/members', ['id' => $this->groupId]);
244-
245250
$editor = $this->createSearchEditor(
246251
DependencyNode::on($this->getDb()),
247-
$redirectUrl,
252+
Url::fromPath('icingadb/redundancygroup/members', ['id' => $this->groupId]),
248253
[
249254
LimitControl::DEFAULT_LIMIT_PARAM,
250255
SortControl::DEFAULT_SORT_PARAM,
@@ -253,9 +258,29 @@ public function searchEditorAction(): void
253258
]
254259
);
255260

256-
if ($isChildrenTab) {
257-
$editor->getSuggestionUrl()->setParam('isChildrenTab');
258-
}
261+
$this->getDocument()->add($editor);
262+
$this->setTitle($this->translate('Adjust Filter'));
263+
}
264+
265+
public function childrenSearchEditorAction(): void
266+
{
267+
$preserveParams = [
268+
LimitControl::DEFAULT_LIMIT_PARAM,
269+
SortControl::DEFAULT_SORT_PARAM,
270+
ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM,
271+
'id'
272+
];
273+
274+
$editor = $this->createSearchEditor(
275+
DependencyNode::on($this->getDb()),
276+
Url::fromPath('icingadb/redundancygroup/children', ['id' => $this->groupId]),
277+
$preserveParams
278+
);
279+
280+
$editor->setSuggestionUrl(
281+
Url::fromPath('icingadb/redundancygroup/children-complete')
282+
->setParams(Url::fromRequest()->onlyWith($preserveParams)->getParams())
283+
);
259284

260285
$this->getDocument()->add($editor);
261286
$this->setTitle($this->translate('Adjust Filter'));

0 commit comments

Comments
 (0)