add edit and back macros to twig

This commit is contained in:
Xu 2024-05-22 18:29:32 +02:00 committed by Igor Scheller
parent b380d7e68e
commit 833af4c62e
18 changed files with 38 additions and 25 deletions

View File

@ -8,9 +8,9 @@
<div class="container">
<h1>
{% 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 @@
<td>
<div class="d-flex ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/locations/edit/' ~ location.id), {'size': 'sm', 'title': __('form.edit')}) }}
{{ m.edit(url('/admin/locations/edit/' ~ location.id)) }}
<form method="post" class="ps-1">
{{ csrf() }}

View File

@ -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 %}

View File

@ -41,7 +41,7 @@
{{ csrf() }}
<div class="btn-group">
{{ 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'),

View File

@ -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 %}

View File

@ -7,7 +7,7 @@
{% block content %}
<div class="container">
<h1>
{{ 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 %}
</h1>

View File

@ -8,7 +8,7 @@
<div class="container">
<h1>
{% 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 %}
</h1>
@ -45,7 +45,7 @@
<td>
{% if can('shifttypes.edit') %}
<div class="d-flex ms-auto">
{{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), {'size': 'sm', 'title': __('form.edit')}) }}
{{ m.edit(url('admin/shifttypes/edit/' ~ shifttype.id)) }}
<form method="post" class="ps-1">
{{ csrf() }}

View File

@ -9,7 +9,7 @@
{% block content %}
<div class="container">
<h1>
{{ m.button(m.icon('chevron-left'), url('/admin-active'), {'size': 'sm', 'title': __('general.back')}) }}
{{ m.back(url('/admin-active')) }}
{{ block('title') }}: <small>{{ m.user(userdata) }}</small>
</h1>

View File

@ -7,7 +7,7 @@
{% block content %}
<div class="container">
<h1>
{{ 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') }}
</h1>

View File

@ -45,6 +45,14 @@
</a>
{% 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) %}
<span class="help-block">
{{ _self.icon('info-circle') }}

View File

@ -585,9 +585,17 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular.</code></pre>
</p>
</div>
<div class="col-md-3">
<h4><code>button(label, url, type, size)</code></h4>
<h4><code>button(label, url, opt)</code></h4>
<p>{{ m.button('Label', '#', {'type': 'info', 'size': 'sm'}) }}</p>
</div>
<div class="col-md-3">
<h4><code>edit(url)</code></h4>
<p>{{ m.edit('#') }}</p>
</div>
<div class="col-md-3">
<h4><code>back(url)</code></h4>
<p>{{ m.back('#') }}</p>
</div>
</div>
<span id="bar_chart" class="ref-id"></span>

View File

@ -7,7 +7,7 @@
{% block content %}
<div class="container">
<h1>
{{ m.button(m.icon('chevron-left'), url('/faq'), {'size': 'sm', 'title': __('general.back')}) }}
{{ m.back(url('/faq')) }}
{{ block('title') }}
</h1>

View File

@ -54,7 +54,7 @@
{% if can('faq.edit') %}
<span class="ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/faq/' ~ item.id), {'size': 'sm', 'title': __('form.edit')}) }}
{{ m.edit(url('/admin/faq/' ~ item.id)) }}
</span>
<form class="ps-1"

View File

@ -8,7 +8,7 @@
<div class="container">
<div class="page-header">
<h1>
{{ m.button(m.icon('chevron-left'), url('/messages'), {'size': 'sm', 'title': __('general.back')}) }}
{{ m.back(url('/messages')) }}
{{ __('message.title') }}: {{ m.user(other_user, {'pronoun': true}) }}
</h1>
</div>

View File

@ -7,7 +7,7 @@
{% block content %}
<div class="container">
<h1>
{{ m.button(m.icon('chevron-left'), url('/news'), {'size': 'sm', 'title': __('general.back')}) }}
{{ m.back(url('/news')) }}
{{ block('title') }}
</h1>

View File

@ -9,7 +9,7 @@
<div class="container">
<h1>
{% 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') %}
<div class="d-flex ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/news/' ~ news.id), {'size': 'sm', 'title': __('form.edit')}) }}
{{ m.edit(url('/admin/news/' ~ news.id)) }}
<form class="ps-1"
action="{{ url('/admin/news/' ~ news.id) }}" enctype="multipart/form-data"

View File

@ -7,7 +7,7 @@
{% block content %}
<div class="container">
<h1>
{{ m.button(m.icon('chevron-left'), url('/questions'), {'size': 'sm', 'title': __('general.back')}) }}
{{ m.back(url('/questions')) }}
{{ block('title') }}
</h1>

View File

@ -85,7 +85,7 @@
<div class="d-flex ms-auto">
{% 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') %}

View File

@ -8,10 +8,7 @@
<div class="container">
<div class="mb-5">
<h1>
{{ 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') }}
</h1>
</div>