Remove bind of project month in resident calendar options

This commit is contained in:
2026-01-13 21:02:25 +02:00
parent 92a9c6d704
commit db7623528c
4 changed files with 10 additions and 15 deletions

View File

@@ -9,18 +9,6 @@
import { rota, steps } from "./state.svelte.js"; import { rota, steps } from "./state.svelte.js";
import Generate from "./components/schedule/generate.svelte"; import Generate from "./components/schedule/generate.svelte";
$inspect(rota.selectedMonth).with((type, value) => {
trace(`[Month: ${type}]: ${value}`);
});
$inspect(rota.selectedYear).with((type, value) => {
trace(`[Year: ${type}]: ${value}`);
});
$inspect(rota.holidays).with((type, value) => {
const readableHolidays = JSON.stringify($state.snapshot(value));
trace(`[Holidays: ${type}]: ${readableHolidays}`);
});
</script> </script>
<main <main

View File

@@ -44,6 +44,7 @@
<div class="relative"> <div class="relative">
<select <select
bind:value={rota.selectedMonth} bind:value={rota.selectedMonth}
onchange={() => rota.syncProjectMonth()}
class="w-full appearance-none rounded-xl border border-zinc-200 bg-white px-4 py-3 font-semibold text-zinc-700 transition-all outline-none focus:border-zinc-400 focus:ring-4 focus:ring-zinc-100" class="w-full appearance-none rounded-xl border border-zinc-200 bg-white px-4 py-3 font-semibold text-zinc-700 transition-all outline-none focus:border-zinc-400 focus:ring-4 focus:ring-zinc-100"
> >
{#each monthOptions as month} {#each monthOptions as month}
@@ -71,6 +72,7 @@
<div class="relative"> <div class="relative">
<select <select
bind:value={rota.selectedYear} bind:value={rota.selectedYear}
onchange={() => rota.syncProjectMonth()}
class="w-full appearance-none rounded-xl border border-zinc-200 bg-white px-4 py-3 font-semibold text-zinc-700 transition-all outline-none focus:border-zinc-400 focus:ring-4 focus:ring-zinc-100" class="w-full appearance-none rounded-xl border border-zinc-200 bg-white px-4 py-3 font-semibold text-zinc-700 transition-all outline-none focus:border-zinc-400 focus:ring-4 focus:ring-zinc-100"
> >
{#each yearOptions as year} {#each yearOptions as year}

View File

@@ -127,7 +127,7 @@
); );
}} }}
bind:value={resident.negativeShifts} bind:value={resident.negativeShifts}
bind:placeholder={rota.projectMonth} placeholder={rota.projectMonth}
numberOfMonths={1} numberOfMonths={1}
class="select-none" class="select-none"
> >
@@ -241,7 +241,7 @@
return resident.negativeShifts.some((s) => s.compare(date) === 0); return resident.negativeShifts.some((s) => s.compare(date) === 0);
}} }}
bind:value={resident.manualShifts} bind:value={resident.manualShifts}
bind:placeholder={rota.projectMonth} placeholder={rota.projectMonth}
numberOfMonths={1} numberOfMonths={1}
class="select-none" class="select-none"
> >

View File

@@ -24,7 +24,12 @@ export class RotaState {
holidays = $state<CalendarDate[]>([]); holidays = $state<CalendarDate[]>([]);
forbiddenPairs = $state<ForbiddenPair[]>([]); forbiddenPairs = $state<ForbiddenPair[]>([]);
projectMonth = $derived(new CalendarDate(this.selectedYear, this.selectedMonth, 1)); projectMonth = $state(new CalendarDate(2026, 2, 1));
syncProjectMonth() {
this.projectMonth = new CalendarDate(this.selectedYear, this.selectedMonth, 1);
}
projectMonthDays = $derived(this.projectMonth.calendar.getDaysInMonth(this.projectMonth)); projectMonthDays = $derived(this.projectMonth.calendar.getDaysInMonth(this.projectMonth));
daysArray = $derived(Array.from({ length: this.projectMonthDays }, (_, i) => i + 1)); daysArray = $derived(Array.from({ length: this.projectMonthDays }, (_, i) => i + 1));
emptySlots = $derived(Array.from({ length: getDayOfWeek(this.projectMonth, "en-GB") })); emptySlots = $derived(Array.from({ length: getDayOfWeek(this.projectMonth, "en-GB") }));