T hoguet/issue5 (#37)

* enregistrer les calendar settings dans le localstorage
Fixes #5

* Refactor calendar settings service to use a definitions map for settings and update related components to access settings via a getter method

* Update src/app/services/calendar-settings-service.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor calendar settings service to utilize a new storedSignal implementation for localStorage persistence and restore the stored-signal utility

* Update typescript-eslint to version 8.46.3 and enhance error handling in storedSignal function

* Update src/app/services/calendar-settings-service.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Enhance storedSignal function to accept an Injector for improved context handling in localStorage persistence

* Skip initial execution in storedSignal effect to prevent unnecessary localStorage writes

* Refactor get method in CalendarSettingsService to throw an error if the setting ID doesn't exist

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Théophyl HoguetandCopilot authored and GitHub committed 2025-11-07 00:19:38 +01:00
1 parent 1922b9acb2
commit 81d974cbfe
9 files changed
+199 -36

No files matched your search

@@ -2,7 +2,7 @@
<h3>{{ getMonthName() }} {{ year }}</h3>
<div>
<div class="row header">
@if (calendarSettingsService.showWeekNumbers()) {
@if (calendarSettingsService.get('showWeekNumbers')()) {
<p class="day empty week-number"></p>
}
<p class="day">L</p>
@@ -16,7 +16,7 @@
<div class="cols">
@for (week of weeksInAMonth; track $index) {
<div class="row week">
@if (calendarSettingsService.showWeekNumbers()) {
@if (calendarSettingsService.get('showWeekNumbers')()) {
<p
class="day week-number"
[class.start]="$index === 0"
@@ -35,7 +35,7 @@ export class CalendarYear {
effect(() => {
this.selectedDates = this.calendarService.getSelectedDatesForYear();
const vacationData = this.userInput.vacationNumberSignal();
const c = this.calendarSettingsService.samediMalin();
const c = this.calendarSettingsService.get('samediMalin')();
console.log('Samedi Malin setting:', c);
console.log('Optimizing vacations with data:', vacationData);
this.isLoading.set(true);
@@ -4,15 +4,15 @@
<p>Configure your calendar settings here.</p>
</div>
<div style="display: flex; flex-direction: column; gap: 1rem">
@for (signal of calendarSettingsService.settings; track signal.id) {
@for (setting of calendarSettingsService.settingsArray; track setting.id) {
<div style="align-self: flex-start">
<mat-slide-toggle
[id]="signal.id"
[name]="signal.id"
[checked]="signal.signal()"
(change)="signal.signal.set($event.checked)"
[id]="setting.id"
[name]="setting.id"
[checked]="setting.signal()"
(change)="setting.signal.set($event.checked)"
>
{{ signal.description }}
{{ setting.description }}
</mat-slide-toggle>
</div>
}