Merge branch 'issue-83' into 'develop'

fix: 🐛 respond button is now displayed

See merge request ldc-web/projets/support-web!102
This commit is contained in:
Vincent BRIDIER 2025-05-12 09:39:59 +00:00
commit 420947f8e0
3 changed files with 159 additions and 146 deletions

View file

@ -284,7 +284,11 @@ class TicketPolicy
public function createGitlabIssue(User $user, Ticket $ticket)
{
return $user->role->equals(RoleEnum::developper)
&& ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution) || $ticket->type->equals(TicketTypeEnum::newsletter))
&& (
$ticket->type->equals(TicketTypeEnum::bug)
|| $ticket->type->equals(TicketTypeEnum::evolution)
|| $ticket->type->equals(TicketTypeEnum::newsletter)
)
&& !\is_null($ticket->site->gitlab_project_id)
&& \is_null($ticket->gitlab_issue);
}
@ -293,12 +297,11 @@ class TicketPolicy
* Determine if the user can changeOrder
*
* @param User $user
* @return bool
* @throws Error
* @return boolean
* @throws Error The error.
*/
public function changeOrder(User $user)
{
return $user->role->equals(RoleEnum::developper);
}
}

View file

@ -21,7 +21,7 @@
$projectManager = \App\Models\Site::query()->find(session('tickets.pr'))->projectManager;
@endphp
@if($projectManager)
<h2>{{ __("Chef de projet") }} : {{ $projectManager->name; }}</h2>
<h2>{{ __("Chef de projet") }} : {{ $projectManager->name }}</h2>
@endif
@endif
</div>

View file

