From 8e16e7e3b6ca56282e0d9eec9faefefcc61a83a0 Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:37:10 +0100 Subject: [PATCH] WIP3 --- .../controllers/EventRuleController.php | 2 +- .../EventRuleConfigFilter.php | 32 ++++++++++++++----- application/forms/EventRuleConfigForm.php | 1 - 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/application/controllers/EventRuleController.php b/application/controllers/EventRuleController.php index fe002f48b..4b4bd3744 100644 --- a/application/controllers/EventRuleController.php +++ b/application/controllers/EventRuleController.php @@ -86,10 +86,10 @@ public function indexAction(): void ->on(EventRuleConfigForm::ON_DISCARD, function () use ($config) { $ruleId = $config['id']; $this->sessionNamespace->delete($ruleId); + Notification::success(sprintf(t('Successfully discarded changes to event rule %s'), $config['name'])); $this->redirectNow(Links::eventRule($ruleId)); }) ->on(EventRuleConfigForm::ON_CHANGE, function (EventRuleConfigForm $form) use ($config) { - $formValues = $form->getValues(); $config = array_merge($config, $form->getValues()); $this->sessionNamespace->set($config['id'], $config); }) diff --git a/application/forms/EventRuleConfigElements/EventRuleConfigFilter.php b/application/forms/EventRuleConfigElements/EventRuleConfigFilter.php index 21cc880e7..9a89d42bc 100644 --- a/application/forms/EventRuleConfigElements/EventRuleConfigFilter.php +++ b/application/forms/EventRuleConfigElements/EventRuleConfigFilter.php @@ -13,13 +13,10 @@ class EventRuleConfigFilter extends FieldsetElement { - /** @var bool */ - public $showSearchBar = false; - - /** @var Url The url to open the SearchEditor at */ + /** @var Url Url of the search editor */ protected $searchEditorUrl; - /** @var ?string */ + /** @var ?string Event rule's object filter*/ protected $objectFilter; protected $defaultAttributes = ['class' => 'config-filter']; @@ -57,7 +54,7 @@ protected function assemble() } else { $editorOpener = new Link( new Icon('cog'), - $this->searchEditorUrl, + $this->getSearchEditorUrl(), Attributes::create([ 'class' => 'search-editor-opener control-button', 'title' => t('Adjust Filter'), @@ -82,6 +79,13 @@ protected function assemble() $this->add($filterElement); } + /** + * Set the Url of the search editor + * + * @param Url $url + * + * @return $this + */ public function setSearchEditorUrl(Url $url) { $this->searchEditorUrl = $url; @@ -89,24 +93,36 @@ public function setSearchEditorUrl(Url $url) return $this; } + /** + * Get the search editor's Url + * + * @return Url + */ public function getSearchEditorUrl() { return $this->searchEditorUrl; } /** + * Set the event rule's object filter + * * @param string $filter * * @return $this */ - public function setObjectFilter(string $filter) + public function setObjectFilter(string $filter): self { $this->objectFilter = rawurldecode($filter); return $this; } - public function getObjectFilter() + /** + * Get the event rule's object filter + * + * @return ?string + */ + public function getObjectFilter(): ?string { return $this->objectFilter; } diff --git a/application/forms/EventRuleConfigForm.php b/application/forms/EventRuleConfigForm.php index e9c39b3a5..0baa6501c 100644 --- a/application/forms/EventRuleConfigForm.php +++ b/application/forms/EventRuleConfigForm.php @@ -163,7 +163,6 @@ protected function assemble() for ($i = 1; $i <= $escalationCount; $i++) { $escalationCondition = new EscalationCondition('escalation-condition_' . $i); $escalationRecipient = new EscalationRecipient('escalation-recipient_' . $i); - $this->registerElement($escalationCondition); $this->registerElement($escalationRecipient);