From cb5b2ec79779e508d9ed6794cd9060aa6f2c1eed Mon Sep 17 00:00:00 2001 From: Ewelina Skrzypacz <56546832+EwelinaSkrzypacz@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:53:21 +0100 Subject: [PATCH] - improve Slack messages about request (#367) - wip --- ...ionRequestWaitsForApprovalNotification.php | 16 +++++++++-- .../Slack/SlackActionController.php | 27 ++++++++++++++++--- lang/pl.json | 6 +++-- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php b/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php index f390ec98..c5aa5bc2 100644 --- a/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php +++ b/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php @@ -51,17 +51,29 @@ protected function buildDescription(): string { $title = $this->vacationRequest->name; $requester = $this->vacationRequest->user->profile->full_name; + $from = $this->vacationRequest->from; + $to = $this->vacationRequest->to; + + $date = $from->equalTo($to) + ? "{$from->toDisplayString()}" + : "{$from->toDisplayString()} - {$to->toDisplayString()}"; + + $days = $this->vacationRequest->vacations()->count(); if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) { - return __("The request :title from user :requester is waiting for your technical approval.", [ + return __("The request :title is waiting for your technical approval.\nUser: :requester\nDate: :date (number of days: :days)", [ "title" => $title, "requester" => $requester, + "date" => $date, + "days" => $days, ]); } - return __("The request :title from user :requester is waiting for your administrative approval.", [ + return __("The request :title is waiting for your administrative approval.\nUser: :requester\nDate: :date (number of days: :days)", [ "title" => $title, "requester" => $requester, + "date" => $date, + "days" => $days, ]); } } diff --git a/app/Infrastructure/Slack/SlackActionController.php b/app/Infrastructure/Slack/SlackActionController.php index 4b1e1b3b..02246c3f 100644 --- a/app/Infrastructure/Slack/SlackActionController.php +++ b/app/Infrastructure/Slack/SlackActionController.php @@ -83,11 +83,21 @@ protected function handleTechnicalApproval(User $user, VacationRequest $vacation $acceptAsTechnical->execute($vacationRequest, $user); + $from = $vacationRequest->from; + $to = $vacationRequest->to; + + $date = $from->equalTo($to) + ? "{$from->toDisplayString()}" + : "{$from->toDisplayString()} - {$to->toDisplayString()}"; + + $days = $vacationRequest->vacations()->count(); + return response()->json([ - "text" => __("The request :title from user :requester has been approved by you as a technical approver.", [ + "text" => __("The request :title has been approved by you as a technical approver.\nUser: :requester\nDate: :date (number of days: :days)", [ "title" => $vacationRequest->name, "requester" => $vacationRequest->user->profile->full_name, - "technical" => $user->profile->full_name, + "date" => $date, + "days" => $days, ]), ]); } @@ -104,10 +114,21 @@ protected function handleAdministrativeApproval(User $user, VacationRequest $vac $acceptAsAdministrative->execute($vacationRequest, $user); + $from = $vacationRequest->from; + $to = $vacationRequest->to; + + $date = $from->equalTo($to) + ? "{$from->toDisplayString()}" + : "{$from->toDisplayString()} - {$to->toDisplayString()}"; + + $days = $vacationRequest->vacations()->count(); + return response()->json([ - "text" => __("The request :title from user :requester has been approved by you as an administrative approver.", [ + "text" => __("The request :title has been approved by you as an administrative approver.\nUser: :requester\nDate: :date (number of days: :days)", [ "title" => $vacationRequest->name, "requester" => $vacationRequest->user->profile->full_name, + "date" => $date, + "days" => $days, ]), ]); } diff --git a/lang/pl.json b/lang/pl.json index bee34536..c17ba212 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -63,8 +63,10 @@ "Click here for details": "Kliknij, aby zobaczyć szczegóły", "Request :title is waiting for your technical approval": "Wniosek :title czeka na akceptację techniczną", "Request :title is waiting for your administrative approval": "Wniosek :title czeka na akceptację administracyjną", - "The request :title from user :requester is waiting for your technical approval.": "Wniosek :title użytkownika :requester czeka na Twoją akceptację techniczną.", - "The request :title from user :requester is waiting for your administrative approval.": "Wniosek :title użytkownika :requester czeka na Twoją akceptację administracyjną.", + "The request :title is waiting for your technical approval.\nUser: :requester\nDate: :date (number of days: :days)": "Wniosek :title czeka na Twoją akceptację techniczną.\nPracownik: :requester\nData: :date (liczba dni: :days)", + "The request :title is waiting for your administrative approval.\nUser: :requester\nDate: :date (number of days: :days)": "Wniosek :title czeka na Twoją akceptację administracyjną.\nPracownik: :requester\nData: :date (liczba dni: :days)", + "The request :title has been approved by you as a technical approver.\nUser: :requester\nDate: :date (number of days: :days)": "Wniosek :title został zaakceptowany przez Ciebie jako przełożonego technicznego.\nPracownik: :requester\nData: :date (liczba dni: :days)", + "The request :title has been approved by you as an administrative approver.\nUser: :requester\nDate: :date (number of days: :days)": "Wniosek :title został zaakceptowany przez Ciebie jako przełożonego administracyjnego.\nPracownik: :requester\nData: :date (liczba dni: :days)", "Request :title has been :status": "Wniosek :title został :status", "Request :title in :application": "Wniosek :title w aplikacji :application", "The request :title from user :requester has been :status.": "Wniosek :title użytkownika :requester został :status.",