mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
[CRUD] check that action exists before inserting them in edit and view template
This commit is contained in:
parent
d4b498e2be
commit
1e06393a7d
@ -112,4 +112,4 @@ Master branch
|
|||||||
- [translation] in french, replace "Modifier" by "Enregistrer" in the edit form
|
- [translation] in french, replace "Modifier" by "Enregistrer" in the edit form
|
||||||
- [chill entity render] fix error when fallback to default entity render (usage of `__toString()`)
|
- [chill entity render] fix error when fallback to default entity render (usage of `__toString()`)
|
||||||
- [CRUD] add step delete
|
- [CRUD] add step delete
|
||||||
|
- [CRUD] check that action exists before inserting them in edit and view template
|
||||||
|
@ -93,4 +93,10 @@ class Resolver
|
|||||||
'_'.
|
'_'.
|
||||||
$action);
|
$action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasAction($crudName, $action)
|
||||||
|
{
|
||||||
|
return \array_key_exists($action,
|
||||||
|
$this->crudConfig[$crudName]['actions']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,9 @@ class TwigCRUDResolver extends AbstractExtension
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFunction('chill_crud_config', [$this, 'getConfig'],
|
new TwigFunction('chill_crud_config', [$this, 'getConfig'],
|
||||||
['is_safe' => 'html'])
|
['is_safe' => 'html']),
|
||||||
|
new TwigFunction('chill_crud_action_exists', [$this, 'hasAction'],
|
||||||
|
[]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,5 +57,10 @@ class TwigCRUDResolver extends AbstractExtension
|
|||||||
{
|
{
|
||||||
return $this->resolver->getConfigValue($configKey, $crudName, $action);
|
return $this->resolver->getConfigValue($configKey, $crudName, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasAction($crudName, $action)
|
||||||
|
{
|
||||||
|
return $this->resolver->hasAction($crudName, $action);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,22 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content_form_actions_before %}{% endblock %}
|
{% block content_form_actions_before %}{% endblock %}
|
||||||
{% block content_form_actions_delete %}
|
{% block content_form_actions_delete %}
|
||||||
|
{% if chill_crud_action_exists(crud_name, 'delete') %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'delete'), entity) %}
|
{% if is_granted(chill_crud_config('role', crud_name, 'delete'), entity) %}
|
||||||
<li class="">
|
<li class="">
|
||||||
<a class="sc-button bt-small bt-delete" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_delete', { 'id': entity.id }) }}"></a>
|
<a class="sc-button bt-small bt-delete" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_delete', { 'id': entity.id }) }}"></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock content_form_actions_delete %}
|
{% endblock content_form_actions_delete %}
|
||||||
{% block content_form_actions_view %}
|
{% block content_form_actions_view %}
|
||||||
|
{% if chill_crud_action_exists(crud_name, 'view') %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %}
|
{% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %}
|
||||||
<li class="">
|
<li class="">
|
||||||
<a class="sc-button bt-small bt-show" href="{{ chill_path_forward_return_path('chill_crud_'~crud_name~'_view', { 'id': entity.id }) }}"></a>
|
<a class="sc-button bt-small bt-show" href="{{ chill_path_forward_return_path('chill_crud_'~crud_name~'_view', { 'id': entity.id }) }}"></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock content_form_actions_view %}
|
{% endblock content_form_actions_view %}
|
||||||
{% block content_form_actions_save_and_close %}
|
{% block content_form_actions_save_and_close %}
|
||||||
<li class="">
|
<li class="">
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content_view_actions_before %}{% endblock %}
|
{% block content_view_actions_before %}{% endblock %}
|
||||||
{% block content_form_actions_delete %}
|
{% block content_form_actions_delete %}
|
||||||
|
{% if chill_crud_action_exists(crud_name, 'delete') %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'delete'), entity) %}
|
{% if is_granted(chill_crud_config('role', crud_name, 'delete'), entity) %}
|
||||||
<li class="">
|
<li class="">
|
||||||
<a class="sc-button bt-delete" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_delete', { 'id': entity.id }) }}">
|
<a class="sc-button bt-delete" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_delete', { 'id': entity.id }) }}">
|
||||||
@ -30,8 +31,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock content_form_actions_delete %}
|
{% endblock content_form_actions_delete %}
|
||||||
{% block content_view_actions_duplicate_link %}
|
{% block content_view_actions_duplicate_link %}
|
||||||
|
{% if chill_crud_action_exists(crud_name, 'new') %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'new'), entity) %}
|
{% if is_granted(chill_crud_config('role', crud_name, 'new'), entity) %}
|
||||||
<li>
|
<li>
|
||||||
<a class="sc-button bt-duplicate" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_new', { 'duplicate_id': entity.id, 'duplicate': true }) }}">
|
<a class="sc-button bt-duplicate" href="{{ chill_path_add_return_path('chill_crud_'~crud_name~'_new', { 'duplicate_id': entity.id, 'duplicate': true }) }}">
|
||||||
@ -39,8 +42,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock content_view_actions_duplicate_link %}
|
{% endblock content_view_actions_duplicate_link %}
|
||||||
{% block content_view_actions_edit_link %}
|
{% block content_view_actions_edit_link %}
|
||||||
|
{% if chill_crud_action_exists(crud_name, 'edit') %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'edit'), entity) %}
|
{% if is_granted(chill_crud_config('role', crud_name, 'edit'), entity) %}
|
||||||
<li>
|
<li>
|
||||||
<a class="sc-button bt-edit" href="{{ chill_path_forward_return_path('chill_crud_'~crud_name~'_edit', { 'id': entity.id }) }}">
|
<a class="sc-button bt-edit" href="{{ chill_path_forward_return_path('chill_crud_'~crud_name~'_edit', { 'id': entity.id }) }}">
|
||||||
@ -48,6 +53,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endblock content_view_actions_edit_link %}
|
{% endblock content_view_actions_edit_link %}
|
||||||
{% block content_view_actions_after %}{% endblock %}
|
{% block content_view_actions_after %}{% endblock %}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user