Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable unsaved-changes guard after logout #13

Closed
KKostis opened this issue Jan 5, 2021 · 4 comments
Closed

Disable unsaved-changes guard after logout #13

KKostis opened this issue Jan 5, 2021 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@KKostis
Copy link

KKostis commented Jan 5, 2021

Hello!

I have been using the unsaved-changes module and have encountered the following issue. On logout, I want to redirect the user to the login page. However, if the user has been editing a form at the time of logout, without having saved the changes, the guard pops up requiring a confirmation. The issue is that the user has already logged out (a confirmation dialog has already popped-up), so I don't want the guard to check for unsaved changes in the form. I noticed that the unsaved-changes service provides the unwatch function to ignore a dirty form, however since the logout button is located elsewhere (different component), I don't have access to the necessary form id. A solution would be to store the active form id in a service and use it to unwatch the corresponding form when needed, but that would require to store a new form id every time a form gets rendered. Is there a way to ignore all the changes manually at once (for example by emptying the formList property in the unsaved-changes service)?

@gillerr
Copy link
Collaborator

gillerr commented Jan 7, 2021

Hello

This is an interesting problem. Oblique don't currently provide a mean to achieve this, we'll need to think of a solution. Maybe with a isDisabled variable that makes the service simply ignore the changes. This would mean you will have to inject the ObUnsavedChangesService into the component that performs the logout and set the isDisabled to false. Then upon login, you should reset its value to true. Would such a solution be acceptable to you?

@gillerr gillerr added the enhancement New feature or request label Jan 7, 2021
@KKostis
Copy link
Author

KKostis commented Jan 11, 2021

I suppose you mean the opposite. On logout set isDisabled to true, to basically disable the change detection and on login set is disabled to false. Yes, the proposed solution is simple and straight forward! Thank you!

@gillerr gillerr added this to the 6.0.0 milestone Jan 11, 2021
@gillerr
Copy link
Collaborator

gillerr commented Jan 11, 2021

Ewh yes I meant it that way. If I don't come with a better idea, it will be implemented that way.

@gillerr gillerr modified the milestones: 6.0.0, 6.1.0 Feb 2, 2021
@gillerr
Copy link
Collaborator

gillerr commented Apr 6, 2021

Release with Oblique 6.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants