Skip to content

Commit

Permalink
IBX-5018: Unified 'Create' buttons in Content Types and Content Type …
Browse files Browse the repository at this point in the history
…Groups lists (#720)

IBX-5018: Unify 'Create' buttons in Content Types and Content Type Groups lists
  • Loading branch information
barw4 authored Mar 10, 2023
1 parent 8b4aa15 commit b154f6d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/bundle/Controller/ContentTypeGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public function viewAction(Request $request, ContentTypeGroup $group, int $page
'content_type_group' => $group,
'page' => $page,
'route_name' => $request->get('_route'),
'can_create' => $this->isGranted(new Attribute('class', 'create')),
]);
}

Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/content_type.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@
<target state="new">Some of the Fields are disabled when translating a Content Type. To modify them, edit the Content Type in the main language.</target>
<note>key: content_type.view.edit.notranslatable_fields_disabled</note>
</trans-unit>
<trans-unit id="803a61fc8cf4e7bdfcf27432bb35e379a4971134" resname="content_type.view.list.action.add">
<source>Create</source>
<target state="new">Create</target>
<note>key: content_type.view.list.action.add</note>
</trans-unit>
<trans-unit id="da5f710198c48c803b3d0e2272e488903f92e569" resname="content_type.view.list.cannot_delete_notice">
<source>You cannot delete the disabled Content Types, because Content items of those types exist.</source>
<target state="new">You cannot delete the disabled Content Types, because Content items of those types exist.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@
} %}
{% endblock %}

{% block context_menu %}
{% set menu_items %}
{% if can_create %}
<li class="ibexa-context-menu__item ibexa-adaptive-items__item">
<a
href="{{ path('ibexa.content_type.add', {contentTypeGroupId: content_type_group.id}) }}"
class="btn ibexa-btn ibexa-btn--primary"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--create">
<use xlink:href="{{ ibexa_icon_path('create') }}"></use>
</svg>
<span class="ibexa-btn__label">
{{ 'content_type.view.list.action.add'|trans|desc('Create') }}
</span>
</a>
</li>
{% endif %}
{% endset %}

{{ include('@ibexadesign/ui/component/context_menu/context_menu.html.twig', {
menu_items: menu_items,
}) }}
{% endblock %}

{% block content %}
{{ render(controller('Ibexa\\Bundle\\AdminUi\\Controller\\ContentTypeController::listAction', {
contentTypeGroupId: content_type_group.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@
{% block header %}
{% embed '@ibexadesign/ui/component/table/table_header.html.twig' %}
{% block actions %}
{% if can_create %}
<a
href="{{ path('ibexa.content_type.add', {contentTypeGroupId: content_type_group.id}) }}"
class="btn ibexa-btn ibexa-btn--tertiary ibexa-btn--small"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--create">
<use xlink:href="{{ ibexa_icon_path('create') }}"></use>
</svg>
<span class="ibexa-btn__label">
{{ 'content_type.view.list.action.add'|trans|desc('Add new') }}
</span>
</a>
{% endif %}
{% if can_delete %}
{% set modal_data_target = 'delete-content-types-modal' %}
<button
Expand Down

0 comments on commit b154f6d

Please sign in to comment.