Add the task calendar, holidays, workflow templates and customer removal
Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Application\Contracts;
|
||||
|
||||
use App\Modules\Shared\Application\DTOs\HolidayOverride;
|
||||
|
||||
/**
|
||||
* Stored changes to the calculated Finnish holidays, one per date.
|
||||
*/
|
||||
interface HolidayOverrides
|
||||
{
|
||||
/**
|
||||
* @return list<HolidayOverride> In date order; dates are Y-m-d and inclusive.
|
||||
*/
|
||||
public function between(string $from, string $to): array;
|
||||
|
||||
public function find(string $date): ?HolidayOverride;
|
||||
|
||||
public function save(HolidayOverride $override): void;
|
||||
|
||||
public function delete(string $date): void;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Application\DTOs;
|
||||
|
||||
/**
|
||||
* A holiday of the calendar. A Finnish public holiday has a key (named in
|
||||
* the UI's language) and can be taken out of use; a company's own day off
|
||||
* has a name and can be removed.
|
||||
*/
|
||||
final readonly class Holiday
|
||||
{
|
||||
public function __construct(
|
||||
public string $date,
|
||||
public ?string $key,
|
||||
public ?string $name,
|
||||
public bool $active,
|
||||
) {}
|
||||
|
||||
public function isCompanyDay(): bool
|
||||
{
|
||||
return $this->key === null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Application\DTOs;
|
||||
|
||||
/**
|
||||
* A change to the calculated holidays: a Finnish holiday taken out of use
|
||||
* (isHoliday false) or a company's own day off (isHoliday true, named).
|
||||
*/
|
||||
final readonly class HolidayOverride
|
||||
{
|
||||
public function __construct(
|
||||
public string $date,
|
||||
public bool $isHoliday,
|
||||
public ?string $name = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Application\UseCases;
|
||||
|
||||
use App\Modules\Shared\Application\Contracts\HolidayOverrides;
|
||||
use App\Modules\Shared\Application\DTOs\Holiday;
|
||||
use App\Modules\Shared\Application\DTOs\HolidayOverride;
|
||||
use App\Modules\Shared\Domain\Exceptions\HolidayAlreadyExists;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHolidayName;
|
||||
use App\Modules\Shared\Domain\Exceptions\NotAHoliday;
|
||||
use App\Modules\Shared\Domain\Services\FinnishHolidays;
|
||||
use DateTimeImmutable;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* The holidays (arkipyhät) of the calendar: the Finnish public holidays,
|
||||
* calculated for every year, minus those the admin has taken out of use,
|
||||
* plus the company's own days off (Asetukset → Arkipyhät). Holidays are
|
||||
* shown like weekends, but work can still be scheduled on them. Who may
|
||||
* change them is checked by the caller (admin).
|
||||
*/
|
||||
final class HolidayCalendar
|
||||
{
|
||||
public function __construct(private HolidayOverrides $overrides) {}
|
||||
|
||||
/**
|
||||
* Every holiday between the dates, including those out of use.
|
||||
*
|
||||
* @return list<Holiday> In date order.
|
||||
*/
|
||||
public function between(string $from, string $to): array
|
||||
{
|
||||
$fromDate = self::date($from);
|
||||
$toDate = self::date($to);
|
||||
$holidays = [];
|
||||
|
||||
for ($year = (int) $fromDate->format('Y'); $year <= (int) $toDate->format('Y'); $year++) {
|
||||
foreach (FinnishHolidays::forYear($year) as $date => $key) {
|
||||
if ($date >= $from && $date <= $to) {
|
||||
$holidays[$date] = new Holiday($date, $key, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->overrides->between($from, $to) as $override) {
|
||||
$calculated = $holidays[$override->date] ?? null;
|
||||
|
||||
if ($calculated !== null) {
|
||||
$holidays[$override->date] = new Holiday($override->date, $calculated->key, null, $override->isHoliday);
|
||||
} elseif ($override->isHoliday) {
|
||||
$holidays[$override->date] = new Holiday($override->date, null, $override->name, true);
|
||||
}
|
||||
}
|
||||
|
||||
ksort($holidays);
|
||||
|
||||
return array_values($holidays);
|
||||
}
|
||||
|
||||
/**
|
||||
* The holidays in use between the dates.
|
||||
*
|
||||
* @return list<string> Y-m-d dates in order.
|
||||
*/
|
||||
public function activeDatesBetween(string $from, string $to): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (Holiday $holiday): string => $holiday->date,
|
||||
array_filter($this->between($from, $to), fn (Holiday $holiday): bool => $holiday->active),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotAHoliday
|
||||
*/
|
||||
public function disable(string $date): void
|
||||
{
|
||||
$this->calculatedKey($date);
|
||||
$this->overrides->save(new HolidayOverride($date, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotAHoliday
|
||||
*/
|
||||
public function enable(string $date): void
|
||||
{
|
||||
$this->calculatedKey($date);
|
||||
$this->overrides->delete($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidHolidayName
|
||||
* @throws HolidayAlreadyExists
|
||||
*/
|
||||
public function addCompanyDay(string $date, string $name): void
|
||||
{
|
||||
$name = trim((string) preg_replace('/\s+/u', ' ', $name));
|
||||
|
||||
if ($name === '' || mb_strlen($name) > 100) {
|
||||
throw new InvalidHolidayName;
|
||||
}
|
||||
|
||||
self::date($date);
|
||||
|
||||
if (isset(FinnishHolidays::forYear((int) substr($date, 0, 4))[$date]) || $this->overrides->find($date) !== null) {
|
||||
throw new HolidayAlreadyExists;
|
||||
}
|
||||
|
||||
$this->overrides->save(new HolidayOverride($date, true, $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotAHoliday
|
||||
*/
|
||||
public function removeCompanyDay(string $date): void
|
||||
{
|
||||
$override = $this->overrides->find($date);
|
||||
|
||||
if ($override === null || ! $override->isHoliday || isset(FinnishHolidays::forYear((int) substr($date, 0, 4))[$date])) {
|
||||
throw new NotAHoliday;
|
||||
}
|
||||
|
||||
$this->overrides->delete($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotAHoliday
|
||||
*/
|
||||
private function calculatedKey(string $date): string
|
||||
{
|
||||
self::date($date);
|
||||
|
||||
return FinnishHolidays::forYear((int) substr($date, 0, 4))[$date] ?? throw new NotAHoliday;
|
||||
}
|
||||
|
||||
private static function date(string $value): DateTimeImmutable
|
||||
{
|
||||
$date = DateTimeImmutable::createFromFormat('!Y-m-d', $value);
|
||||
|
||||
if ($date === false || $date->format('Y-m-d') !== $value) {
|
||||
throw new InvalidArgumentException("Not a Y-m-d date: {$value}");
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\Exceptions;
|
||||
|
||||
final class HolidayAlreadyExists extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The day is already a holiday.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\Exceptions;
|
||||
|
||||
final class InvalidHolidayName extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('A company holiday needs a name of 1–100 characters.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\Exceptions;
|
||||
|
||||
final class NotAHoliday extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The day is not a holiday that can be changed this way.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\Services;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* The Finnish public holidays (arkipyhät) of a year that can fall on a
|
||||
* weekday, plus Midsummer Eve and Christmas Eve, which are days off in
|
||||
* practice. Sunday and Saturday holidays (Easter Sunday, Whitsunday,
|
||||
* Midsummer Day, All Saints' Day) are weekend days anyway.
|
||||
*/
|
||||
final class FinnishHolidays
|
||||
{
|
||||
public const array KEYS = [
|
||||
'new_years_day',
|
||||
'epiphany',
|
||||
'good_friday',
|
||||
'easter_monday',
|
||||
'may_day',
|
||||
'ascension_day',
|
||||
'midsummer_eve',
|
||||
'independence_day',
|
||||
'christmas_eve',
|
||||
'christmas_day',
|
||||
'st_stephens_day',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, string> Y-m-d date => holiday key, in date order.
|
||||
*/
|
||||
public static function forYear(int $year): array
|
||||
{
|
||||
$easter = self::easterSunday($year);
|
||||
$midsummerEve = new DateTimeImmutable(sprintf('%04d-06-19', $year));
|
||||
|
||||
while ($midsummerEve->format('N') !== '5') {
|
||||
$midsummerEve = $midsummerEve->add(new DateInterval('P1D'));
|
||||
}
|
||||
|
||||
$holidays = [
|
||||
sprintf('%04d-01-01', $year) => 'new_years_day',
|
||||
sprintf('%04d-01-06', $year) => 'epiphany',
|
||||
$easter->sub(new DateInterval('P2D'))->format('Y-m-d') => 'good_friday',
|
||||
$easter->add(new DateInterval('P1D'))->format('Y-m-d') => 'easter_monday',
|
||||
sprintf('%04d-05-01', $year) => 'may_day',
|
||||
$easter->add(new DateInterval('P39D'))->format('Y-m-d') => 'ascension_day',
|
||||
$midsummerEve->format('Y-m-d') => 'midsummer_eve',
|
||||
sprintf('%04d-12-06', $year) => 'independence_day',
|
||||
sprintf('%04d-12-24', $year) => 'christmas_eve',
|
||||
sprintf('%04d-12-25', $year) => 'christmas_day',
|
||||
sprintf('%04d-12-26', $year) => 'st_stephens_day',
|
||||
];
|
||||
|
||||
ksort($holidays);
|
||||
|
||||
return $holidays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easter Sunday by the anonymous Gregorian algorithm (Meeus/Jones/Butcher).
|
||||
*/
|
||||
public static function easterSunday(int $year): DateTimeImmutable
|
||||
{
|
||||
$a = $year % 19;
|
||||
$b = intdiv($year, 100);
|
||||
$c = $year % 100;
|
||||
$d = intdiv($b, 4);
|
||||
$e = $b % 4;
|
||||
$f = intdiv($b + 8, 25);
|
||||
$g = intdiv($b - $f + 1, 3);
|
||||
$h = (19 * $a + $b - $d - $g + 15) % 30;
|
||||
$i = intdiv($c, 4);
|
||||
$k = $c % 4;
|
||||
$l = (32 + 2 * $e + 2 * $i - $h - $k) % 7;
|
||||
$m = intdiv($a + 11 * $h + 22 * $l, 451);
|
||||
$month = intdiv($h + $l - 7 * $m + 114, 31);
|
||||
$day = (($h + $l - 7 * $m + 114) % 31) + 1;
|
||||
|
||||
return new DateTimeImmutable(sprintf('%04d-%02d-%02d', $year, $month, $day));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Shared\Infrastructure\Persistence;
|
||||
|
||||
use App\Modules\Shared\Application\Contracts\HolidayOverrides;
|
||||
use App\Modules\Shared\Application\DTOs\HolidayOverride;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Holiday changes in the `holiday_overrides` table.
|
||||
*/
|
||||
class DatabaseHolidayOverrides implements HolidayOverrides
|
||||
{
|
||||
public function between(string $from, string $to): array
|
||||
{
|
||||
return DB::table('holiday_overrides')
|
||||
->whereBetween('date', [$from, $to])
|
||||
->orderBy('date')
|
||||
->get()
|
||||
->map(fn ($row): HolidayOverride => self::toOverride($row))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
public function find(string $date): ?HolidayOverride
|
||||
{
|
||||
$row = DB::table('holiday_overrides')->where('date', $date)->first();
|
||||
|
||||
return $row === null ? null : self::toOverride($row);
|
||||
}
|
||||
|
||||
public function save(HolidayOverride $override): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
DB::table('holiday_overrides')->upsert(
|
||||
[['date' => $override->date, 'is_holiday' => $override->isHoliday, 'name' => $override->name, 'created_at' => $now, 'updated_at' => $now]],
|
||||
['date'],
|
||||
['is_holiday', 'name', 'updated_at'],
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(string $date): void
|
||||
{
|
||||
DB::table('holiday_overrides')->where('date', $date)->delete();
|
||||
}
|
||||
|
||||
private static function toOverride(object $row): HolidayOverride
|
||||
{
|
||||
return new HolidayOverride(substr((string) $row->date, 0, 10), (bool) $row->is_holiday, $row->name === null ? null : (string) $row->name);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ namespace App\Modules\Shared\Infrastructure\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Shared\Application\Contracts\EventDispatcher;
|
||||
use App\Modules\Shared\Application\Contracts\HolidayOverrides;
|
||||
use App\Modules\Shared\Application\Contracts\Settings;
|
||||
use App\Modules\Shared\Application\Contracts\TransactionManager;
|
||||
use App\Modules\Shared\Infrastructure\Events\LaravelEventDispatcher;
|
||||
use App\Modules\Shared\Infrastructure\Persistence\DatabaseHolidayOverrides;
|
||||
use App\Modules\Shared\Infrastructure\Persistence\DatabaseSettings;
|
||||
use App\Modules\Shared\Infrastructure\Persistence\LaravelTransactionManager;
|
||||
use App\Modules\Shared\Presentation\Http\Middleware\SetSecurityHeaders;
|
||||
@@ -25,6 +27,7 @@ class SharedServiceProvider extends ServiceProvider
|
||||
TransactionManager::class => LaravelTransactionManager::class,
|
||||
EventDispatcher::class => LaravelEventDispatcher::class,
|
||||
Settings::class => DatabaseSettings::class,
|
||||
HolidayOverrides::class => DatabaseHolidayOverrides::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Shared\Application\DTOs\Holiday;
|
||||
use App\Modules\Shared\Application\UseCases\HolidayCalendar;
|
||||
use App\Modules\Shared\Domain\Exceptions\HolidayAlreadyExists;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHolidayName;
|
||||
use App\Modules\Shared\Domain\Exceptions\NotAHoliday;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Holidays (Arkipyhät): the Finnish public holidays of a year, calculated
|
||||
* automatically, which the admin can take out of use, and the company's
|
||||
* own days off. The task calendar shows them like weekends.
|
||||
*/
|
||||
new class extends Component
|
||||
{
|
||||
#[Url(except: 0)]
|
||||
public int $year = 0;
|
||||
|
||||
public string $date = '';
|
||||
|
||||
public string $name = '';
|
||||
|
||||
#[Locked]
|
||||
public string $statusMessage = '';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->authorize('settings.manage');
|
||||
|
||||
if ($this->year < 2000 || $this->year > 2100) {
|
||||
$this->year = (int) now()->format('Y');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{date: string, day: string, name: string, kind: string, active: bool, company: bool}>
|
||||
*/
|
||||
#[Computed]
|
||||
public function holidays(): array
|
||||
{
|
||||
return array_map(fn (Holiday $holiday): array => [
|
||||
'date' => $holiday->date,
|
||||
'day' => $this->formatDay($holiday->date),
|
||||
'name' => $this->holidayName($holiday),
|
||||
'kind' => __($holiday->isCompanyDay() ? 'holidays.kinds.company' : 'holidays.kinds.public'),
|
||||
'active' => $holiday->active,
|
||||
'company' => $holiday->isCompanyDay(),
|
||||
], app(HolidayCalendar::class)->between($this->year.'-01-01', $this->year.'-12-31'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{index: string, label: string, sortable: bool}>
|
||||
*/
|
||||
public function headers(): array
|
||||
{
|
||||
return [
|
||||
['index' => 'day', 'label' => __('holidays.columns.date'), 'sortable' => false],
|
||||
['index' => 'name', 'label' => __('holidays.columns.name'), 'sortable' => false],
|
||||
['index' => 'kind', 'label' => __('holidays.columns.kind'), 'sortable' => false],
|
||||
['index' => 'state', 'label' => __('holidays.columns.state'), 'sortable' => false],
|
||||
['index' => 'actions', 'label' => __('holidays.columns.actions'), 'sortable' => false],
|
||||
];
|
||||
}
|
||||
|
||||
public function changeYear(int $step): void
|
||||
{
|
||||
$this->authorize('settings.manage');
|
||||
|
||||
$this->year = max(2000, min(2100, $this->year + ($step < 0 ? -1 : 1)));
|
||||
$this->statusMessage = __('holidays.showing_year', ['year' => $this->year]);
|
||||
unset($this->holidays);
|
||||
}
|
||||
|
||||
public function disable(string $date, HolidayCalendar $calendar): void
|
||||
{
|
||||
$this->change($date, fn () => $calendar->disable($date), 'holidays.disabled');
|
||||
}
|
||||
|
||||
public function enable(string $date, HolidayCalendar $calendar): void
|
||||
{
|
||||
$this->change($date, fn () => $calendar->enable($date), 'holidays.enabled');
|
||||
}
|
||||
|
||||
public function remove(string $date, HolidayCalendar $calendar): void
|
||||
{
|
||||
$this->change($date, fn () => $calendar->removeCompanyDay($date), 'holidays.removed');
|
||||
}
|
||||
|
||||
public function add(HolidayCalendar $calendar): void
|
||||
{
|
||||
$this->authorize('settings.manage');
|
||||
$this->statusMessage = '';
|
||||
|
||||
$this->validate([
|
||||
'date' => ['required', 'date_format:Y-m-d', 'after_or_equal:2000-01-01', 'before_or_equal:2100-12-31'],
|
||||
'name' => ['required', 'string', 'max:100'],
|
||||
], [
|
||||
'date.*' => __('holidays.errors.date'),
|
||||
'name.*' => __('holidays.errors.name'),
|
||||
]);
|
||||
|
||||
try {
|
||||
$calendar->addCompanyDay($this->date, $this->name);
|
||||
} catch (InvalidHolidayName) {
|
||||
$this->addError('name', __('holidays.errors.name'));
|
||||
|
||||
return;
|
||||
} catch (HolidayAlreadyExists) {
|
||||
$this->addError('date', __('holidays.errors.exists'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->statusMessage = __('holidays.added', ['day' => $this->formatDay($this->date), 'name' => trim($this->name)]);
|
||||
$this->year = (int) substr($this->date, 0, 4);
|
||||
$this->reset('date', 'name');
|
||||
unset($this->holidays);
|
||||
}
|
||||
|
||||
public function render(): mixed
|
||||
{
|
||||
return $this->view()->title(__('holidays.title'));
|
||||
}
|
||||
|
||||
private function change(string $date, \Closure $action, string $messageKey): void
|
||||
{
|
||||
$this->authorize('settings.manage');
|
||||
|
||||
$holiday = collect($this->holidays)->firstWhere('date', $date);
|
||||
|
||||
try {
|
||||
$action();
|
||||
} catch (NotAHoliday|\InvalidArgumentException) {
|
||||
$this->statusMessage = __('holidays.not_changed');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->holidays);
|
||||
$this->statusMessage = __($messageKey, ['day' => $this->formatDay($date), 'name' => $holiday['name'] ?? '']);
|
||||
}
|
||||
|
||||
private function holidayName(Holiday $holiday): string
|
||||
{
|
||||
return $holiday->key === null ? (string) $holiday->name : __('holidays.names.'.$holiday->key);
|
||||
}
|
||||
|
||||
private function formatDay(string $date): string
|
||||
{
|
||||
$day = CarbonImmutable::createFromFormat('!Y-m-d', $date);
|
||||
|
||||
return ! $day instanceof CarbonImmutable ? $date :__('holidays.weekdays.'.$day->dayOfWeekIso).' '.$day->format('j.n.Y');
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div class="mx-auto max-w-4xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<h1 class="text-2xl font-semibold">{{ __('holidays.title') }}</h1>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('holidays.intro') }}</p>
|
||||
<p class="text-sm"><x-link :href="route('settings.company')" navigate>{{ __('company.title') }}</x-link></p>
|
||||
</div>
|
||||
|
||||
<p role="status" aria-live="polite" class="min-h-5 text-sm font-medium">{{ $statusMessage }}</p>
|
||||
|
||||
<section aria-labelledby="holidays-year-heading" class="space-y-4">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<x-button subtle color="black" icon="chevron-left" wire:click="changeYear(-1)" :text="__('holidays.previous_year')" />
|
||||
<h2 id="holidays-year-heading" class="text-lg font-semibold">{{ __('holidays.year_heading', ['year' => $year]) }}</h2>
|
||||
<x-button subtle color="black" icon="chevron-right" position="right" wire:click="changeYear(1)" :text="__('holidays.next_year')" />
|
||||
</div>
|
||||
|
||||
<x-table :headers="$this->headers()" :rows="$this->holidays">
|
||||
@interact('column_day', $holiday)
|
||||
<span class="whitespace-nowrap">{{ $holiday['day'] }}</span>
|
||||
@endinteract
|
||||
|
||||
@interact('column_name', $holiday)
|
||||
<span class="break-words">{{ $holiday['name'] }}</span>
|
||||
@endinteract
|
||||
|
||||
@interact('column_kind', $holiday)
|
||||
{{ $holiday['kind'] }}
|
||||
@endinteract
|
||||
|
||||
@interact('column_state', $holiday)
|
||||
@if ($holiday['active'])
|
||||
<span class="inline-flex items-center gap-1"><x-icon name="check" class="size-4" aria-hidden="true" />{{ __('holidays.in_use') }}</span>
|
||||
@else
|
||||
<span class="inline-flex items-center gap-1"><x-icon name="x-mark" class="size-4" aria-hidden="true" />{{ __('holidays.not_in_use') }}</span>
|
||||
@endif
|
||||
@endinteract
|
||||
|
||||
@interact('column_actions', $holiday)
|
||||
@if ($holiday['company'])
|
||||
<x-button sm subtle color="black" wire:click="remove('{{ $holiday['date'] }}')" :text="__('holidays.remove')" :aria-label="__('holidays.remove_named', ['name' => $holiday['name'], 'day' => $holiday['day']])" />
|
||||
@elseif ($holiday['active'])
|
||||
<x-button sm subtle color="black" wire:click="disable('{{ $holiday['date'] }}')" :text="__('holidays.disable')" :aria-label="__('holidays.disable_named', ['name' => $holiday['name'], 'day' => $holiday['day']])" />
|
||||
@else
|
||||
<x-button sm subtle color="black" wire:click="enable('{{ $holiday['date'] }}')" :text="__('holidays.enable')" :aria-label="__('holidays.enable_named', ['name' => $holiday['name'], 'day' => $holiday['day']])" />
|
||||
@endif
|
||||
@endinteract
|
||||
</x-table>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="holidays-add-heading" class="space-y-4">
|
||||
<h2 id="holidays-add-heading" class="text-lg font-semibold">{{ __('holidays.add_heading') }}</h2>
|
||||
|
||||
<form wire:submit="add" class="grid gap-4 sm:grid-cols-[12rem_1fr_auto] sm:items-start" novalidate>
|
||||
<x-input wire:model="date" type="date" :label="__('holidays.fields.date')" required />
|
||||
<x-input wire:model="name" :label="__('holidays.fields.name')" :hint="__('holidays.fields.name_hint')" autocomplete="off" required />
|
||||
<div class="sm:pt-6">
|
||||
<x-button submit :text="__('holidays.add')" />
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
@@ -7,4 +7,5 @@ Route::middleware(['web', 'auth', 'can:settings.manage'])
|
||||
->name('settings.')
|
||||
->group(function () {
|
||||
Route::livewire('/company', 'shared::company')->name('company');
|
||||
Route::livewire('/holidays', 'shared::holidays')->name('holidays');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user