From a3637faafa79d737cc0afe15ef54fbc2b3ec6f55 Mon Sep 17 00:00:00 2001 From: Florian THIERRY Date: Mon, 2 Feb 2026 17:29:49 +0100 Subject: [PATCH] Rework picture selector to use signals. --- .../picture-selection-dialog.component.html | 4 ++-- .../picture-selection-dialog.component.ts | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.html b/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.html index ddbe7ed..88dab07 100644 --- a/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.html +++ b/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.html @@ -10,7 +10,7 @@

Select an illustration

- @if (isLoading) { + @if (isLoading()) {

Pictures loading...

} @else { @@ -40,4 +40,4 @@ Add new picture - \ No newline at end of file + diff --git a/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.ts b/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.ts index 2e989bb..25ad430 100644 --- a/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.ts +++ b/frontend/src/app/components/publication-edition/picture-selection-dialog/picture-selection-dialog.component.ts @@ -1,11 +1,11 @@ -import { Component, inject, OnInit } from "@angular/core"; +import {Component, inject, OnInit, signal} from "@angular/core"; import { Picture } from "../../../core/rest-services/picture/model/picture"; -import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; +import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; import { MatSnackBar } from "@angular/material/snack-bar"; import { PictureRestService } from "../../../core/rest-services/picture/picture.rest-service"; import { MatIcon } from "@angular/material/icon"; import { MatDialogRef } from "@angular/material/dialog"; -import {MatRippleModule} from '@angular/material/core'; +import {MatRippleModule} from '@angular/material/core'; import { MatTooltip } from "@angular/material/tooltip"; @Component({ @@ -24,12 +24,12 @@ export class PictureSelectionDialog implements OnInit { private readonly snackBar = inject(MatSnackBar); private readonly dialogRef = inject(MatDialogRef); - isLoading: boolean = false; - isLoaded: boolean = false; + isLoading = signal(false); + isLoaded = signal(false); pictures: Picture[] = []; ngOnInit(): void { - this.isLoading = true; + this.isLoading.set(true); this.pictureRestService.getAllOfCurrentUser() .then(pictures => { this.pictures = pictures; @@ -38,14 +38,14 @@ export class PictureSelectionDialog implements OnInit { if (error.status === 401) { this.dialogRef.close(); } else { - const errorMessage = $localize`An error occured while loading pictures.`; + const errorMessage = $localize`An error occurred while loading pictures.`; console.error(errorMessage, error); this.snackBar.open(errorMessage, $localize`Close`, { duration: 5000 }); } }) .finally(() => { - this.isLoading = false; - this.isLoaded = true; + this.isLoading.set(false); + this.isLoaded.set(true); }); } @@ -65,10 +65,10 @@ export class PictureSelectionDialog implements OnInit { this.dialogRef.close(pictureId); }) .catch(error => { - const errorMessage = $localize`A technical error occured while uploading your picture.`; + const errorMessage = $localize`A technical error occurred while uploading your picture.`; console.error(errorMessage, error); this.snackBar.open(errorMessage, $localize`Close`, { duration: 5000 }); }); } } -} \ No newline at end of file +}