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;
}
$actions[] = form(
[form_submit('submit', __('set active'), 'btn-sm', false)],
page_link_to('admin_active', $parameters)
[form_submit('submit', __('set active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parameters), false, true
);
}
if ($usr->state->active) {
@ -241,8 +241,8 @@ function admin_active()
$parametersRemove['show_all_shifts'] = 1;
}
$actions[] = form(
[form_submit('submit', __('remove active'), 'btn-sm', false)],
page_link_to('admin_active', $parametersRemove)
[form_submit('submit', __('remove active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersRemove), false, true
);
}
if (!$usr->state->got_shirt) {
@ -254,8 +254,8 @@ function admin_active()
$parametersShirt['show_all_shifts'] = 1;
}
$actions[] = form(
[form_submit('submit', __('got t-shirt'), 'btn-sm', false)],
page_link_to('admin_active', $parametersShirt)
[form_submit('submit', __('got t-shirt'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersShirt), false, true
);
}
if ($usr->state->got_shirt) {
@ -267,12 +267,12 @@ function admin_active()
$parameters['show_all_shifts'] = 1;
}
$actions[] = form(
[form_submit('submit', __('remove t-shirt'), 'btn-sm', false)],
page_link_to('admin_active', $parameters)
[form_submit('submit', __('remove t-shirt'), 'btn-sm', false, 'secondary')],
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);

View File

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

View File

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

View File

@ -14,19 +14,17 @@
{{ csrf() }}
<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) }}
</div>
<div class="col-md-8">
{% if has_permission_to('admin_arrive') %}
{{ f.switch('arrived', __('user.arrived'), userdata.state.arrived) }}
{% endif %}
<div class="col-md-12">
{{ f.switch('arrived', __('user.arrived'), userdata.state.arrived, {'disabled': not has_permission_to('admin_arrive')}) }}
{% if userdata.state.force_active %}
{{ f.switch('force_active', __('user.force_active'), true, {'disabled': true}) }}
{% endif %}
{% else %}
{{ f.switch('active', __('user.active'), userdata.state.active) }}
{% endif %}
{{ f.switch('got_shirt', __('user.got_shirt'), userdata.state.got_shirt) }}
</div>

View File

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

View File

@ -112,13 +112,14 @@ class UserShirtController extends BaseController
$user->state->save();
$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,
'user' => $user->name,
'size' => $user->personalData->shirt_size,
'arrived' => $user->state->arrived,
'got_shirt' => $user->state->got_shirt
'arrived' => $user->state->arrived ? 'yes' : 'no',
'active' => $user->state->active ? 'yes' : 'no',
'got_shirt' => $user->state->got_shirt ? 'yes' : 'no'
]
);