@@ -117,8 +117,13 @@ export class OwnerDialogComponent {
117117
118118 this . isLoading = true ;
119119
120+ let shouldContinue = false ;
120121 if ( this . type . value === OWNER_TYPE . INDIVIDUAL ) {
121- this . removeCorporateSummary ( ) ;
122+ shouldContinue = await this . removeCorporateSummary ( ) ;
123+ if ( ! shouldContinue ) {
124+ this . isLoading = false ;
125+ return ;
126+ }
122127 }
123128
124129 let documentUuid ;
@@ -178,8 +183,14 @@ export class OwnerDialogComponent {
178183 if ( this . form . valid ) {
179184 this . isLoading = true ;
180185
186+ let shouldContinue = false ;
181187 if ( this . type . value === OWNER_TYPE . INDIVIDUAL ) {
182- this . removeCorporateSummary ( ) ;
188+ shouldContinue = await this . removeCorporateSummary ( ) ;
189+
190+ if ( ! shouldContinue ) {
191+ this . isLoading = false ;
192+ return ;
193+ }
183194 }
184195
185196 let document ;
@@ -235,27 +246,33 @@ export class OwnerDialogComponent {
235246 }
236247 }
237248
238- removeCorporateSummary ( ) {
239- if ( this . data . isDraft ) {
240- this . dialog
241- . open ( RemoveFileConfirmationDialogComponent )
242- . beforeClosed ( )
243- . subscribe ( async ( didConfirm ) => {
244- if ( didConfirm ) {
245- if ( this . pendingFile ) {
246- this . pendingFile = undefined ;
249+ removeCorporateSummary ( ) : Promise < boolean > {
250+ return new Promise < boolean > ( ( resolve ) => {
251+ if ( this . data . isDraft && ( this . pendingFile || this . files . length > 0 ) ) {
252+ this . dialog
253+ . open ( RemoveFileConfirmationDialogComponent )
254+ . beforeClosed ( )
255+ . subscribe ( async ( didConfirm ) => {
256+ if ( didConfirm ) {
257+ if ( this . pendingFile ) {
258+ this . pendingFile = undefined ;
259+ }
260+ this . corporateSummary . setValue ( null ) ;
261+ this . files = [ ] ;
262+ resolve ( true ) ; // User confirmed, continue with the operation
263+ } else {
264+ resolve ( false ) ; // User canceled, don't continue
247265 }
248- this . corporateSummary . setValue ( null ) ;
249- this . files = [ ] ;
250- }
251- } ) ;
252- } else {
253- if ( this . pendingFile ) {
254- this . pendingFile = undefined ;
266+ } ) ;
267+ } else {
268+ if ( this . pendingFile ) {
269+ this . pendingFile = undefined ;
270+ }
271+ this . corporateSummary . setValue ( null ) ;
272+ this . files = [ ] ;
273+ resolve ( true ) ; // No confirmation dialog needed, continue
255274 }
256- this . corporateSummary . setValue ( null ) ;
257- this . files = [ ] ;
258- }
275+ } ) ;
259276 }
260277
261278 async openCorporateSummary ( ) {
0 commit comments