@ -89,168 +89,177 @@
</div>
</div>
@can('assignLabels', App\Models\Ticket::class)
<div class="row">
<div class="col">
@foreach ($ticket->labels as $label)
<span class="badge label colorize" data-color="{{ $label->color }}">{{ $label->name }}</span>
@endforeach
</div>
<div class="row">
<div class="col">
@foreach ($ticket->labels as $label)
<span class="badge label colorize" data-color="{{ $label->color }}">{{ $label->name }}</span>
@endforeach
</div>
</div>
@endcan
<hr>
@if ($ticket->estimation)
@include('estimations.pendingCard', ['ticket' => $ticket, 'estimation' => $ticket->estimation])
<hr>
@include('estimations.pendingCard', ['ticket' => $ticket, 'estimation' => $ticket->estimation])
<hr>
@endif
<div>
<h4>
<div class="d-flex justify-content-between mb-3">
@if ($ticket->site->projectManager)
<h4>
{{ __("Chef de projet") }} : {{ $ticket->site->projectManager->name }}
</h4>
@endif
@can('createMessage', $ticket)
<div class="d-flex">
@can('estimate', $ticket)
<a class="btn btn-sm btn-info float-end mx-1"
href="{{ route('bo.ticket.estimation.estimate', $ticket) }}">{{ __('Estimation') }}</a>
@endcan
@can('createMessage', $ticket)
<button class="btn btn-sm btn-primary float-end mx-1" data-bs-toggle="modal" data-bs-target="#messageModal" type="button">
{{ __('Répondre') }}
</button>
<div class="modal fade" id="messageModal" aria-labelledby="messageModalLabel" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.create', $ticket) }}" method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Répondre au ticket n°:ticketId', ['ticketId' => $ticket->id]) }} <span
class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
</h5>
<button class="btn btn-sm btn-primary bg-primary" data-bs-dismiss="modal" type="button" aria-label="Close">
<i class="fa-solid fa-xmark text-white"></i>
</button>
@endcan
</div>
</div>
{{-- if the user can create message, the modal is displayed --}}
@can('createMessage', $ticket)
<div class="modal fade" id="messageModal" aria-labelledby="messageModalLabel" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.create', $ticket) }}" method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Répondre au ticket n°:ticketId', ['ticketId' => $ticket->id]) }}
<span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
</h5>
<button class="btn btn-sm btn-primary bg-primary" data-bs-dismiss="modal" type="button" aria-label="Close">
<i class="fa-solid fa-xmark text-white"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10"></textarea>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10"></textarea>
</div>
</div>
@for ($i = 1; $i < 4; $i++)
<div class="row mt-4">
<div class="col">
<h4>Fichier joint {{ $i }}</h4>
<input class="form-control" name="file_messages[]" type="file"
accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
</div>
</div>
@endfor
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="subscribeResponse" name="subscribe" type="checkbox"
value="1" autocomplete="off" @if ($isSubscribed) checked @endif>
<label class="form-check-label" for="subscribeResponse">{{ __('Suivre le ticket') }}</label>
</div>
</div>
</div>
@can('createPrivateMessage', $ticket)
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="setPrivate" name="is_private" type="checkbox"
value="{{ \App\Enums\MessageTypeEnum::private }}" autocomplete="off">
<label class="form-check-label" for="setPrivate">{{ __('Rendre le message privé') }}</label>
</div>
</div>
</div>
@endif
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal" type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
@for ($i = 1; $i < 4; $i++)
<div class="row mt-4">
<div class="col">
<h4>Fichier joint {{ $i }}</h4>
<input class="form-control" name="file_messages[]" type="file"
accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
</div>
</div>
@endfor
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="subscribeResponse" name="subscribe" type="checkbox"
value="1" autocomplete="off" @if ($isSubscribed) checked @endif>
<label class="form-check-label" for="subscribeResponse">{{ __('Suivre le ticket') }}</label>
</div>
</div>
</div>
@can('createPrivateMessage', $ticket)
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="setPrivate" name="is_private" type="checkbox"
value="{{ \App\Enums\MessageTypeEnum::private }}" autocomplete="off">
<label class="form-check-label" for="setPrivate">{{ __('Rendre le message privé') }}</label>
</div>
</div>
</div>
@endcan
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal" type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
</div>
@endcan
{{-- modal end --}}
{{-- Section to display the messages --}}
@foreach ($messages as $message)
@if ($message->type->equals(\App\Enums\MessageTypeEnum::public) || Auth::user()->can('createPrivateMessage', $ticket))
@if ($message->user_id === null)
<div class="offset-md-3 col-md-6 alert alert-info text-dark text-center">
{!! nl2br(clean($message->message)) !!} - <span class="fw-bold text-light">Le
{{ \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i') }}</span>
<small class="fw-bold">({{ __('Message système') }})</small>
</div>
@endcan
@can('estimate', $ticket)
<a class="btn btn-sm btn-info float-end mx-1"
href="{{ route('bo.ticket.estimation.estimate', $ticket) }}">{{ __('Estimation') }}</a>
@endcan
</h4>
@foreach ($messages as $message)
@if ($message->type->equals(\App\Enums\MessageTypeEnum::public) || Auth::user()->can('createPrivateMessage', $ticket))
@if ($message->user_id === null)
<div class="offset-md-3 col-md-6 alert alert-info text-dark text-center">
{!! nl2br(clean($message->message)) !!} - <span class="fw-bold text-light">Le
{{ \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i') }}</span>
<small class="fw-bold">({{ __('Message système') }})</small>
</div>
@else
<div
class="@if ($message->user_id === Auth::user()->id) offset-md-4 alert-dark @else alert-light @endif @if ($message->type->equals(\App\Enums\MessageTypeEnum::private)) border border-danger border-2 @endif col-md-8 alert">
@if ($message->type->equals(\App\Enums\MessageTypeEnum::private))
<i class="fa-solid fa-lock"></i>&nbsp;&nbsp;
@else
<div
class="@if ($message->user_id === Auth::user()->id) offset-md-4 alert-dark @else alert-light @endif @if ($message->type->equals(\App\Enums\MessageTypeEnum::private)) border border-danger border-2 @endif col-md-8 alert">
@if ($message->type->equals(\App\Enums\MessageTypeEnum::private))
<i class="fa-solid fa-lock"></i>&nbsp;&nbsp;
@endif
{!! \App\Lib\Helpers\ToolboxHelper::plainToHtml($message->message) !!}
@foreach ([$message->file, $message->file2, $message->file3] as $file)
@if ($file !== null)
<br><a href="{{ asset($file) }}" target="_blank">Ouvrir la pièce jointe</a>
@endif
{!! \App\Lib\Helpers\ToolboxHelper::plainToHtml($message->message) !!}
@foreach ([$message->file, $message->file2, $message->file3] as $file)
@if ($file !== null)
<br><a href="{{ asset($file) }}" target="_blank">Ouvrir la pièce jointe</a>
@endif
@endforeach
<br><br>
<small class="@if ($message->user_id === Auth::user()->id) text-bg-dark @else text-body-secondary @endif fw-bold">
{!! __('Créé le :date par <b>:userName</b>', [
'date' => \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i'),
'userName' => $message->user ? $message->user->name : __('Utilisateur supprimé'),
]) !!}
</small>
@if ($message->user_id === Auth::user()->id)
@can('updateMessage', $ticket, $message)
<button class="btn btn-sm btn-primary float-end" data-bs-toggle="modal"
data-bs-target="#updateMessageModal{{ $message->id }}" type="button">
{{ __('Modifier le message') }}
</button>
<div class="modal fade" id="updateMessageModal{{ $message->id }}" aria-labelledby="updateMessageModalLabel"
aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.update', ['ticket' => $ticket, 'message' => $message]) }}"
method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Modification du message n°:messageid', ['messageid' => $message->id]) }}
</h5>
<button class="btn btn-sm btn-primary bg-primary" data-bs-dismiss="modal" type="button"
aria-label="Close">
<i class="fa-solid fa-xmark text-white"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10">{{ $message->message }}</textarea>
</div>
@endforeach
<br><br>
<small class="@if ($message->user_id === Auth::user()->id) text-bg-dark @else text-body-secondary @endif fw-bold">
{!! __('Créé le :date par <b>:userName</b>', [
'date' => \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i'),
'userName' => $message->user ? $message->user->name : __('Utilisateur supprimé'),
]) !!}
</small>
@if ($message->user_id === Auth::user()->id)
@can('updateMessage', $ticket, $message)
<button class="btn btn-sm btn-primary float-end" data-bs-toggle="modal"
data-bs-target="#updateMessageModal{{ $message->id }}" type="button">
{{ __('Modifier le message') }}
</button>
<div class="modal fade" id="updateMessageModal{{ $message->id }}" aria-labelledby="updateMessageModalLabel"
aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.update', ['ticket' => $ticket, 'message' => $message]) }}"
method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Modification du message n°:messageid', ['messageid' => $message->id]) }}
</h5>
<button class="btn btn-sm btn-primary bg-primary" data-bs-dismiss="modal" type="button"
aria-label="Close">
<i class="fa-solid fa-xmark text-white"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10">{{ $message->message }}</textarea>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal"
type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal"
type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
@endcan
@endif
</div>
@endif
</div>
@endcan
@endif
</div>
@endif
@endforeach
</div>
@endif
@endforeach
{{-- End display message --}}
<hr>
<div>
<h4>{{ __('Description') }}</h4>
@ -341,4 +350,5 @@
@endif
@endcan
@endcan
@endsection
</div>
@endsection