Refactor calendar settings dialog to use dynamic settings from service (#30)
* Refactor calendar settings dialog to use dynamic settings from service * Update src/app/components/dialog/calendar-settings-dialog/calendar-settings-dialog.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add type definition for calendar settings array (#35) * Initial plan * Add type definition for calendar settings array Co-authored-by: THoguet <61246905+THoguet@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: THoguet <61246905+THoguet@users.noreply.github.com> * use inject --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
3 files changed
+30
-21
No files matched your search
@@ -4,26 +4,18 @@
|
||||
<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) {
|
||||
<div style="align-self: flex-start">
|
||||
<mat-slide-toggle
|
||||
id="showWeekNumbers"
|
||||
name="showWeekNumbers"
|
||||
[checked]="calendarSettingsService.showWeekNumbers()"
|
||||
(change)="calendarSettingsService.showWeekNumbers.set($event.checked)"
|
||||
[id]="signal.id"
|
||||
[name]="signal.id"
|
||||
[checked]="signal.signal()"
|
||||
(change)="signal.signal.set($event.checked)"
|
||||
>
|
||||
Afficher les numéros de semaine
|
||||
</mat-slide-toggle>
|
||||
</div>
|
||||
<div style="align-self: flex-start">
|
||||
<mat-slide-toggle
|
||||
id="samediMalin"
|
||||
name="samediMalin"
|
||||
[checked]="calendarSettingsService.samediMalin()"
|
||||
(change)="calendarSettingsService.samediMalin.set($event.checked)"
|
||||
>
|
||||
Activer le Samedi Malin
|
||||
{{ signal.description }}
|
||||
</mat-slide-toggle>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button mat-button (click)="closeDialog()">Fermer</button>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { CalendarSettingsService } from '../../../services/calendar-settings-service';
|
||||
@@ -11,10 +11,8 @@ import { MatSlideToggle } from '@angular/material/slide-toggle';
|
||||
styleUrl: './calendar-settings-dialog.scss',
|
||||
})
|
||||
export class CalendarSettingsDialog {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<CalendarSettingsDialog>,
|
||||
protected calendarSettingsService: CalendarSettingsService,
|
||||
) {}
|
||||
public readonly dialogRef = inject<MatDialogRef<CalendarSettingsDialog>>(MatDialogRef);
|
||||
protected readonly calendarSettingsService = inject(CalendarSettingsService);
|
||||
|
||||
closeDialog() {
|
||||
this.dialogRef.close();
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { Injectable, signal, WritableSignal } from '@angular/core';
|
||||
|
||||
interface CalendarSetting {
|
||||
signal: WritableSignal<boolean>;
|
||||
id: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -6,4 +12,17 @@ import { Injectable, signal } from '@angular/core';
|
||||
export class CalendarSettingsService {
|
||||
readonly showWeekNumbers = signal(false);
|
||||
readonly samediMalin = signal(true);
|
||||
|
||||
readonly settings: readonly CalendarSetting[] = [
|
||||
{
|
||||
signal: this.showWeekNumbers,
|
||||
id: 'showWeekNumbers',
|
||||
description: 'Afficher les numéros de semaine',
|
||||
},
|
||||
{
|
||||
signal: this.samediMalin,
|
||||
id: 'samediMalin',
|
||||
description: 'Activer le Samedi Malin',
|
||||
},
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user