From 833af4c62e9e2b1f0e22e0d10ad0e30a245e4d76 Mon Sep 17 00:00:00 2001 From: Xu Date: Wed, 22 May 2024 18:29:32 +0200 Subject: [PATCH] add edit and back macros to twig --- resources/views/admin/locations/index.twig | 6 +++--- resources/views/admin/schedule/edit.twig | 2 +- resources/views/admin/schedule/index.twig | 2 +- resources/views/admin/schedule/load.twig | 2 +- resources/views/admin/shifts/history.twig | 2 +- resources/views/admin/shifttypes/index.twig | 6 +++--- resources/views/admin/user/edit-goodie.twig | 2 +- resources/views/admin/user/edit-worklog.twig | 2 +- resources/views/macros/base.twig | 8 ++++++++ resources/views/pages/design.twig | 10 +++++++++- resources/views/pages/faq/edit.twig | 2 +- resources/views/pages/faq/overview.twig | 2 +- resources/views/pages/messages/conversation.twig | 2 +- resources/views/pages/news/edit.twig | 2 +- resources/views/pages/news/overview.twig | 4 ++-- resources/views/pages/questions/edit.twig | 2 +- resources/views/pages/questions/overview.twig | 2 +- resources/views/pages/registration.twig | 5 +---- 18 files changed, 38 insertions(+), 25 deletions(-) diff --git a/resources/views/admin/locations/index.twig b/resources/views/admin/locations/index.twig index 9edacb57..f16f4e21 100644 --- a/resources/views/admin/locations/index.twig +++ b/resources/views/admin/locations/index.twig @@ -8,9 +8,9 @@

