Ends in:
1 DAY
5 HRS
3 MIN
55 SEC
Ends in:
1 D
5 H
3 M
55 S
Open Closed

handle discard changes , if user navigate to new page with out save #7492


User avatar
0
ramkumar.subramanian created

ABP Framework version : 7.4.3

Please help me in below implementation, if user fills the form and with out saving (formgroup) navigate to another page, system should prompt confirmation popup for "cancel" and "confirm" popup if confirm=>navigate to new clicked page cancel=> stay in same page

Tried below: but it is always navigating to new page**, cannot remain in same page , if cancel is clicked **

ngOnInit(): void{ this.documentListDuplicateerror = false; this.currentUser = this.config.getOne('currentUser'); this.getDocumentConfig();

this.routeSubscription = this.router.events.subscribe((event) => {

  debugger;
  if (event instanceof NavigationEnd) {
    console.log('Navigation ended:', event.url);
    // Execute your logic here, e.g., update component state

    alert(event.url);
  }
});

}

public ngOnDestroy() {

if (this.apPayableForm.dirty) {

  const options: Partial<Confirmation.Options> = {
    hideCancelBtn: false,
    hideYesBtn: false,
    dismissible: false,
    cancelText: 'Cancel',
    yesText: 'Confirm'

  };

  this.confirmation
    .warn('DocHubManagement::DocHub:ChangesWillDiscard', 'DocHubManagement::DocHub:DiscardChanges', options)
    .subscribe((status: Confirmation.Status) => {

      if (status == Confirmation.Status.confirm) {

        return true;
      }
      else {
        //this.saveDocHubConfiguration();
        //if cancel then previous page
        if (this.routeSubscription) {
          this.routeSubscription.unsubscribe();
        }
      }
    });

}

return true;

//if (this.routeSubscription) {
//  this.routeSubscription.unsubscribe();
//}

}


1 Answer(s)
  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello, I could not duplicate your issue on my side. Normally, the warning pop up should behave in the right way.

    For this reason, I suspect some other configuration that may result in this and that would be the best if you can share a sample project through this e-mail: sumeyye.kurtulus@volosoft.com

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19