m.button with opt

This commit is contained in:
Xu 2024-05-21 19:05:33 +02:00 committed by Igor Scheller
parent 6f8dad070c
commit b380d7e68e
19 changed files with 37 additions and 43 deletions

View File

@ -10,13 +10,13 @@
{% if not is_index|default(false) %}
{{ m.button(m.icon('chevron-left'), location
? url('/locations', {'action': 'view', 'location_id': location.id})
: url('/admin/locations'), 'secondary', 'sm', __('general.back')) }}
: url('/admin/locations'), {'size':'sm', 'title':__('general.back')}) }}
{% endif %}
{{ block('title') }}
{% if is_index|default(false) %}
{{ m.button(m.icon('plus-lg'), url('/admin/locations/edit'), 'secondary') }}
{{ m.button(m.icon('plus-lg'), url('/admin/locations/edit')) }}
{% endif %}
</h1>
@ -57,7 +57,7 @@
<td>
<div class="d-flex ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/locations/edit/' ~ location.id), null, 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('/admin/locations/edit/' ~ location.id), {'size': 'sm', 'title': __('form.edit')}) }}
<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'), 'secondary', 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/admin/schedule'), {'size': 'sm', 'title': __('general.back')}) }}
{{ block('title') }}
{% endblock %}

View File

@ -10,7 +10,7 @@
{% block content_title %}{{ block('title') }}{% endblock %}
{% if is_index|default(false) %}
{{ m.button(m.icon('plus-lg'), url('/admin/schedule/edit'), 'secondary') }}
{{ m.button(m.icon('plus-lg'), url('/admin/schedule/edit')) }}
{% endif %}
</h1>
@ -40,8 +40,8 @@
<form method="post" action="{{ url('/admin/schedule/edit/' ~ schedule.id) }}">
{{ csrf() }}
<div class="btn-group">
{{ m.button(m.icon('box-arrow-in-down'), url('/admin/schedule/load/' ~ schedule.id), 'secondary', 'sm', __('form.import')) }}
{{ m.button(m.icon('pencil'), url('/admin/schedule/edit/' ~ schedule.id), 'secondary', 'sm', __('form.edit')) }}
{{ 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')}) }}
{{ 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'), 'secondary', 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/admin/schedule'), {'size': 'sm', 'title': __('general.back')}) }}
{{ block('title') }}
{% endblock %}

View File

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

View File

@ -8,15 +8,15 @@
<div class="container">
<h1>
{% if not is_index|default(false) %}
{{ m.button(m.icon('chevron-left'), url('/admin/shifttypes'), 'secondary', 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/admin/shifttypes'), {'size': 'sm', 'title': __('general.back')}) }}
{% endif %}
{{ block('title') }}
{% if is_index|default(false) and can('shifttypes.edit') %}
{{ m.button(m.icon('plus-lg'), url('/admin/shifttypes/edit'), 'secondary') }}
{{ 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), null, 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), {'size': 'sm', 'title': __('form.edit')}) }}
{% 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), null, 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), {'size': 'sm', 'title': __('form.edit')}) }}
<form method="post" class="ps-1">
{{ csrf() }}

View File

@ -12,12 +12,7 @@
<div class="row">
<div class="col-md-12">
{{ m.alert(__('worklog.delete.info', [m.user(userdata)]), 'danger', true) }}
{{ m.button(__('form.cancel'),
url('/users?action=view&user_id=' ~ userdata.id),
null,
null,
null,
'x-lg') }}
{{ m.button(__('form.cancel'), url('/users?action=view&user_id=' ~ userdata.id), {'icon_left': 'x-lg'}) }}
{{ f.delete(__('form.delete')) }}
</div>
</div>

View File

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

View File

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

View File

@ -34,14 +34,14 @@
</a>
{% endmacro %}
{% macro button(label, url, type, size, title, icon_left, icon_right) %}
<a href="{{ url }}" class="btn btn-{{ type|default('secondary') }}
{%- if size %} btn-{{ size }}{% endif %}"
{%- if title %} title="{{ title }}"{% endif -%}
{% macro button(label, url, opt) %}
<a href="{{ url }}" class="btn btn-{{ opt.type|default('secondary') }}
{%- if opt.size is defined %} btn-{{ opt.size }}{% endif %}"
{%- if opt.title is defined %} title="{{ opt.title }}"{% endif -%}
>
{%- if icon_left %}{{ _self.icon(icon_left) }}{% endif %}
{%- if opt.icon_left is defined %}{{ _self.icon(opt.icon_left) }}{% endif %}
{{ label }}
{%- if icon_right %}{{ _self.icon(icon_right) }}{% endif %}
{%- if opt.icon_right is defined %}{{ _self.icon(opt.icon_right) }}{% endif %}
</a>
{% endmacro %}

