From 5a8d44d644d6359d35c2290eb5236fd1719083c2 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Mon, 18 May 2026 12:35:28 +0200 Subject: [PATCH] Feature: prompt conferma su creazione nuovo flow se ci sono modifiche non salvate (editor-sidebar) --- src/app/pages/main/editor-sidebar/editor-sidebar.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/pages/main/editor-sidebar/editor-sidebar.ts b/src/app/pages/main/editor-sidebar/editor-sidebar.ts index 37c49e5..c273354 100644 --- a/src/app/pages/main/editor-sidebar/editor-sidebar.ts +++ b/src/app/pages/main/editor-sidebar/editor-sidebar.ts @@ -12,6 +12,7 @@ import { ListState } from '@stores/list-state'; import { finalize } from 'rxjs'; import { MatMenuModule } from '@angular/material/menu'; import { MatIconModule } from '@angular/material/icon'; +import { ConfirmDialogService } from '@services/dialogs/confirm-dialog'; type OpenedId = 'flows' | 'blocks' | 'containers'; @@ -31,6 +32,7 @@ export class EditorSidebar { flowService = inject(FlowsService); blocksService = inject(BlocksService); containersService = inject(ContainersService); + confirm = inject(ConfirmDialogService); blockDisabled = computed(() => !this.flowState.hasFlow()); @@ -58,8 +60,17 @@ export class EditorSidebar { this.open = null; } - createNewFlow() { + async createNewFlow() { if (this.creatingFlow()) return; + + if (this.flowState.hasFlow() && this.flowState.isDirty()) { + const confirmed = await this.confirm.open( + 'You have unsaved changes. Close this flow and create a new one?' + ); + if (!confirmed) return; + this.flowState.closeDocument(); + } + this.creatingFlow.set(true); console.log('Creating new flow...'); this.flowService.createNewFlow().pipe(