Skip to content

Commit

Permalink
- improve Slack messages about request (#367)
Browse files Browse the repository at this point in the history
- wip
  • Loading branch information
EwelinaSkrzypacz authored Oct 30, 2023
1 parent 8019143 commit cb5b2ec
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
27 changes: 24 additions & 3 deletions app/Infrastructure/Slack/SlackActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]),
]);
}
Expand All @@ -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,
]),
]);
}
Expand Down
6 changes: 4 additions & 2 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit cb5b2ec

Please sign in to comment.