user shirt edit: finetuning shirt edit view and logs

This commit is contained in:
msquare 2021-10-23 17:02:33 +02:00
parent 5c90a1ef37
commit ca8f851ab1
6 changed files with 26 additions and 25 deletions

View File

@ -228,8 +228,8 @@ function admin_active()
$parameters['show_all_shifts'] = 1; $parameters['show_all_shifts'] = 1;
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('set active'), 'btn-sm', false)], [form_submit('submit', __('set active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parameters) page_link_to('admin_active', $parameters), false, true
); );
} }
if ($usr->state->active) { if ($usr->state->active) {
@ -241,8 +241,8 @@ function admin_active()
$parametersRemove['show_all_shifts'] = 1; $parametersRemove['show_all_shifts'] = 1;
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('remove active'), 'btn-sm', false)], [form_submit('submit', __('remove active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersRemove) page_link_to('admin_active', $parametersRemove), false, true
); );
} }
if (!$usr->state->got_shirt) { if (!$usr->state->got_shirt) {
@ -254,8 +254,8 @@ function admin_active()
$parametersShirt['show_all_shifts'] = 1; $parametersShirt['show_all_shifts'] = 1;
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('got t-shirt'), 'btn-sm', false)], [form_submit('submit', __('got t-shirt'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersShirt) page_link_to('admin_active', $parametersShirt), false, true
); );
} }
if ($usr->state->got_shirt) { if ($usr->state->got_shirt) {
@ -267,12 +267,12 @@ function admin_active()
$parameters['show_all_shifts'] = 1; $parameters['show_all_shifts'] = 1;
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('remove t-shirt'), 'btn-sm', false)], [form_submit('submit', __('remove t-shirt'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parameters) page_link_to('admin_active', $parameters), false, true
); );
} }
$actions[] = button(url('/admin/user/' . $usr->id . '/shirt'), __('form.edit'), 'btn-primary btn-sm'); $actions[] = button(url('/admin/user/' . $usr->id . '/shirt'), __('form.edit'), 'btn-secondary btn-sm');
$userData['actions'] = buttons($actions); $userData['actions'] = buttons($actions);

View File

@ -448,11 +448,13 @@ function form_element($label, $input, $for = '', $class = '')
* @param bool $inline * @param bool $inline
* @return string * @return string
*/ */
function form($elements, $action = '', $inline = false) function form($elements, $action = '', $inline = false, $btnGroup = false)
{ {
return '<form action="' . $action . '" enctype="multipart/form-data" method="post"' . ($inline ? ' style="float:left"' : '') . '>' return '<form action="' . $action . '" enctype="multipart/form-data" method="post"'
. form_csrf() . ($btnGroup ? ' class="btn-group"' : '')
. ($inline ? ' style="float:left"' : '') . '>'
. join($elements) . join($elements)
. form_csrf()
. '</form>'; . '</form>';
} }

View File

@ -58,7 +58,7 @@ msgid "form.save"
msgstr "Save" msgstr "Save"
msgid "form.edit" msgid "form.edit"
msgstr "Bearbeiten" msgstr "Edit"
msgid "form.preview" msgid "form.preview"
msgstr "Preview" msgstr "Preview"

View File

@ -14,20 +14,18 @@
{{ csrf() }} {{ csrf() }}
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-12">
{{ f.select('shirt_size', config('tshirt_sizes'), __('user.shirt_size'), userdata.personalData.shirt_size) }} {{ f.select('shirt_size', config('tshirt_sizes'), __('user.shirt_size'), userdata.personalData.shirt_size) }}
</div> </div>
<div class="col-md-8"> <div class="col-md-12">
{% if has_permission_to('admin_arrive') %} {{ f.switch('arrived', __('user.arrived'), userdata.state.arrived, {'disabled': not has_permission_to('admin_arrive')}) }}
{{ f.switch('arrived', __('user.arrived'), userdata.state.arrived) }}
{% endif %}
{% if userdata.state.force_active %} {% if userdata.state.force_active %}
{{ f.switch('force_active', __('user.force_active'), true, {'disabled': true}) }} {{ f.switch('force_active', __('user.force_active'), true, {'disabled': true}) }}
{% else %}
{{ f.switch('active', __('user.active'), userdata.state.active) }}
{% endif %} {% endif %}
{{ f.switch('active', __('user.active'), userdata.state.active) }}
{{ f.switch('got_shirt', __('user.got_shirt'), userdata.state.got_shirt) }} {{ f.switch('got_shirt', __('user.got_shirt'), userdata.state.got_shirt) }}
</div> </div>
<div class="col-md-12"> <div class="col-md-12">

View File

@ -51,7 +51,7 @@
{%- endmacro %} {%- endmacro %}
{% macro checkbox(name, label, checked, value, disabled) %} {% macro checkbox(name, label, checked, value, disabled) %}
<div class="form-check"> <div class="form-check mb-3">
<label> <label>
<input type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}" class="form-check-input" <input type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}" class="form-check-input"
{%- if checked|default(false) %} checked{% endif %} {%- if checked|default(false) %} checked{% endif %}
@ -84,7 +84,7 @@
{%- endmacro %} {%- endmacro %}
{% macro switch(name, label, checked, opt) %} {% macro switch(name, label, checked, opt) %}
<div class="form-check form-switch"> <div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ opt.value|default('1') }}" <input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ opt.value|default('1') }}"
{%- if checked|default(false) %} checked{% endif %} {%- if checked|default(false) %} checked{% endif %}
{%- if opt.disabled|default(false) %} disabled{% endif %} {%- if opt.disabled|default(false) %} disabled{% endif %}

View File

@ -112,13 +112,14 @@ class UserShirtController extends BaseController
$user->state->save(); $user->state->save();
$this->log->info( $this->log->info(
'Updated user shirt state "{user}" ({id}): {size}, arrived: {arrived}, got shirt: {got_shirt}', 'Updated user shirt state "{user}" ({id}): {size}, arrived: {arrived}, active: {active}, got shirt: {got_shirt}',
[ [
'id' => $user->id, 'id' => $user->id,
'user' => $user->name, 'user' => $user->name,
'size' => $user->personalData->shirt_size, 'size' => $user->personalData->shirt_size,
'arrived' => $user->state->arrived, 'arrived' => $user->state->arrived ? 'yes' : 'no',
'got_shirt' => $user->state->got_shirt 'active' => $user->state->active ? 'yes' : 'no',
'got_shirt' => $user->state->got_shirt ? 'yes' : 'no'
] ]
); );