back buttons on edit and deletion pages

This commit is contained in:
Xu 2023-10-25 17:38:23 +02:00 committed by Igor Scheller
parent 185b7e3fb6
commit 89321306bc
15 changed files with 267 additions and 204 deletions

View File

@ -199,8 +199,9 @@ function shift_edit_controller()
);
}
$link = button(page_link_to('user-shifts'), icon('chevron-left'), 'btn-sm');
return page_with_title(
shifts_title(),
$link . ' ' . shifts_title(),
[
msg(),
'<noscript>'
@ -270,18 +271,22 @@ function shift_delete_controller()
throw_redirect(page_link_to('user_shifts'));
}
return page_with_title(shifts_title(), [
error(sprintf(
__('Do you want to delete the shift %s from %s to %s?'),
$shift->shiftType->name,
$shift->start->format(__('Y-m-d H:i')),
$shift->end->format(__('H:i'))
), true),
form([
form_hidden('delete_shift', $shift->id),
form_submit('delete', __('delete')),
]),
]);
$link = button(page_link_to('user-shifts'), icon('chevron-left'), 'btn-sm');
return page_with_title(
$link . ' ' . shifts_title(),
[
error(sprintf(
__('Do you want to delete the shift %s from %s to %s?'),
$shift->shiftType->name,
$shift->start->format(__('Y-m-d H:i')),
$shift->end->format(__('H:i'))
), true),
form([
form_hidden('delete_shift', $shift->id),
form_submit('delete', __('delete')),
]),
]
);
}
/**

View File

@ -453,8 +453,9 @@ function admin_shifts()
. '</div>';
}
$link = button(page_link_to('user-shifts'), icon('chevron-left'), 'btn-sm');
return page_with_title(
admin_shifts_title() . ' ' . sprintf(
$link . ' ' . admin_shifts_title() . ' ' . sprintf(
'<a href="%s">%s</a>',
page_link_to('admin_shifts_history'),
icon('clock-history')

View File

@ -303,9 +303,13 @@ function admin_user()
}
}
return page_with_title(__('Edit user'), [
$link = button(page_link_to('users', ['action' => 'view', 'user_id' => $user_id]), icon('chevron-left'), 'btn-sm');
return page_with_title(
$link . ' ' . __('Edit user'),
[
$html,
]);
]
);
}
/**

View File

@ -80,85 +80,91 @@ function AngelType_delete_view(AngelType $angeltype)
*/
function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
{
return page_with_title(sprintf(__('Edit %s'), $angeltype->name), [
buttons([
button(page_link_to('angeltypes'), icon('person-lines-fill') . __('angeltypes.angeltypes'), 'back'),
]),
msg(),
form([
$supporter_mode
? form_info(__('general.name'), $angeltype->name)
: form_text('name', __('general.name'), $angeltype->name),
$supporter_mode
? form_info(__('angeltypes.restricted'), $angeltype->restricted ? __('Yes') : __('No'))
: form_checkbox(
'restricted',
__('angeltypes.restricted') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.restricted.info') . '"></span>',
$angeltype->restricted
),
$supporter_mode
? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No'))
: form_checkbox(
'shift_self_signup',
__('shift.self_signup') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.shift.self_signup.info') . '"></span>',
$angeltype->shift_self_signup
),
$supporter_mode ?
$link = button($angeltype->id
? page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id])
: page_link_to('angeltypes'), icon('chevron-left'), 'btn-sm');
return page_with_title(
$link . ' ' . sprintf(__('Edit %s'), $angeltype->name),
[
buttons([
button(page_link_to('angeltypes'), icon('person-lines-fill') . __('angeltypes.angeltypes'), 'back'),
]),
msg(),
form([
$supporter_mode
? form_info(__('general.name'), $angeltype->name)
: form_text('name', __('general.name'), $angeltype->name),
$supporter_mode
? form_info(__('angeltypes.restricted'), $angeltype->restricted ? __('Yes') : __('No'))
: form_checkbox(
'restricted',
__('angeltypes.restricted') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.restricted.info') . '"></span>',
$angeltype->restricted
),
$supporter_mode
? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No'))
: form_checkbox(
'shift_self_signup',
__('shift.self_signup') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.shift.self_signup.info') . '"></span>',
$angeltype->shift_self_signup
),
$supporter_mode ?
form_info(
__('Requires driver license'),
$angeltype->requires_driver_license
? __('Yes')
: __('No')
) :
form_checkbox(
'requires_driver_license',
__('Requires driver license'),
$angeltype->requires_driver_license
),
$supporter_mode && config('ifsg_enabled') ?
form_info(
__('angeltype.ifsg.required'),
$angeltype->requires_ifsg_certificate
? __('Yes')
: __('No')
) :
form_checkbox(
'requires_ifsg_certificate',
__('angeltype.ifsg.required'),
$angeltype->requires_ifsg_certificate
),
$supporter_mode
? form_info(__('Show on dashboard'), $angeltype->show_on_dashboard ? __('Yes') : __('No'))
: form_checkbox('show_on_dashboard', __('Show on dashboard'), $angeltype->show_on_dashboard),
$supporter_mode
? form_info(__('Hide at Registration'), $angeltype->hide_register ? __('Yes') : __('No'))
: form_checkbox('hide_register', __('Hide at Registration'), $angeltype->hide_register),
$supporter_mode
? form_info(__('angeltypes.hide_on_shift_view'), $angeltype->hide_on_shift_view ? __('Yes') : __('No'))
: form_checkbox(
'hide_on_shift_view',
__('angeltypes.hide_on_shift_view') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.hide_on_shift_view.info') . '"></span>',
$angeltype->hide_on_shift_view
),
form_textarea('description', __('general.description'), $angeltype->description),
form_info('', __('Please use markdown for the description.')),
heading(__('Contact'), 3),
form_info(
__('Requires driver license'),
$angeltype->requires_driver_license
? __('Yes')
: __('No')
) :
form_checkbox(
'requires_driver_license',
__('Requires driver license'),
$angeltype->requires_driver_license
'',
__('Primary contact person/desk for user questions.')
),
$supporter_mode && config('ifsg_enabled') ?
form_info(
__('angeltype.ifsg.required'),
$angeltype->requires_ifsg_certificate
? __('Yes')
: __('No')
) :
form_checkbox(
'requires_ifsg_certificate',
__('angeltype.ifsg.required'),
$angeltype->requires_ifsg_certificate
),
$supporter_mode
? form_info(__('Show on dashboard'), $angeltype->show_on_dashboard ? __('Yes') : __('No'))
: form_checkbox('show_on_dashboard', __('Show on dashboard'), $angeltype->show_on_dashboard),
$supporter_mode
? form_info(__('Hide at Registration'), $angeltype->hide_register ? __('Yes') : __('No'))
: form_checkbox('hide_register', __('Hide at Registration'), $angeltype->hide_register),
$supporter_mode
? form_info(__('angeltypes.hide_on_shift_view'), $angeltype->hide_on_shift_view ? __('Yes') : __('No'))
: form_checkbox(
'hide_on_shift_view',
__('angeltypes.hide_on_shift_view') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.hide_on_shift_view.info') . '"></span>',
$angeltype->hide_on_shift_view
),
form_textarea('description', __('general.description'), $angeltype->description),
form_info('', __('Please use markdown for the description.')),
heading(__('Contact'), 3),
form_info(
'',
__('Primary contact person/desk for user questions.')
),
form_text('contact_name', __('general.name'), $angeltype->contact_name),
config('enable_dect') ? form_text('contact_dect', __('general.dect'), $angeltype->contact_dect) : '',
form_text('contact_email', __('general.email'), $angeltype->contact_email),
form_submit('submit', __('form.save')),
]),
]);
form_text('contact_name', __('general.name'), $angeltype->contact_name),
config('enable_dect') ? form_text('contact_dect', __('general.dect'), $angeltype->contact_dect) : '',
form_text('contact_email', __('general.email'), $angeltype->contact_email),
form_submit('submit', __('form.save')),
]),
]
);
}
/**
@ -422,24 +428,28 @@ function AngelType_view(
ShiftCalendarRenderer $shiftCalendarRenderer,
$tab
) {
return page_with_title(sprintf(__('Team %s'), $angeltype->name), [
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
msg(),
tabs([
__('Info') => AngelType_view_info(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes,
$supporter
),
__('Shifts') => AngelType_view_shifts(
$angeltype,
$shiftsFilterRenderer,
$shiftCalendarRenderer
),
], $tab),
], true);
return page_with_title(
sprintf(__('Team %s'), $angeltype->name),
[
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
msg(),
tabs([
__('Info') => AngelType_view_info(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes,
$supporter
),
__('Shifts') => AngelType_view_shifts(
$angeltype,
$shiftsFilterRenderer,
$shiftCalendarRenderer
),
], $tab),
],
true
);
}
/**

View File

@ -213,17 +213,25 @@ function ShiftEntry_edit_view(
$comment = '';
}
return page_with_title(__('Edit shift entry'), [
msg(),
form([
form_info(__('Angel:'), User_Nick_render($angel)),
form_info(__('Date, Duration:'), $date),
form_info(__('Location:'), $location),
form_info(__('Title:'), $title),
form_info(__('Type:'), $type),
$comment,
join('', $freeload_form),
form_submit('submit', __('form.save')),
]),
]);
$link = button(
page_link_to('users', ['action' => 'view', 'user_id' => $angel->id]),
icon('chevron-left'),
'btn-sm'
);
return page_with_title(
$link . ' ' . __('Edit shift entry'),
[
msg(),
form([
form_info(__('Angel:'), User_Nick_render($angel)),
form_info(__('Date, Duration:'), $date),
form_info(__('Location:'), $location),
form_info(__('Title:'), $title),
form_info(__('Type:'), $type),
$comment,
join('', $freeload_form),
form_submit('submit', __('form.save')),
]),
]
);
}

View File

@ -45,18 +45,28 @@ function ShiftType_delete_view(ShiftType $shifttype)
*/
function ShiftType_edit_view($name, $description, $shifttype_id)
{
return page_with_title($shifttype_id ? __('Edit shifttype') : __('Create shifttype'), [
msg(),
buttons([
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
]),
form([
form_text('name', __('general.name'), $name),
form_textarea('description', __('general.description'), $description),
form_info('', __('Please use markdown for the description.')),
form_submit('submit', __('form.save')),
]),
], true);
return page_with_title(
$shifttype_id
? (button(
page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype_id]),
icon('chevron-left'),
'btn-sm'
) . ' ' . __('Edit shifttype'))
: (button(page_link_to('shifttypes'), icon('chevron-left'), 'btn-sm') . ' ' . __('Create shifttype')),
[
msg(),
buttons([
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
]),
form([
form_text('name', __('general.name'), $name),
form_textarea('description', __('general.description'), $description),
form_info('', __('Please use markdown for the description.')),
form_submit('submit', __('form.save')),
]),
],
true
);
}
/**

View File

@ -12,44 +12,46 @@ use Engelsystem\Models\User\User;
*/
function UserDriverLicense_edit_view($user_source, $user_driver_license)
{
return page_with_title(sprintf(__('Edit %s driving license information'), User_Nick_render($user_source)), [
buttons([
button(user_link($user_source->id), __('Back to profile'), 'back'),
]),
msg(),
form([
form_info(__('Privacy'), __('Your driving license information is only visible for supporters and admins.')),
form_checkbox('wants_to_drive', __('I am willing to drive a car for the event'), $user_driver_license->wantsToDrive()),
div('m-3', [
form_checkbox(
'has_car',
__('I have my own car with me and am willing to use it for the event (You\'ll get reimbursed for fuel)'),
$user_driver_license->has_car
),
heading(__('driving license'), 3),
form_checkbox('has_license_car', __('Car'), $user_driver_license->drive_car),
form_checkbox(
'has_license_3_5t_transporter',
__('3.5t Transporter'),
$user_driver_license->drive_3_5t
),
form_checkbox(
'has_license_7_5t_truck',
__('7.5t Truck'),
$user_driver_license->drive_7_5t
),
form_checkbox(
'has_license_12t_truck',
__('12t Truck'),
$user_driver_license->drive_12t
),
form_checkbox(
'has_license_forklift',
__('Forklift'),
$user_driver_license->drive_forklift
),
], 'driving_license'),
form_submit('submit', __('form.save')),
]),
], true);
$link = button(user_link($user_source->id), icon('chevron-left'), 'btn-sm');
return page_with_title(
$link . ' ' . sprintf(__('Edit %s driving license information'), User_Nick_render($user_source)),
[
msg(),
form([
form_info(__('Privacy'), __('Your driving license information is only visible for supporters and admins.')),
form_checkbox('wants_to_drive', __('I am willing to drive a car for the event'), $user_driver_license->wantsToDrive()),
div('m-3', [
form_checkbox(
'has_car',
__('I have my own car with me and am willing to use it for the event (You\'ll get reimbursed for fuel)'),
$user_driver_license->has_car
),
heading(__('driving license'), 3),
form_checkbox('has_license_car', __('Car'), $user_driver_license->drive_car),
form_checkbox(
'has_license_3_5t_transporter',
__('3.5t Transporter'),
$user_driver_license->drive_3_5t
),
form_checkbox(
'has_license_7_5t_truck',
__('7.5t Truck'),
$user_driver_license->drive_7_5t
),
form_checkbox(
'has_license_12t_truck',
__('12t Truck'),
$user_driver_license->drive_12t
),
form_checkbox(
'has_license_forklift',
__('Forklift'),
$user_driver_license->drive_forklift
),
], 'driving_license'),
form_submit('submit', __('form.save')),
]),
],
true
);
}

