chg: [navigation:tags] Updated UI to reflect users' permissions

refacto/CRUDComponent
Sami Mokaddem 2023-09-06 10:42:08 +02:00
parent bde01882d9
commit 01356824a2
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 23 additions and 3 deletions

View File

@ -10,7 +10,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'data' => [ 'data' => [
'type' => 'simple', 'type' => 'simple',
'text' => __('Add tag'), 'text' => __('Add tag'),
'popover_url' => '/tags/add' 'popover_url' => '/tags/add',
'requirement' => !empty($loggedUser['role']['perm_admin']),
] ]
] ]
], ],
@ -65,12 +66,14 @@ echo $this->element('genericElements/IndexTable/index_table', [
[ [
'open_modal' => '/tags/edit/[onclick_params_data_path]', 'open_modal' => '/tags/edit/[onclick_params_data_path]',
'modal_params_data_path' => 'id', 'modal_params_data_path' => 'id',
'icon' => 'edit' 'icon' => 'edit',
'requirement' => !empty($loggedUser['role']['perm_admin']),
], ],
[ [
'open_modal' => '/tags/delete/[onclick_params_data_path]', 'open_modal' => '/tags/delete/[onclick_params_data_path]',
'modal_params_data_path' => 'id', 'modal_params_data_path' => 'id',
'icon' => 'trash' 'icon' => 'trash',
'requirement' => !empty($loggedUser['role']['perm_admin']),
], ],
] ]
] ]

View File

@ -5,4 +5,21 @@ require_once(APP . 'Controller' . DS . 'Component' . DS . 'Navigation' . DS . 'b
class TagsNavigation extends BaseNavigation class TagsNavigation extends BaseNavigation
{ {
public function addLinks()
{
$controller = 'Tags';
if (empty($this->viewVars['loggedUser']['role']['perm_admin'])) {
$this->bcf->removeLink($controller, 'view', $controller, 'edit');
$this->bcf->removeLink($controller, 'edit', $controller, 'edit');
}
}
public function addActions()
{
$controller = 'Tags';
if (empty($this->viewVars['loggedUser']['role']['perm_admin'])) {
$this->bcf->removeAction($controller, 'view', $controller, 'delete');
$this->bcf->removeAction($controller, 'edit', $controller, 'delete');
}
}
} }