From db525564c876ddb9269b7dcec2c3f6f9e73bea8d Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Tue, 9 Jun 2026 17:00:47 +0200 Subject: [PATCH] edit hinter button --- .../list-detail/list-detail.component.html | 94 +++++++++++-------- .../list-detail/list-detail.component.scss | 21 +++++ .../list-detail/list-detail.component.ts | 29 ++++++ 3 files changed, 104 insertions(+), 40 deletions(-) diff --git a/listify-client/src/app/lists/list-detail/list-detail.component.html b/listify-client/src/app/lists/list-detail/list-detail.component.html index fbacd5f..8fbb637 100644 --- a/listify-client/src/app/lists/list-detail/list-detail.component.html +++ b/listify-client/src/app/lists/list-detail/list-detail.component.html @@ -36,32 +36,44 @@ Details + @if (!isCreateMode()) { + + } -
- - Titel - - @if (listForm.controls.name.hasError('required')) { - Titel ist erforderlich. - } - + @if (showEditor()) { + + + Titel + + @if (listForm.controls.name.hasError('required')) { + Titel ist erforderlich. + } + - - Beschreibung - - + + Beschreibung + + - -
+ + + } @else { +
+

{{ list()?.description || 'Keine Beschreibung hinterlegt.' }}

+
+ }
@@ -78,26 +90,28 @@ -
- - Neues Item - - @if (itemForm.controls.title.hasError('required')) { - Item-Titel ist erforderlich. - } - + @if (showEditor()) { + + + Neues Item + + @if (itemForm.controls.title.hasError('required')) { + Item-Titel ist erforderlich. + } + - Pflicht + Pflicht - -
+ + + } @if (!canEditItems()) {
@@ -143,7 +157,7 @@ - Zur Listenuebersicht + Zur Listenübersicht } diff --git a/listify-client/src/app/lists/list-detail/list-detail.component.scss b/listify-client/src/app/lists/list-detail/list-detail.component.scss index bdbbbaf..d28c880 100644 --- a/listify-client/src/app/lists/list-detail/list-detail.component.scss +++ b/listify-client/src/app/lists/list-detail/list-detail.component.scss @@ -34,6 +34,16 @@ background: color-mix(in srgb, var(--mat-sys-surface-container-low) 94%, white); } +.editor-card mat-card-header { + align-items: center; + justify-content: space-between; + gap: 0.75rem; +} + +.editor-card mat-card-header button { + flex: 0 0 auto; +} + .list-form, .item-form { display: grid; @@ -72,6 +82,17 @@ font-size: 48px; } +.list-summary { + padding-top: 0.75rem; +} + +.list-summary p { + margin: 0; + color: var(--mat-sys-on-surface-variant); + overflow-wrap: anywhere; + line-height: 1.45; +} + .error-state mat-icon { color: var(--mat-sys-error); } diff --git a/listify-client/src/app/lists/list-detail/list-detail.component.ts b/listify-client/src/app/lists/list-detail/list-detail.component.ts index 92ca274..1b1ec32 100644 --- a/listify-client/src/app/lists/list-detail/list-detail.component.ts +++ b/listify-client/src/app/lists/list-detail/list-detail.component.ts @@ -46,10 +46,12 @@ export class ListDetailComponent implements OnInit { protected readonly isCreateMode = signal(false); protected readonly loading = signal(true); protected readonly saving = signal(false); + protected readonly editing = signal(false); protected readonly addingItem = signal(false); protected readonly errorMessage = signal(null); protected readonly updatingItemId = signal(null); protected readonly canEditItems = computed(() => Boolean(this.list()?.id)); + protected readonly showEditor = computed(() => this.isCreateMode() || this.editing()); protected readonly listForm = this.formBuilder.group({ name: ['', [Validators.required]], @@ -66,6 +68,7 @@ export class ListDetailComponent implements OnInit { if (this.isCreateMode()) { this.loading.set(false); + this.editing.set(true); this.listForm.reset({ name: '', description: '' }); return; } @@ -128,7 +131,10 @@ export class ListDetailComponent implements OnInit { this.setList(list); if (this.isCreateMode()) { this.isCreateMode.set(false); + this.editing.set(false); void this.router.navigate(['/lists', list.id], { replaceUrl: true }); + } else { + this.editing.set(false); } this.snackBar.open('Liste gespeichert.', 'OK', { duration: 2500 }); }, @@ -196,6 +202,29 @@ export class ListDetailComponent implements OnInit { }); } + protected startEditing(): void { + this.editing.set(true); + } + + protected cancelEditing(): void { + const list = this.list(); + + if (this.isCreateMode()) { + void this.router.navigateByUrl('/lists'); + return; + } + + if (list) { + this.listForm.reset({ + name: list.name, + description: list.description ?? '', + }); + } + + this.itemForm.reset({ title: '', required: true }); + this.editing.set(false); + } + protected checkedCount(list: UserList): number { return list.items.filter((item) => item.checked).length; }