parent
026dd87a44
commit
fae50cb21c
@ -8,12 +8,14 @@ use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvi
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByAdministrative;
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByTechnical;
|
||||
use Toby\Domain\Events\VacationRequestApproved;
|
||||
use Toby\Domain\Events\VacationRequestCancelled;
|
||||
use Toby\Domain\Events\VacationRequestCreated;
|
||||
use Toby\Domain\Events\VacationRequestStateChanged;
|
||||
use Toby\Domain\Listeners\CreateVacationRequestActivity;
|
||||
use Toby\Domain\Listeners\HandleAcceptedByAdministrativeVacationRequest;
|
||||
use Toby\Domain\Listeners\HandleAcceptedByTechnicalVacationRequest;
|
||||
use Toby\Domain\Listeners\HandleApprovedVacationRequest;
|
||||
use Toby\Domain\Listeners\HandleCancelledVacationRequest;
|
||||
use Toby\Domain\Listeners\HandleCreatedVacationRequest;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
@ -24,5 +26,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
VacationRequestAcceptedByTechnical::class => [HandleAcceptedByTechnicalVacationRequest::class],
|
||||
VacationRequestAcceptedByAdministrative::class => [HandleAcceptedByAdministrativeVacationRequest::class],
|
||||
VacationRequestApproved::class => [HandleApprovedVacationRequest::class],
|
||||
VacationRequestCancelled::class => [HandleCancelledVacationRequest::class],
|
||||
];
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace Toby\Domain\Enums;
|
||||
enum VacationRequestState: string
|
||||
{
|
||||
case Created = "created";
|
||||
case Canceled = "canceled";
|
||||
case Cancelled = "cancelled";
|
||||
case Rejected = "rejected";
|
||||
case Approved = "approved";
|
||||
case WaitingForTechnical = "waiting_for_technical";
|
||||
@ -40,7 +40,7 @@ enum VacationRequestState: string
|
||||
{
|
||||
return [
|
||||
self::Rejected,
|
||||
self::Canceled,
|
||||
self::Cancelled,
|
||||
];
|
||||
}
|
||||
|
||||
|
20
app/Domain/Events/VacationRequestCancelled.php
Normal file
20
app/Domain/Events/VacationRequestCancelled.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Events;
|
||||
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
|
||||
class VacationRequestCancelled
|
||||
{
|
||||
use Dispatchable;
|
||||
use SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public VacationRequest $vacationRequest,
|
||||
) {
|
||||
}
|
||||
}
|
@ -5,16 +5,10 @@ declare(strict_types=1);
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Toby\Domain\Events\VacationRequestApproved;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
use Toby\Infrastructure\Jobs\SendVacationRequestDaysToGoogleCalendar;
|
||||
|
||||
class HandleApprovedVacationRequest
|
||||
{
|
||||
public function __construct(
|
||||
protected VacationTypeConfigRetriever $configRetriever,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestApproved $event): void
|
||||
{
|
||||
SendVacationRequestDaysToGoogleCalendar::dispatch($event->vacationRequest);
|
||||
|
16
app/Domain/Listeners/HandleCancelledVacationRequest.php
Normal file
16
app/Domain/Listeners/HandleCancelledVacationRequest.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Toby\Domain\Events\VacationRequestCancelled;
|
||||
use Toby\Infrastructure\Jobs\ClearVacationRequestDaysInGoogleCalendar;
|
||||
|
||||
class HandleCancelledVacationRequest
|
||||
{
|
||||
public function handle(VacationRequestCancelled $event): void
|
||||
{
|
||||
ClearVacationRequestDaysInGoogleCalendar::dispatch($event->vacationRequest);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ use Toby\Domain\Enums\VacationRequestState;
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByAdministrative;
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByTechnical;
|
||||
use Toby\Domain\Events\VacationRequestApproved;
|
||||
use Toby\Domain\Events\VacationRequestCancelled;
|
||||
use Toby\Domain\Events\VacationRequestCreated;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
|
||||
@ -42,7 +43,9 @@ class VacationRequestStateManager
|
||||
|
||||
public function cancel(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::Canceled);
|
||||
$this->changeState($vacationRequest, VacationRequestState::Cancelled);
|
||||
|
||||
$this->dispatcher->dispatch(new VacationRequestCancelled($vacationRequest));
|
||||
}
|
||||
|
||||
public function acceptAsTechnical(VacationRequest $vacationRequest): void
|
||||
|
@ -116,7 +116,7 @@ class VacationRequestController extends Controller
|
||||
$stateManager->cancel($vacationRequest);
|
||||
|
||||
return redirect()->back()
|
||||
->with("success", __("Vacation request has been canceled."));
|
||||
->with("success", __("Vacation request has been cancelled."));
|
||||
}
|
||||
|
||||
public function acceptAsTechnical(
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Spatie\GoogleCalendar\Event;
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
|
||||
class ClearVacationRequestDaysInGoogleCalendar implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
protected VacationRequest $vacationRequest,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$vacations = $this->vacationRequest->vacations()
|
||||
->whereNotNull("event_id")
|
||||
->get();
|
||||
|
||||
/** @var Vacation $vacation */
|
||||
foreach ($vacations as $vacation) {
|
||||
Event::find($vacation->event_id)->delete();
|
||||
|
||||
$vacation->update([
|
||||
"event_id" => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
@ -110,7 +110,7 @@ const statuses = [
|
||||
},
|
||||
{
|
||||
text: 'Anulowany',
|
||||
value: 'canceled',
|
||||
value: 'cancelled',
|
||||
outline: {
|
||||
icon: OutlineXIcon,
|
||||
foreground: 'text-white',
|
||||
|
@ -62,7 +62,9 @@
|
||||
as="template"
|
||||
:value="type"
|
||||
>
|
||||
<li :class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']">
|
||||
<li
|
||||
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
|
||||
>
|
||||
<span :class="[selected ? 'font-semibold' : 'font-normal', 'block truncate']">
|
||||
{{ type.label }}
|
||||
</span>
|
||||
@ -137,7 +139,9 @@
|
||||
</div>
|
||||
<div class="sm:grid sm:grid-cols-3 py-4 items-center">
|
||||
<span class="block text-sm font-medium text-gray-700 sm:mt-px">Liczba dni urlopu</span>
|
||||
<div class="mt-1 sm:mt-0 sm:col-span-2 w-full max-w-lg bg-gray-50 border border-gray-300 rounded-md px-4 py-2 inline-flex items-center text-gray-500 sm:text-sm">
|
||||
<div
|
||||
class="mt-1 sm:mt-0 sm:col-span-2 w-full max-w-lg bg-gray-50 border border-gray-300 rounded-md px-4 py-2 inline-flex items-center text-gray-500 sm:text-sm"
|
||||
>
|
||||
{{ estimatedDays.length }}
|
||||
</div>
|
||||
</div>
|
||||
@ -179,11 +183,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {useForm} from '@inertiajs/inertia-vue3'
|
||||
import {useForm, usePage} from '@inertiajs/inertia-vue3'
|
||||
import FlatPickr from 'vue-flatpickr-component'
|
||||
import {Listbox, ListboxButton, ListboxLabel, ListboxOption, ListboxOptions} from '@headlessui/vue'
|
||||
import {CheckIcon, SelectorIcon, XCircleIcon} from '@heroicons/vue/solid'
|
||||
import {reactive, ref} from 'vue'
|
||||
import {reactive, ref, computed} from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
@ -218,18 +222,22 @@ export default {
|
||||
})
|
||||
|
||||
const estimatedDays = ref([])
|
||||
const minDate = computed(() => new Date(usePage().props.value.years.current, 0, 1))
|
||||
const maxDate = computed(() => new Date(usePage().props.value.years.current, 11, 31))
|
||||
|
||||
const disableDates = [
|
||||
date => (date.getDay() === 0 || date.getDay() === 6),
|
||||
]
|
||||
|
||||
const fromInputConfig = reactive({
|
||||
maxDate: null,
|
||||
minDate: minDate,
|
||||
maxDate: maxDate,
|
||||
disable: disableDates,
|
||||
})
|
||||
|
||||
const toInputConfig = reactive({
|
||||
minDate: null,
|
||||
minDate: minDate,
|
||||
maxDate: maxDate,
|
||||
disable: disableDates,
|
||||
})
|
||||
|
||||
@ -250,13 +258,11 @@ export default {
|
||||
.post('/vacation-requests')
|
||||
},
|
||||
onFromChange(selectedDates, dateStr) {
|
||||
this.toInputConfig.minDate = dateStr
|
||||
this.form.to = dateStr
|
||||
|
||||
this.refreshEstimatedDays(this.form.from, this.form.to)
|
||||
},
|
||||
onToChange(selectedDates, dateStr) {
|
||||
this.fromInputConfig.maxDate = dateStr
|
||||
|
||||
onToChange() {
|
||||
this.refreshEstimatedDays(this.form.from, this.form.to)
|
||||
},
|
||||
refreshEstimatedDays(from, to) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
"technical_approver": "Techniczny akceptujący",
|
||||
"administrative_approver": "Administracyjny akceptujący",
|
||||
"created": "Utworzony",
|
||||
"canceled": "Anulowany",
|
||||
"cancelled": "Anulowany",
|
||||
"rejected": "Odrzucony",
|
||||
"approved": "Zatwierdzony",
|
||||
"waiting_for_technical": "Czeka na akceptację od technicznego",
|
||||
@ -43,6 +43,6 @@
|
||||
"Vacation request has been created.": "Wniosek urlopowy został utworzony.",
|
||||
"Vacation request has been accepted.": "Wniosek urlopowy został zaakceptowany.",
|
||||
"Vacation request has been rejected.": "Wniosek urlopowy został odrzucony.",
|
||||
"Vacation request has been canceled.": "Wniosek urlopowy został anulowany."
|
||||
"Vacation request has been cancelled.": "Wniosek urlopowy został anulowany."
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user