refactor user info icon
This commit is contained in:
parent
8cff7aa205
commit
7637e0c66e
|
@ -226,15 +226,7 @@ function admin_active()
|
|||
$shirtSize = $usr->personalData->shirt_size;
|
||||
$userData = [];
|
||||
$userData['no'] = count($matched_users) + 1;
|
||||
$userData['nick'] = User_Nick_render($usr) . User_Pronoun_render($usr);
|
||||
if ($usr->state->user_info) {
|
||||
$userData['nick'] .=
|
||||
' <small><span class="bi bi-info-circle-fill text-info"'
|
||||
. (auth()->can('user.info.show')
|
||||
? (' data-bs-toggle="tooltip" title="' . htmlspecialchars($usr->state->user_info) . '"')
|
||||
: '')
|
||||
. '></span></small>';
|
||||
}
|
||||
$userData['nick'] = User_Nick_render($usr) . User_Pronoun_render($usr) . user_info_icon($usr);
|
||||
if ($goodie_tshirt) {
|
||||
$userData['shirt_size'] = (isset($tshirt_sizes[$shirtSize]) ? $tshirt_sizes[$shirtSize] : '');
|
||||
}
|
||||
|
|
|
@ -100,9 +100,7 @@ function admin_arrive()
|
|||
|
||||
$usr->name = User_Nick_render($usr)
|
||||
. User_Pronoun_render($usr)
|
||||
. ($usr->state->user_info
|
||||
? ' <small><span class="bi bi-info-circle-fill text-info"></span></small>'
|
||||
: '');
|
||||
. user_info_icon($usr);
|
||||
$plannedDepartureDate = $usr->personalData->planned_departure_date;
|
||||
$arrivalDate = $usr->state->arrival_date;
|
||||
$plannedArrivalDate = $usr->personalData->planned_arrival_date;
|
||||
|
|
|
@ -99,9 +99,7 @@ function admin_free()
|
|||
$free_users_table[] = [
|
||||
'name' => User_Nick_render($usr)
|
||||
. User_Pronoun_render($usr)
|
||||
. ($usr->state->user_info
|
||||
? ' <small><span class="bi bi-info-circle-fill text-info"></span></small>'
|
||||
: ''),
|
||||
. user_info_icon($usr),
|
||||
'shift_state' => User_shift_state_render($usr),
|
||||
'last_shift' => User_last_shift_render($usr),
|
||||
'dect' => sprintf('<a href="tel:%s">%1$s</a>', htmlspecialchars((string) $usr->contact->dect)),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Engelsystem\Models\User\User;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
|
@ -421,3 +422,16 @@ function table_buttons($buttons = [], $additionalClass = '')
|
|||
{
|
||||
return '<div class="btn-group ' . $additionalClass . '" role="group">' . join('', $buttons) . '</div>';
|
||||
}
|
||||
|
||||
function user_info_icon(User $user): string
|
||||
{
|
||||
if (!auth()->can('admin_arrive') || !$user->state->user_info) {
|
||||
return '';
|
||||
}
|
||||
$infoIcon = ' <small><span class="bi bi-info-circle-fill text-info" ';
|
||||
if (auth()->can('user.info.show')) {
|
||||
$infoIcon .= 'data-bs-toggle="tooltip" title="' . htmlspecialchars($user->state->user_info) . '"';
|
||||
}
|
||||
$infoIcon .= '></span></small>';
|
||||
return $infoIcon;
|
||||
}
|
||||
|
|
|
@ -92,9 +92,7 @@ function Users_view(
|
|||
$u = [];
|
||||
$u['name'] = User_Nick_render($user)
|
||||
. User_Pronoun_render($user)
|
||||
. ($user->state->user_info
|
||||
? ' <small><span class="bi bi-info-circle-fill text-info"></span></small>'
|
||||
: '');
|
||||
. user_info_icon($user);
|
||||
$u['first_name'] = htmlspecialchars((string) $user->personalData->first_name);
|
||||
$u['last_name'] = htmlspecialchars((string) $user->personalData->last_name);
|
||||
$u['dect'] = sprintf('<a href="tel:%s">%1$s</a>', htmlspecialchars((string) $user->contact->dect));
|
||||
|
@ -542,7 +540,6 @@ function User_view(
|
|||
$nightShiftsConfig = config('night_shifts');
|
||||
$user_name = htmlspecialchars((string) $user_source->personalData->first_name) . ' '
|
||||
. htmlspecialchars((string) $user_source->personalData->last_name);
|
||||
$user_info_show = auth()->can('user.info.show');
|
||||
$myshifts_table = '';
|
||||
if ($its_me || $admin_user_privilege || $tshirt_admin) {
|
||||
$my_shifts = User_view_myshifts(
|
||||
|
@ -590,17 +587,7 @@ function User_view(
|
|||
)
|
||||
. htmlspecialchars($user_source->name)
|
||||
. (config('enable_user_name') ? ' <small>' . $user_name . '</small>' : '')
|
||||
. (
|
||||
(($user_info_show || auth()->can('admin_arrive')) && $user_source->state->user_info)
|
||||
? (
|
||||
' <small><span class="bi bi-info-circle-fill text-info" '
|
||||
. ($user_info_show
|
||||
? 'data-bs-toggle="tooltip" title="' . htmlspecialchars($user_source->state->user_info)
|
||||
: '')
|
||||
. '"></span></small>'
|
||||
)
|
||||
: ''
|
||||
),
|
||||
. user_info_icon($user_source),
|
||||
[
|
||||
msg(),
|
||||
div('row', [
|
||||
|
|
Loading…
Reference in New Issue