@@ -97,7 +97,7 @@ public function indexAction(): void
97
97
public function membersAction (): Generator
98
98
{
99
99
$ this ->loadGroup ();
100
- $ nodesQuery = $ this ->fetchNodes (true );
100
+ $ nodesQuery = $ this ->fetchDependencyNodes (true );
101
101
102
102
$ limitControl = $ this ->createLimitControl ();
103
103
$ paginationControl = $ this ->createPaginationControl ($ nodesQuery );
@@ -159,7 +159,7 @@ public function membersAction(): Generator
159
159
public function childrenAction (): Generator
160
160
{
161
161
$ this ->loadGroup ();
162
- $ nodesQuery = $ this ->fetchNodes ();
162
+ $ nodesQuery = $ this ->fetchDependencyNodes ();
163
163
164
164
$ limitControl = $ this ->createLimitControl ();
165
165
$ paginationControl = $ this ->createPaginationControl ($ nodesQuery );
@@ -174,19 +174,22 @@ public function childrenAction(): Generator
174
174
);
175
175
$ viewModeSwitcher = $ this ->createViewModeSwitcher ($ paginationControl , $ limitControl );
176
176
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
+ );
190
193
191
194
if ($ searchBar ->hasBeenSent () && ! $ searchBar ->isValid ()) {
192
195
if ($ searchBar ->hasBeenSubmitted ()) {
@@ -224,28 +227,31 @@ public function childrenAction(): Generator
224
227
225
228
public function completeAction (): void
226
229
{
227
- $ isChildrenTab = $ this ->params ->shift ('isChildrenTab ' );
228
- $ column = $ isChildrenTab ? 'parent ' : 'child ' ;
230
+ $ suggestions = (new ObjectSuggestions ())
231
+ ->setModel (DependencyNode::class)
232
+ ->onlyWithCustomVarSources (['host ' , 'service ' , 'hostgroup ' , 'servicegroup ' ])
233
+ ->setBaseFilter (Filter::equal ("child.redundancy_group.id " , $ this ->groupId ))
234
+ ->forRequest ($ this ->getServerRequest ());
235
+
236
+ $ this ->getDocument ()->add ($ suggestions );
237
+ }
229
238
239
+ public function childrenCompleteAction (): void
240
+ {
230
241
$ suggestions = (new ObjectSuggestions ())
231
242
->setModel (DependencyNode::class)
232
- ->setBaseFilter (Filter::equal ("$ column.redundancy_group.id " , $ this ->groupId ))
233
243
->onlyWithCustomVarSources (['host ' , 'service ' , 'hostgroup ' , 'servicegroup ' ])
244
+ ->setBaseFilter (Filter::equal ("parent.redundancy_group.id " , $ this ->groupId ))
234
245
->forRequest ($ this ->getServerRequest ());
235
246
236
247
$ this ->getDocument ()->add ($ suggestions );
237
248
}
238
249
239
250
public function searchEditorAction (): void
240
251
{
241
- $ isChildrenTab = $ this ->params ->shift ('isChildrenTab ' );
242
- $ redirectUrl = $ isChildrenTab
243
- ? Url::fromPath ('icingadb/redundancygroup/children ' , ['id ' => $ this ->groupId ])
244
- : Url::fromPath ('icingadb/redundancygroup/members ' , ['id ' => $ this ->groupId ]);
245
-
246
252
$ editor = $ this ->createSearchEditor (
247
253
DependencyNode::on ($ this ->getDb ()),
248
- $ redirectUrl ,
254
+ Url:: fromPath ( ' icingadb/redundancygroup/members ' , [ ' id ' => $ this -> groupId ]) ,
249
255
[
250
256
LimitControl::DEFAULT_LIMIT_PARAM ,
251
257
SortControl::DEFAULT_SORT_PARAM ,
@@ -254,9 +260,29 @@ public function searchEditorAction(): void
254
260
]
255
261
);
256
262
257
- if ($ isChildrenTab ) {
258
- $ editor ->getSuggestionUrl ()->setParam ('isChildrenTab ' );
259
- }
263
+ $ this ->getDocument ()->add ($ editor );
264
+ $ this ->setTitle ($ this ->translate ('Adjust Filter ' ));
265
+ }
266
+
267
+ public function childrenSearchEditorAction (): void
268
+ {
269
+ $ preserveParams = [
270
+ LimitControl::DEFAULT_LIMIT_PARAM ,
271
+ SortControl::DEFAULT_SORT_PARAM ,
272
+ ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM ,
273
+ 'id '
274
+ ];
275
+
276
+ $ editor = $ this ->createSearchEditor (
277
+ DependencyNode::on ($ this ->getDb ()),
278
+ Url::fromPath ('icingadb/redundancygroup/children ' , ['id ' => $ this ->groupId ]),
279
+ $ preserveParams
280
+ );
281
+
282
+ $ editor ->setSuggestionUrl (
283
+ Url::fromPath ('icingadb/redundancygroup/children-complete ' )
284
+ ->setParams (Url::fromRequest ()->onlyWith ($ preserveParams )->getParams ())
285
+ );
260
286
261
287
$ this ->getDocument ()->add ($ editor );
262
288
$ this ->setTitle ($ this ->translate ('Adjust Filter ' ));
@@ -291,17 +317,17 @@ protected function setTitleTab(string $name): void
291
317
}
292
318
293
319
/**
294
- * Fetch the nodes for the current group
320
+ * Fetch the dependency nodes of the current group
295
321
*
296
- * @param bool $fetchParents Whether to fetch the parents or the children
322
+ * @param bool $parents Whether to fetch the parents or the children
297
323
*
298
324
* @return Query
299
325
*/
300
- private function fetchNodes (bool $ fetchParents = false ): Query
326
+ private function fetchDependencyNodes (bool $ parents = false ): Query
301
327
{
302
328
$ filterColumn = sprintf (
303
329
'%s.redundancy_group.id ' ,
304
- $ fetchParents ? 'child ' : 'parent '
330
+ $ parents ? 'child ' : 'parent '
305
331
);
306
332
307
333
$ query = DependencyNode::on ($ this ->getDb ())
0 commit comments