diff --git a/application/forms/Dashboard/RemoveHomePaneForm.php b/application/forms/Dashboard/RemoveHomePaneForm.php new file mode 100644 index 000000000..c29818f1c --- /dev/null +++ b/application/forms/Dashboard/RemoveHomePaneForm.php @@ -0,0 +1,45 @@ +dashboard = $dashboard; + + $this->setAction((string) Url::fromRequest()); + } + + protected function assemble() + { + $this->addElement('submit', 'btn_remove', ['label' => t('Remove Home')]); + } + + protected function onSuccess() + { + $requestUrl = Url::fromRequest(); + $home = $this->dashboard->getActiveHome(); + + if ($requestUrl->getPath() === Dashboard::BASE_ROUTE . '/remove-home') { + $this->dashboard->removeHome($home); + + Notification::success(sprintf(t('Removed dashboard home "%s" successfully'), $home->getLabel())); + } else { + $pane = $home->getPane($requestUrl->getParam('pane')); + $home->removePane($pane); + + Notification::success(sprintf(t('Removed dashboard pane "%s" successfully'), $pane->getTitle())); + } + } +}