From be3c43ef778ead1df5a85fb0943e4754fa5c82f7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 1 Oct 2015 00:25:54 +0200 Subject: [PATCH] Add tab to new, update and remove role refs #5543 --- application/controllers/RoleController.php | 18 +++++++++--------- application/views/scripts/role/form.phtml | 6 ------ application/views/scripts/simple-form.phtml | 6 ++++++ library/Icinga/Web/Controller.php | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 15 deletions(-) delete mode 100644 application/views/scripts/role/form.phtml create mode 100644 application/views/scripts/simple-form.phtml diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 9bfd2d175d..68fbadf3f0 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -20,6 +20,8 @@ class RoleController extends AuthBackendController { /** * List roles + * + * @TODO(el): Rename to indexAction() */ public function listAction() { @@ -30,6 +32,8 @@ public function listAction() /** * Create a new role + * + * @TODO(el): Rename to newAction() */ public function addAction() { @@ -52,24 +56,23 @@ public function addAction() } )); $role - ->setTitle($this->translate('New Role')) ->setSubmitLabel($this->translate('Create Role')) ->setIniConfig(Config::app('roles', true)) ->setRedirectUrl('role/list') ->handleRequest(); - $this->view->form = $role; - $this->render('form'); + $this->renderForm($role, $this->translate('New Role')); } /** * Update a role + * + * @TODO(el): Rename to updateAction() */ public function editAction() { $this->assertPermission('config/authentication/roles/edit'); $name = $this->params->getRequired('role'); $role = new RoleForm(); - $role->setTitle(sprintf($this->translate('Update Role %s'), $name)); $role->setSubmitLabel($this->translate('Update Role')); try { $role @@ -97,8 +100,7 @@ public function editAction() }) ->setRedirectUrl('role/list') ->handleRequest(); - $this->view->form = $role; - $this->render('form'); + $this->renderForm($role, $this->translate('Update Role')); } /** @@ -132,12 +134,10 @@ public function removeAction() } )); $confirmation - ->setTitle(sprintf($this->translate('Remove Role %s'), $name)) ->setSubmitLabel($this->translate('Remove Role')) ->setRedirectUrl('role/list') ->handleRequest(); - $this->view->form = $confirmation; - $this->render('form'); + $this->renderForm($confirmation, $this->translate('Remove Role')); } /** diff --git a/application/views/scripts/role/form.phtml b/application/views/scripts/role/form.phtml deleted file mode 100644 index cbf06590d6..0000000000 --- a/application/views/scripts/role/form.phtml +++ /dev/null @@ -1,6 +0,0 @@ -
- showOnlyCloseButton(); ?> -
-
- -
\ No newline at end of file diff --git a/application/views/scripts/simple-form.phtml b/application/views/scripts/simple-form.phtml new file mode 100644 index 0000000000..954edc2633 --- /dev/null +++ b/application/views/scripts/simple-form.phtml @@ -0,0 +1,6 @@ +
+ +
+
+ setTitle(null) ?> +
diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 1e636aa33c..ac92e45b6a 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -78,6 +78,23 @@ public function httpNotFound($message) throw HttpNotFoundException::create(func_get_args()); } + /** + * Render the given form using a simple view script + * + * @param Form $form + * @param string $tab + */ + public function renderForm(Form $form, $tab) + { + $this->getTabs()->add(uniqid(), array( + 'active' => true, + 'label' => $tab, + 'url' => Url::fromRequest() + )); + $this->view->form = $form; + $this->render('simple-form', null, true); + } + /** * Create a SortBox widget and apply its sort rules on the given query *