View File

@ -43,25 +43,26 @@ function User_delete_view($user)
*/
function User_edit_vouchers_view($user)
{
return page_with_title(sprintf(__('%s\'s vouchers'), User_Nick_render($user)), [
msg(),
buttons([
button(user_link($user->id), icon('chevron-left') . __('back')),
]),
info(sprintf(
$user->state->force_active
? __('Angel can receive another %d vouchers and is FA.')
: __('Angel can receive another %d vouchers.'),
User_get_eligable_voucher_count($user)
), true),
form(
[
form_spinner('vouchers', __('Number of vouchers given out'), $user->state->got_voucher),
form_submit('submit', __('form.save')),
],
page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user->id])
),
]);
$link = button(user_link($user->id), icon('chevron-left'), 'btn-sm');
return page_with_title(
$link . ' ' . sprintf(__('%s\'s vouchers'), User_Nick_render($user)),
[
msg(),
info(sprintf(
$user->state->force_active
? __('Angel can receive another %d vouchers and is FA.')
: __('Angel can receive another %d vouchers.'),
User_get_eligable_voucher_count($user)
), true),
form(
[
form_spinner('vouchers', __('Number of vouchers given out'), $user->state->got_voucher),
form_submit('submit', __('form.save')),
],
page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user->id])
),
]
);
}
/**

View File

@ -7,6 +7,10 @@
{% block content %}
<div class="container">
<h1>
{% if not is_index|default(false) %}
{{ m.button(m.icon('chevron-left'), room ? url('/rooms', {'action': 'view', 'room_id': room.id}) : url('/admin/rooms'), 'secondary', 'sm') }}
{% endif %}
{{ block('title') }}
{% if is_index|default(false) %}

View File

@ -8,7 +8,10 @@
{% block content %}
<div class="container">
<h1>{{ block('title') }}: <small>{{ m.user(userdata) }}</small></h1>
<h1>
{{ m.button(m.icon('chevron-left'), url('/admin-active'), null, 'sm') }}
{{ block('title') }}: <small>{{ m.user(userdata) }}</small>
</h1>
{% include 'layouts/parts/messages.twig' %}

View File

@ -6,16 +6,16 @@
{% block content %}
<div class="container">
<h1>{{ block('title') }}</h1>
<h1>
{{ m.button(m.icon('chevron-left'), url('/users', {action: 'view', user_id: user.id}), null, 'sm') }}
{{ block('title') }}
</h1>
{% include 'layouts/parts/messages.twig' %}
<form method="post">
{{ csrf() }}
<div class="row g-2">
<div class="col-12">
{{ m.button(__('back'), url('/users', {action: 'view', user_id: user.id})) }}
</div>
<div class="col-12">
<div>
<label class="form-label">{{ __('User') }}</label>

View File

@ -6,7 +6,10 @@
{% block content %}
<div class="container">
<h1>{{ block('title') }}</h1>
<h1>
{{ m.button(m.icon('chevron-left'), url('/faq'), 'secondary', 'sm') }}
{{ block('title') }}
</h1>
{% include 'layouts/parts/messages.twig' %}

View File

@ -6,7 +6,10 @@
{% block content %}
<div class="container">
<h1>{{ block('title') }}</h1>
<h1>
{{ m.button(m.icon('chevron-left'), url('/news'), null, 'sm') }}
{{ block('title') }}
</h1>
{% include 'layouts/parts/messages.twig' %}

View File

@ -6,7 +6,10 @@
{% block content %}
<div class="container">
<h1>{{ block('title') }}</h1>
<h1>
{{ m.button(m.icon('chevron-left'), url('/questions'), null, 'sm') }}
{{ block('title') }}
</h1>
{% include 'layouts/parts/messages.twig' %}

View File

@ -7,7 +7,13 @@
{% block content %}
<div class="container">
<div class="mb-5">
<h1>{{ __('page.sign-up.title') }}</h1>
<h1>
{{ has_permission_to('admin_user')
? m.button(m.icon('chevron-left'), url('/users'), null, 'sm')
: ''
}}
{{ __('page.sign-up.title') }}
</h1>
</div>
{% include 'layouts/parts/messages.twig' %}