View File

@ -586,7 +586,7 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular.</code></pre>
</div>
<div class="col-md-3">
<h4><code>button(label, url, type, size)</code></h4>
<p>{{ m.button('Label', '#', 'info', 'sm') }}</p>
<p>{{ m.button('Label', '#', {'type': 'info', 'size': 'sm'}) }}</p>
</div>
</div>

View File

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

View File

@ -10,7 +10,7 @@
{{ block('title') }}
{%- if can('faq.edit') -%}
{{ m.button(m.icon('plus-lg'), url('/admin/faq'), 'secondary') }}
{{ m.button(m.icon('plus-lg'), url('/admin/faq')) }}
{%- endif %}
</h1>
@ -54,7 +54,7 @@
{% if can('faq.edit') %}
<span class="ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/faq/' ~ item.id), 'secondary', 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('/admin/faq/' ~ item.id), {'size': 'sm', 'title': __('form.edit')}) }}
</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'), null, 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/messages'), {'size': 'sm', 'title': __('general.back')}) }}
{{ __('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'), null, 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/news'), {'size': 'sm', 'title': __('general.back')}) }}
{{ block('title') }}
</h1>

View File

@ -9,11 +9,11 @@
<div class="container">
<h1>
{% if not is_overview|default(false) %}
{{ m.button(m.icon('chevron-left'), url('/news'), null, 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/news'), {'size': 'sm', 'title': __('general.back')}) }}
{% endif %}
{{ block('title') }}
{%- if can('admin_news') and is_overview|default(false) -%}
{{ m.button(m.icon('plus-lg'), url('/admin/news', only_meetings ? {'meeting': 1} : {}), 'secondary') }}
{{ m.button(m.icon('plus-lg'), url('/admin/news', only_meetings ? {'meeting': 1} : {})) }}
{%- endif %}
</h1>
@ -66,7 +66,7 @@
<div class="card-body bg-body">
{{ news.text(not is_overview)|markdown }}
{% if is_overview and news.text != news.text(false) %}
{{ m.button(__('news.read_more'), url('/news/' ~ news.id), null, 'sm', null, null, 'chevron-double-right') }}
{{ m.button(__('news.read_more'), url('/news/' ~ news.id), {'size': 'sm', 'icon_right': 'chevron-double-right'}) }}
{% endif %}
</div>
@ -99,7 +99,7 @@
{% if can('admin_news') %}
<div class="d-flex ms-auto">
{{ m.button(m.icon('pencil'), url('/admin/news/' ~ news.id), 'secondary', 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('/admin/news/' ~ news.id), {'size': 'sm', 'title': __('form.edit')}) }}
<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'), null, 'sm', __('general.back')) }}
{{ m.button(m.icon('chevron-left'), url('/questions'), {'size': 'sm', 'title': __('general.back')}) }}
{{ block('title') }}
</h1>

View File

@ -36,9 +36,9 @@
<h1>
{{ block('title') }}
{% if is_admin | default(false) %}
{{ m.button(m.icon('question-lg'), url('/faq'), 'secondary', null, __('faq.faq')) }}
{{ m.button(m.icon('question-lg'), url('/faq'), {'title': __('faq.faq')}) }}
{% else %}
{{ m.button(m.icon('plus-lg'), url('/questions/new'), 'secondary') }}
{{ m.button(m.icon('plus-lg'), url('/questions/new')) }}
{% endif %}
</h1>
</div>
@ -85,7 +85,7 @@
<div class="d-flex ms-auto">
{% if can('question.edit') %}
{{ m.button(m.icon('pencil'), url('/admin/questions/' ~ question.id), null, 'sm', __('form.edit')) }}
{{ m.button(m.icon('pencil'), url('/admin/questions/' ~ question.id), {'size': 'sm', 'title': __('form.edit')}) }}
{% endif %}
{% if question.user.id == user.id or can('question.edit') %}

View File

@ -9,7 +9,7 @@
<div class="mb-5">
<h1>
{{ can('admin_user')
? m.button(m.icon('chevron-left'), url('/users'), null, 'sm', __('general.back'))
? m.button(m.icon('chevron-left'), url('/users'), {'size': 'sm', 'title': __('general.back')})
: ''
}}
{{ __('registration.title') }}