add night shift multiplier to translations

more night shift hints
This commit is contained in:
Xu 2024-02-17 22:46:36 +01:00 committed by Igor Scheller
parent d8f8a4f67d
commit 759a4f9a14
6 changed files with 59 additions and 11 deletions

View File

@ -343,7 +343,7 @@ return [
'night_shifts' => [
'enabled' => (bool) env('NIGHT_SHIFTS', true), // Disable to weigh every shift the same
'start' => env('NIGHT_SHIFTS_START', 2),
'end' => env('NIGHT_SHIFTS_END', 6),
'end' => env('NIGHT_SHIFTS_END', 8),
'multiplier' => env('NIGHT_SHIFTS_MULTIPLIER', 2),
],

View File

@ -2,6 +2,8 @@
namespace Engelsystem;
use Engelsystem\Config\GoodieType;
use Engelsystem\Helpers\Shifts;
use Engelsystem\Models\AngelType;
use Engelsystem\Models\Shifts\Shift;
use Engelsystem\Models\Shifts\ShiftEntry;
@ -243,6 +245,10 @@ class ShiftCalendarShiftRenderer
*/
private function renderShiftHead(Shift $shift, $class, $needed_angeltypes_count)
{
$nightShiftsConfig = config('night_shifts');
$goodie = GoodieType::from(config('goodie_type'));
$goodie_enabled = $goodie !== GoodieType::None;
$header_buttons = '';
if (auth()->can('admin_shifts')) {
$header_buttons = div('ms-auto d-print-none d-flex', [
@ -274,9 +280,17 @@ class ShiftCalendarShiftRenderer
], url('/user-shifts', ['delete_shift' => $shift->id])),
]);
}
$shift_heading = $shift->start->format('H:i') . ' ‐ '
$night_shift = '';
if (Shifts::isNightShift($shift->start, $shift->end) && $nightShiftsConfig['enabled'] && $goodie_enabled) {
$night_shift = ' <i class="bi-moon-stars"></i>';
}
$shift_heading = '<span>'
. $shift->start->format('H:i') . ' &dash; '
. $shift->end->format('H:i') . ' &mdash; '
. htmlspecialchars($shift->shiftType->name);
. htmlspecialchars($shift->shiftType->name)
. $night_shift
. '</span>';
if ($needed_angeltypes_count > 0) {
$shift_heading = '<span class="badge bg-light text-danger me-1">' . $needed_angeltypes_count . '</span> ' . $shift_heading;

View File

@ -1,6 +1,8 @@
<?php
use Engelsystem\Config\GoodieType;
use Engelsystem\Helpers\Carbon;
use Engelsystem\Helpers\Shifts;
use Engelsystem\Models\AngelType;
use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\Shift;
@ -155,6 +157,10 @@ function Shift_view(
$user_shift_admin = auth()->can('user_shifts_admin');
$admin_locations = auth()->can('admin_locations');
$admin_shifttypes = auth()->can('shifttypes');
$nightShiftsConfig = config('night_shifts');
$goodie = GoodieType::from(config('goodie_type'));
$goodie_enabled = $goodie !== GoodieType::None;
$goodie_tshirt = $goodie === GoodieType::Tshirt;
$parsedown = new Parsedown();
@ -262,11 +268,22 @@ function Shift_view(
$start = $shift->start->format(__('general.datetime'));
$night_shift_hint = '';
if (Shifts::isNightShift($shift->start, $shift->end) && $nightShiftsConfig['enabled'] && $goodie_enabled) {
$night_shift_hint = ' <small><span class="bi bi-moon-stars text-info" data-bs-toggle="tooltip" title="'
. __('Night shifts between %d and %d am are multiplied by %d for the %s score.', [
$nightShiftsConfig['start'],
$nightShiftsConfig['end'],
$nightShiftsConfig['multiplier'],
($goodie_tshirt ? __('T-shirt') : __('goodie'))])
. '"></span></small>';
}
$link = button(url('/user-shifts'), icon('chevron-left'), 'btn-sm', '', __('general.back'));
return page_with_title(
$link . ' '
. htmlspecialchars($shift->shiftType->name)
. ' <small title="' . $start . '" data-countdown-ts="' . $shift->start->timestamp . '">%c</small>',
. ' <small title="' . $start . '" data-countdown-ts="' . $shift->start->timestamp . '">%c</small>'
. $night_shift_hint,
$content
);
}

View File

@ -2,6 +2,7 @@
use Carbon\Carbon;
use Engelsystem\Config\GoodieType;
use Engelsystem\Helpers\Shifts;
use Engelsystem\Models\AngelType;
use Engelsystem\Models\Group;
use Engelsystem\Models\Shifts\Shift;
@ -309,6 +310,10 @@ function User_view_shiftentries($needed_angel_type)
*/
function User_view_myshift(Shift $shift, $user_source, $its_me)
{
$nightShiftsConfig = config('night_shifts');
$goodie = GoodieType::from(config('goodie_type'));
$goodie_enabled = $goodie !== GoodieType::None;
$shift_info = '<a href="' . shift_link($shift) . '">' . htmlspecialchars($shift->shiftType->name) . '</a>';
if ($shift->title) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . htmlspecialchars($shift->title) . '</a>';
@ -317,12 +322,19 @@ function User_view_myshift(Shift $shift, $user_source, $its_me)
$shift_info .= User_view_shiftentries($needed_angel_type);
}
$night_shift = '';
if (Shifts::isNightShift($shift->start, $shift->end) && $nightShiftsConfig['enabled'] && $goodie_enabled) {
$night_shift = ' <span class="bi bi-moon-stars text-info" data-bs-toggle="tooltip" title="'
. __('Night shift')
. '"></span>';
}
$myshift = [
'date' => icon('calendar-event')
. $shift->start->format(__('general.date')) . '<br>'
. icon('clock-history') . $shift->start->format('H:i')
. ' - '
. $shift->end->format(__('H:i')),
. $shift->end->format(__('H:i'))
. $night_shift,
'duration' => sprintf('%.2f', ($shift->end->timestamp - $shift->start->timestamp) / 3600) . '&nbsp;h',
'location' => location_name_render($shift->location),
'shift_info' => $shift_info,
@ -682,10 +694,11 @@ function User_view(
$myshifts_table,
($its_me && $nightShiftsConfig['enabled'] && $goodie_enabled) ? info(
sprintf(
icon('info-circle') . __('Your night shifts between %d and %d am count twice for the %s score.'),
$nightShiftsConfig['start'],
$nightShiftsConfig['end'],
($goodie_tshirt ? __('T-shirt') : __('goodie'))
icon('moon-stars') . __('Night shifts between %d and %d am are multiplied by %d for the %s score.', [
$nightShiftsConfig['start'],
$nightShiftsConfig['end'],
$nightShiftsConfig['multiplier'],
($goodie_tshirt ? __('T-shirt') : __('goodie'))])
),
true,
true

View File

@ -1226,8 +1226,11 @@ msgstr "iCal Export"
msgid "JSON Export"
msgstr "JSON Export"
msgid "Your night shifts between %d and %d am count twice for the %s score."
msgstr "Deine Nachtschichten zwischen %d und %d Uhr zählen für den %s Score doppelt."
msgid "Night shifts between %d and %d am are multiplied by %d for the %s score."
msgstr "Nachtschichten zwischen %d und %d Uhr werden für den %4$s Score mit %3$d multipliziert."
msgid "Night shifts"
msgstr "Nachtschicht"
msgid ""
"Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some "

View File

@ -210,6 +210,7 @@
logout: {{ m.icon('box-arrow-left') }}<br>
message: {{ m.icon('envelope') }}<br>
next shift: {{ m.icon('clock') }}<br>
night shift: {{ m.icon('moon-stars') }}<br>
occupancy: {{ m.icon('person-fill-slash') }}<br>
password: {{ m.icon('key-fill') }}<br>
phone: {{ m.icon('phone') }}<br>