{% if not is_index|default(false) %} - {{ m.button(m.icon('chevron-left'), location + {{ m.back(location ? url('/locations', {'action': 'view', 'location_id': location.id}) - : url('/admin/locations'), {'size':'sm', 'title':__('general.back')}) }} + : url('/admin/locations')) }} {% endif %} {{ block('title') }} @@ -57,7 +57,7 @@
- {{ m.button(m.icon('pencil'), url('/admin/locations/edit/' ~ location.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('/admin/locations/edit/' ~ location.id)) }}
{{ csrf() }} diff --git a/resources/views/admin/schedule/edit.twig b/resources/views/admin/schedule/edit.twig index aab4114e..eeebcdbd 100644 --- a/resources/views/admin/schedule/edit.twig +++ b/resources/views/admin/schedule/edit.twig @@ -5,7 +5,7 @@ {% block title %}{{ schedule ? __('schedule.edit.title') : __('schedule.import.title') }}{% endblock %} {% block content_title %} - {{ m.button(m.icon('chevron-left'), url('/admin/schedule'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/admin/schedule')) }} {{ block('title') }} {% endblock %} diff --git a/resources/views/admin/schedule/index.twig b/resources/views/admin/schedule/index.twig index f9e28dc8..30e56886 100644 --- a/resources/views/admin/schedule/index.twig +++ b/resources/views/admin/schedule/index.twig @@ -41,7 +41,7 @@ {{ csrf() }}
{{ m.button(m.icon('box-arrow-in-down'), url('/admin/schedule/load/' ~ schedule.id), {'size': 'sm', 'title': __('form.import')}) }} - {{ m.button(m.icon('pencil'), url('/admin/schedule/edit/' ~ schedule.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('/admin/schedule/edit/' ~ schedule.id)) }} {{ f.delete(null, { 'title': __('form.delete'), 'confirm_button_text': __('form.delete'), diff --git a/resources/views/admin/schedule/load.twig b/resources/views/admin/schedule/load.twig index 24058b98..db0a43a5 100644 --- a/resources/views/admin/schedule/load.twig +++ b/resources/views/admin/schedule/load.twig @@ -5,7 +5,7 @@ {% block title %}{{ __('schedule.import.load.title') }}{% endblock %} {% block content_title %} - {{ m.button(m.icon('chevron-left'), url('/admin/schedule'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/admin/schedule')) }} {{ block('title') }} {% endblock %} diff --git a/resources/views/admin/shifts/history.twig b/resources/views/admin/shifts/history.twig index 253eea6f..ace45b59 100644 --- a/resources/views/admin/shifts/history.twig +++ b/resources/views/admin/shifts/history.twig @@ -7,7 +7,7 @@ {% block content %}

- {{ m.button(m.icon('chevron-left'), url('/admin-shifts'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/admin-shifts')) }} {% block content_title %}{{ block('title') }}{% endblock %}

diff --git a/resources/views/admin/shifttypes/index.twig b/resources/views/admin/shifttypes/index.twig index d4be61e2..746499e8 100644 --- a/resources/views/admin/shifttypes/index.twig +++ b/resources/views/admin/shifttypes/index.twig @@ -8,7 +8,7 @@

{% if not is_index|default(false) %} - {{ m.button(m.icon('chevron-left'), url('/admin/shifttypes'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/admin/shifttypes')) }} {% endif %} {{ block('title') }} @@ -16,7 +16,7 @@ {% if is_index|default(false) and can('shifttypes.edit') %} {{ m.button(m.icon('plus-lg'), url('/admin/shifttypes/edit')) }} {% elseif is_view|default(false) and can('shifttypes.edit') %} - {{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('admin/shifttypes/edit/' ~ shifttype.id)) }} {% endif %}

@@ -45,7 +45,7 @@ {% if can('shifttypes.edit') %}
- {{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('admin/shifttypes/edit/' ~ shifttype.id)) }} {{ csrf() }} diff --git a/resources/views/admin/user/edit-goodie.twig b/resources/views/admin/user/edit-goodie.twig index 99f56101..ec689133 100644 --- a/resources/views/admin/user/edit-goodie.twig +++ b/resources/views/admin/user/edit-goodie.twig @@ -9,7 +9,7 @@ {% block content %}

- {{ m.button(m.icon('chevron-left'), url('/admin-active'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/admin-active')) }} {{ block('title') }}: {{ m.user(userdata) }}

diff --git a/resources/views/admin/user/edit-worklog.twig b/resources/views/admin/user/edit-worklog.twig index b7ac3886..14a9d227 100644 --- a/resources/views/admin/user/edit-worklog.twig +++ b/resources/views/admin/user/edit-worklog.twig @@ -7,7 +7,7 @@ {% block content %}

- {{ m.button(m.icon('chevron-left'), url('/users', {action: 'view', user_id: userdata.id}), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/users', {action: 'view', user_id: userdata.id})) }} {{ block('title') }}

diff --git a/resources/views/macros/base.twig b/resources/views/macros/base.twig index 30ca9393..02b5191b 100644 --- a/resources/views/macros/base.twig +++ b/resources/views/macros/base.twig @@ -45,6 +45,14 @@ {% endmacro %} +{% macro edit(url) %} + {{ _self.button(_self.icon('pencil'), url, {'size': 'sm', 'title': __('form.edit')}) }} +{% endmacro %} + +{% macro back(url) %} + {{ _self.button(_self.icon('chevron-left'), url, {'size': 'sm', 'title': __('general.back')}) }} +{% endmacro %} + {% macro info(text, raw) %} {{ _self.icon('info-circle') }} diff --git a/resources/views/pages/design.twig b/resources/views/pages/design.twig index f4417f24..5390ce9a 100644 --- a/resources/views/pages/design.twig +++ b/resources/views/pages/design.twig @@ -585,9 +585,17 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular.

-

button(label, url, type, size)

+

button(label, url, opt)

{{ m.button('Label', '#', {'type': 'info', 'size': 'sm'}) }}

+
+

edit(url)

+

{{ m.edit('#') }}

+
+
+

back(url)

+

{{ m.back('#') }}

+
diff --git a/resources/views/pages/faq/edit.twig b/resources/views/pages/faq/edit.twig index e415a38f..df54817b 100644 --- a/resources/views/pages/faq/edit.twig +++ b/resources/views/pages/faq/edit.twig @@ -7,7 +7,7 @@ {% block content %}

- {{ m.button(m.icon('chevron-left'), url('/faq'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/faq')) }} {{ block('title') }}

diff --git a/resources/views/pages/faq/overview.twig b/resources/views/pages/faq/overview.twig index 34a4cfaf..745c8e62 100644 --- a/resources/views/pages/faq/overview.twig +++ b/resources/views/pages/faq/overview.twig @@ -54,7 +54,7 @@ {% if can('faq.edit') %} - {{ m.button(m.icon('pencil'), url('/admin/faq/' ~ item.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('/admin/faq/' ~ item.id)) }} diff --git a/resources/views/pages/news/edit.twig b/resources/views/pages/news/edit.twig index 27b5dce2..2df4e7cc 100644 --- a/resources/views/pages/news/edit.twig +++ b/resources/views/pages/news/edit.twig @@ -7,7 +7,7 @@ {% block content %}

- {{ m.button(m.icon('chevron-left'), url('/news'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/news')) }} {{ block('title') }}

diff --git a/resources/views/pages/news/overview.twig b/resources/views/pages/news/overview.twig index 99ef5a49..d607b466 100644 --- a/resources/views/pages/news/overview.twig +++ b/resources/views/pages/news/overview.twig @@ -9,7 +9,7 @@

{% if not is_overview|default(false) %} - {{ m.button(m.icon('chevron-left'), url('/news'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/news')) }} {% endif %} {{ block('title') }} {%- if can('admin_news') and is_overview|default(false) -%} @@ -99,7 +99,7 @@ {% if can('admin_news') %}
- {{ m.button(m.icon('pencil'), url('/admin/news/' ~ news.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('/admin/news/' ~ news.id)) }}

- {{ m.button(m.icon('chevron-left'), url('/questions'), {'size': 'sm', 'title': __('general.back')}) }} + {{ m.back(url('/questions')) }} {{ block('title') }}

diff --git a/resources/views/pages/questions/overview.twig b/resources/views/pages/questions/overview.twig index 75888232..533c752e 100644 --- a/resources/views/pages/questions/overview.twig +++ b/resources/views/pages/questions/overview.twig @@ -85,7 +85,7 @@
{% if can('question.edit') %} - {{ m.button(m.icon('pencil'), url('/admin/questions/' ~ question.id), {'size': 'sm', 'title': __('form.edit')}) }} + {{ m.edit(url('/admin/questions/' ~ question.id)) }} {% endif %} {% if question.user.id == user.id or can('question.edit') %} diff --git a/resources/views/pages/registration.twig b/resources/views/pages/registration.twig index 80ae185b..a019023b 100644 --- a/resources/views/pages/registration.twig +++ b/resources/views/pages/registration.twig @@ -8,10 +8,7 @@

- {{ can('admin_user') - ? m.button(m.icon('chevron-left'), url('/users'), {'size': 'sm', 'title': __('general.back')}) - : '' - }} + {{ can('admin_user') ? m.back(url('/users')) : '' }} {{ __('registration.title') }}