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
*
* @TODO(el): Rename to indexAction()
*/
public function listAction()
{
@ -30,6 +32,8 @@ class RoleController extends AuthBackendController
/**
* Create a new role
*
* @TODO(el): Rename to newAction()
*/
public function addAction()
{
@ -52,24 +56,23 @@ class RoleController extends AuthBackendController
}
));
$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 @@ class RoleController extends AuthBackendController
})
->setRedirectUrl('role/list')
->handleRequest();
$this->view->form = $role;
$this->render('form');
$this->renderForm($role, $this->translate('Update Role'));
}
/**
@ -132,12 +134,10 @@ class RoleController extends AuthBackendController
}
));
$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'));
}
/**

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());
}
/**
* 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
*