Skip to content

Commit

Permalink
Merge pull request #44 from maximehuran/feature/show-page-button
Browse files Browse the repository at this point in the history
Add button to go to page in admin
  • Loading branch information
maximehuran authored Nov 22, 2022
2 parents b51def8 + 863e39c commit dff3e17
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Resources/config/routing/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ monsieurbiz_sylius_cms_page_admin:
subheader: monsieurbiz_cms_page.ui.pages_subheader
templates:
form: "@MonsieurBizSyliusCmsPagePlugin/Admin/Page/_form.html.twig"
toolbar: "@MonsieurBizSyliusCmsPagePlugin/Admin/Page/Update/_toolbar.html.twig"
index:
icon: 'file alternate'
type: sylius.resource
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ monsieurbiz_cms_page:
meta_title: "Meta Title"
meta_description: "Meta Description"
meta_keywords: "Meta Keyword"
show_in: "Show in"
show_page_in_shop_page: "Show page in shop page"
actions:
create: 'Create a new page'
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ monsieurbiz_cms_page:
meta_title: "Meta Title"
meta_description: "Meta Description"
meta_keywords: "Meta Keyword"
show_in: "Afficher dans"
show_page_in_shop_page: "Afficher la page dans la boutique"
actions:
create: 'Créer une nouvelle page'
3 changes: 3 additions & 0 deletions src/Resources/views/Admin/Page/Update/_toolbar.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="ui right floated buttons">
{% include '@MonsieurBizSyliusCmsPagePlugin/Admin/Page/_showInShopButton.html.twig' %}
</div>
37 changes: 37 additions & 0 deletions src/Resources/views/Admin/Page/_showInShopButton.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% set enabledChannels = resource.channels|filter(channel => channel.enabled == true) %}

{% if sylius_bundle_loaded_checker('SyliusShopBundle') %}
{% if not resource.enabled or enabledChannels|length < 1 %}
<a class="ui labeled icon button disabled" href="#">
<i class="angle right icon"></i>
{{ 'monsieurbiz_cms_page.ui.show_page_in_shop_page'|trans }}
</a>
{% elseif enabledChannels|length > 1 %}
<div class="ui floating dropdown labeled icon button">
<i class="share alternate icon"></i>
<span class="text">
{{ 'monsieurbiz_cms_page.ui.show_page_in_shop_page'|trans }}
</span>
<div class="menu">
<div class="scrolling menu">
{% for channel in enabledChannels %}
{% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('monsieurbiz_cms_page_show', {'slug': resource.slug, '_locale': channel.defaultLocale.code}) : url('monsieurbiz_cms_page_show', {'slug': resource.slug, '_locale': channel.defaultLocale.code}) %}
<a href="{{ url|raw }}" class="item" target="_blank">
<i class="angle right icon"></i>
{{ 'monsieurbiz_cms_page.ui.show_in'|trans }}
{{ channel.name }} ({{ channel.code }})
</a>
{% endfor %}
</div>
</div>
</div>
{% else %}
{% for channel in enabledChannels %}
{% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('monsieurbiz_cms_page_show', {'slug': resource.slug, '_locale': channel.defaultLocale.code}) : url('monsieurbiz_cms_page_show', {'slug': resource.slug, '_locale': channel.defaultLocale.code}) %}
<a class="ui labeled icon button" href="{{ url|raw }}" target="_blank">
<i class="angle right icon"></i>
{{ 'monsieurbiz_cms_page.ui.show_page_in_shop_page'|trans }}
</a>
{% endfor %}
{% endif %}
{% endif %}

0 comments on commit dff3e17

Please sign in to comment.