Add tab to new, update and remove role

refs #5543
This commit is contained in:
Eric Lippmann 2015-10-01 00:25:54 +02:00
parent b15b04257b
commit be3c43ef77
4 changed files with 32 additions and 15 deletions

View File

@ -20,6 +20,8 @@ class RoleController extends AuthBackendController
{ {
/** /**
* List roles * List roles
*
* @TODO(el): Rename to indexAction()
*/ */
public function listAction() public function listAction()
{ {
@ -30,6 +32,8 @@ class RoleController extends AuthBackendController
/** /**
* Create a new role * Create a new role
*
* @TODO(el): Rename to newAction()
*/ */
public function addAction() public function addAction()
{ {
@ -52,24 +56,23 @@ class RoleController extends AuthBackendController
} }
)); ));
$role $role
->setTitle($this->translate('New Role'))
->setSubmitLabel($this->translate('Create Role')) ->setSubmitLabel($this->translate('Create Role'))
->setIniConfig(Config::app('roles', true)) ->setIniConfig(Config::app('roles', true))
->setRedirectUrl('role/list') ->setRedirectUrl('role/list')
->handleRequest(); ->handleRequest();
$this->view->form = $role; $this->renderForm($role, $this->translate('New Role'));
$this->render('form');
} }
/** /**
* Update a role * Update a role
*
* @TODO(el): Rename to updateAction()
*/ */
public function editAction() public function editAction()
{ {
$this->assertPermission('config/authentication/roles/edit'); $this->assertPermission('config/authentication/roles/edit');
$name = $this->params->getRequired('role'); $name = $this->params->getRequired('role');
$role = new RoleForm(); $role = new RoleForm();
$role->setTitle(sprintf($this->translate('Update Role %s'), $name));
$role->setSubmitLabel($this->translate('Update Role')); $role->setSubmitLabel($this->translate('Update Role'));
try { try {
$role $role
@ -97,8 +100,7 @@ class RoleController extends AuthBackendController
}) })
->setRedirectUrl('role/list') ->setRedirectUrl('role/list')
->handleRequest(); ->handleRequest();
$this->view->form = $role; $this->renderForm($role, $this->translate('Update Role'));
$this->render('form');
} }
/** /**
@ -132,12 +134,10 @@ class RoleController extends AuthBackendController
} }
)); ));
$confirmation $confirmation
->setTitle(sprintf($this->translate('Remove Role %s'), $name))
->setSubmitLabel($this->translate('Remove Role')) ->setSubmitLabel($this->translate('Remove Role'))
->setRedirectUrl('role/list') ->setRedirectUrl('role/list')
->handleRequest(); ->handleRequest();
$this->view->form = $confirmation; $this->renderForm($confirmation, $this->translate('Remove Role'));
$this->render('form');
} }
/** /**

View File

@ -1,6 +0,0 @@
<div class="controls">
<?= $tabs->showOnlyCloseButton(); ?>
</div>
<div class="content">
<?= $form; ?>
</div>

View File

@ -0,0 +1,6 @@
<div class="controls">
<?= $tabs ?>
</div>
<div class="content">
<?= $form->setTitle(null) ?>
</div>

View File

@ -78,6 +78,23 @@ class Controller extends ModuleActionController
throw HttpNotFoundException::create(func_get_args()); 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 * Create a SortBox widget and apply its sort rules on the given query
* *