Skip to content

Commit

Permalink
searchbar and editor fix: 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Nov 13, 2024
1 parent f17493c commit 684ce55
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions application/controllers/RedundancygroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public function membersAction(): \Generator
]
);

$searchBar->getSuggestionUrl()->setParam('id', $this->groupId);

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
Expand Down Expand Up @@ -173,10 +171,8 @@ public function childrenAction()
]
);

$searchBar->getSuggestionUrl()->setPath('icingadb/redundancygroup/children-complete');
$searchBar->getEditorUrl()->setPath('icingadb/redundancygroup/children-search-editor');

$searchBar->getSuggestionUrl()->setParam('id', $this->groupId);
$searchBar->getSuggestionUrl()->setParam('isChildrenTab');
$searchBar->getEditorUrl()->setParam('isChildrenTab');

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
Expand Down Expand Up @@ -214,27 +210,9 @@ public function childrenAction()

public function completeAction(): void
{
$this->prepareComplete();
}
$isChildrenTab = $this->params->shift('isChildrenTab');
$column = $isChildrenTab ? 'parent' : 'child';

public function childrenCompleteAction(): void
{
$this->prepareComplete(true);
}

public function searchEditorAction(): void
{
$this->prepareSearchEditor();
}

public function childrenSearchEditorAction(): void
{
$this->prepareSearchEditor(true);
}

private function prepareComplete(bool $forChildren = false): void
{
$column = $forChildren ? 'parent' : 'child';
$suggestions = (new ObjectSuggestions())
->setModel(DependencyNode::class)
->setBaseFilter(Filter::equal("$column.redundancy_group.id", $this->groupId))
Expand All @@ -243,9 +221,10 @@ private function prepareComplete(bool $forChildren = false): void
$this->getDocument()->add($suggestions);
}

private function prepareSearchEditor(bool $forChildren = false): void
public function searchEditorAction(): void
{
$redirectUrl = $forChildren
$isChildrenTab = $this->params->shift('isChildrenTab');
$redirectUrl = $isChildrenTab
? Links::redundancyGroupChildren($this->group)
: Links::redundancyGroupMembers($this->group);

Expand All @@ -259,12 +238,8 @@ private function prepareSearchEditor(bool $forChildren = false): void
]
);

if ($editor->getSuggestionUrl()) {
$editor->getSuggestionUrl()->setParam('id', $this->groupId);
}

if ($forChildren) {
$editor->getSuggestionUrl()->setPath('icingadb/redundancygroup/children-complete');
if ($isChildrenTab) {
$editor->getSuggestionUrl()->setParam('isChildrenTab');

Check failure on line 242 in application/controllers/RedundancygroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Cannot call method setParam() on ipl\Web\Url|null.

Check failure on line 242 in application/controllers/RedundancygroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Cannot call method setParam() on ipl\Web\Url|null.
}

$this->getDocument()->add($editor);
Expand Down

0 comments on commit 684ce55

Please sign in to comment.