#39 - generate timesheet #56

Merged
Baakoma merged 9 commits from #39-generate-timesheet into main 2022-02-21 16:09:45 +01:00
20 changed files with 696 additions and 2507 deletions
Showing only changes of commit 0f5b9ecc0b - Show all commits

View File

@@ -19,5 +19,5 @@ CACHE_DRIVER=array
QUEUE_CONNECTION=sync
SESSION_DRIVER=array
SESSION_LIFETIME=120
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
MAIL_MAILER=array

View File

@@ -22,7 +22,7 @@ CACHE_DRIVER=array
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
MAIL_MAILER=array
TELESCOPE_ENABLED=false

View File

@@ -35,7 +35,7 @@ CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
MAILHOG_PORT=1025
MAILHOG_DASHBOARD_PORT=8025

View File

@@ -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],
];
}

View File

@@ -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,
];
}

View 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,
) {
}
}

View File

@@ -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);

View 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);
}
}

View File

@@ -21,7 +21,6 @@ use Maatwebsite\Excel\Events\AfterSheet;
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Color;
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?

View File

@@ -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

View File

@@ -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(

View File

@@ -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,
]);
}
}
}

View File

@@ -12,7 +12,7 @@
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"inertiajs/inertia-laravel": "^0.5.1",
"laravel/framework": "^8.75",
"laravel/framework": "^9.0",
"laravel/sanctum": "^2.14",
"laravel/socialite": "^5.2",
"laravel/telescope": "^4.6",
@@ -23,12 +23,11 @@
},
"require-dev": {
"blumilksoftware/codestyle": "^0.9.0",
"enlightn/enlightn": "^1.22",
"facade/ignition": "^2.5",
"spatie/laravel-ignition": "^1.0",
"fakerphp/faker": "^1.9.1",
"laravel/dusk": "^6.21",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {

2990
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,68 +0,0 @@
<?php
declare(strict_types=1);
return [
"analyzers" => ["*"],
"exclude_analyzers" => [],
"ci_mode_exclude_analyzers" => [],
"analyzer_paths" => [
"Enlightn\\Enlightn\\Analyzers" => base_path("vendor/enlightn/enlightn/src/Analyzers"),
"Enlightn\\EnlightnPro\\Analyzers" => base_path("vendor/enlightn/enlightnpro/src/Analyzers"),
],
"base_path" => [
app_path(),
database_path("migrations"),
database_path("seeders"),
],
"skip_env_specific" => env("ENLIGHTN_SKIP_ENVIRONMENT_SPECIFIC", false),
"guest_url" => null,
"dont_report" => [],
"ignore_errors" => [],
"license_whitelist" => [
"Apache-2.0",
"Apache2",
"BSD-2-Clause",
"BSD-3-Clause",
"LGPL-2.1-only",
"LGPL-2.1",
"LGPL-2.1-or-later",
"LGPL-3.0",
"LGPL-3.0-only",
"LGPL-3.0-or-later",
"MIT",
"ISC",
"CC0-1.0",
"Unlicense",
"WTFPL",
],
"credentials" => [
"username" => env("ENLIGHTN_USERNAME"),
"api_token" => env("ENLIGHTN_API_TOKEN"),
],
"github_repo" => env("ENLIGHTN_GITHUB_REPO"),
"compact_lines" => true,
"commercial_packages" => [
"enlightn/enlightnpro",
],
"allowed_permissions" => [
base_path() => "775",
app_path() => "775",
resource_path() => "775",
storage_path() => "775",
public_path() => "775",
config_path() => "775",
database_path() => "775",
base_path("routes") => "775",
app()->bootstrapPath() => "775",
app()->bootstrapPath("cache") => "775",
app()->bootstrapPath("app.php") => "664",
base_path("artisan") => "775",
public_path("index.php") => "664",
public_path("server.php") => "664",
],
"writable_directories" => [
storage_path(),
app()->bootstrapPath("cache"),
],
];

View File

@@ -3,7 +3,7 @@
declare(strict_types=1);
return [
"default" => env("FILESYSTEM_DRIVER", "local"),
"default" => env("FILESYSTEM_DISK", "local"),
"disks" => [
"local" => [
"driver" => "local",

View File

@@ -110,7 +110,7 @@ const statuses = [
},
{
text: 'Anulowany',
value: 'canceled',
value: 'cancelled',
outline: {
icon: OutlineXIcon,
foreground: 'text-white',

View File

@@ -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) {

View File

@@ -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,7 +43,7 @@
"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.",
"Sum:": "Suma:",
"Date": "Data",
"Day of week": "Dzień tygodnia",

View File

@@ -122,6 +122,6 @@ class HolidayTest extends FeatureTestCase
->delete("/holidays/{$holiday->id}")
->assertSessionHasNoErrors();
$this->assertDeleted($holiday);
$this->assertModelMissing($holiday);
}
}