-
Notifications
You must be signed in to change notification settings - Fork 248
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
(feat) O3-4014: Add ability to warn user of unsaved changes on form-entry-app #2031
Conversation
Size Change: -515 kB (-3.36%) Total Size: 14.8 MB
ℹ️ View Unchanged
|
packages/esm-form-entry-app/src/app/fe-wrapper/fe-wrapper.component.ts
Outdated
Show resolved
Hide resolved
One other thing worth doing is cleaning up the subscription when the component unmounts. We could use something like: private workspaceDirtyStateListenerSubscription: Subscription;
public ngOnDestroy() {
// ... existing code
this.workspaceDirtyStateListenerSubscription?.unsubscribe();
}
// and then...
private setupWorkspaceDirtyStateListener(): void {
const promptBeforeClosing = this.singleSpaPropsService.getPropOrThrow('promptBeforeClosing');
this.workspaceDirtyStateListenerSubscription = this.form.rootNode.control.valueChanges
.pipe(
map(() => this.form.rootNode.control.dirty),
filter((isDirty) => isDirty),
take(1),
)
.subscribe(() => {
promptBeforeClosing(() => true);
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @donaldkibet. Generally LGTM sans a couple suggestions about using the form's actual dirty
state and cleanup for the subscription to prevent memory leaks.
79c5fc6
to
b766b91
Compare
b766b91
to
157fd04
Compare
…ntry-app (openmrs#2031) * (feat) : add ability to warn user of unsaved changes on form-entry-app * code reviews changes
Requirements
Summary
This PR adds ability to warn user before closing unsaved form while using angular form engine
Screenshots
Kapture.2024-09-24.at.14.38.19.mp4
Related Issue
Other