Skip to content

Commit

Permalink
Add tab to new, update and remove role
Browse files Browse the repository at this point in the history
refs #5543
  • Loading branch information
lippserd committed Sep 30, 2015
1 parent b15b042 commit be3c43e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
18 changes: 9 additions & 9 deletions application/controllers/RoleController.php
Expand Up @@ -20,6 +20,8 @@ class RoleController extends AuthBackendController
{
/**
* List roles
*
* @TODO(el): Rename to indexAction()
*/
public function listAction()
{
Expand All @@ -30,6 +32,8 @@ public function listAction()

/**
* Create a new role
*
* @TODO(el): Rename to newAction()
*/
public function addAction()
{
Expand All @@ -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
Expand Down Expand Up @@ -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'));
}

/**
Expand Down Expand Up @@ -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'));
}

/**
Expand Down
6 changes: 0 additions & 6 deletions application/views/scripts/role/form.phtml

This file was deleted.

6 changes: 6 additions & 0 deletions application/views/scripts/simple-form.phtml
@@ -0,0 +1,6 @@
<div class="controls">
<?= $tabs ?>
</div>
<div class="content">
<?= $form->setTitle(null) ?>
</div>
17 changes: 17 additions & 0 deletions library/Icinga/Web/Controller.php
Expand Up @@ -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
*
Expand Down

0 comments on commit be3c43e

Please sign in to comment.