diff --git a/application/forms/Dashboard/RemoveDashletForm.php b/application/forms/Dashboard/RemoveDashletForm.php new file mode 100644 index 000000000..a5dbd2b25 --- /dev/null +++ b/application/forms/Dashboard/RemoveDashletForm.php @@ -0,0 +1,46 @@ +dashboard = $dashboard; + + $this->setAction((string) Url::fromRequest()); + } + + protected function assemble() + { + $this->addHtml(HtmlElement::create('h1', null, sprintf( + t('Please confirm removal of dashlet "%s"'), + Url::fromRequest()->getParam('dashlet') + ))); + + $this->addElement('submit', 'remove_dashlet', ['label' => t('Remove Dashlet')]); + } + + protected function onSuccess() + { + $requestUrl = Url::fromRequest(); + $home = $this->dashboard->getActiveHome(); + $pane = $home->getPane($requestUrl->getParam('pane')); + + $dashlet = $requestUrl->getParam('dashlet'); + $pane->removeDashlet($dashlet); + + Notification::success(sprintf(t('Removed dashlet "%s" successfully'), $dashlet)); + } +}