Browse Source

Apr 17 [UPDT] : Bug Fixed 'auto_save_restrict'

pull/313/head
AjmalCybro 1 year ago
parent
commit
0cd3aa9195
  1. 5
      auto_save_restrict/doc/RELEASE_NOTES.md
  2. 7
      auto_save_restrict/static/src/js/form_controller.js

5
auto_save_restrict/doc/RELEASE_NOTES.md

@ -10,3 +10,8 @@
##### BUG FIX ##### BUG FIX
- Updated the module by removing the auto save option while reloading - Updated the module by removing the auto save option while reloading
the page in form and tree. the page in form and tree.
#### 17.04.2024
#### Version 17.0.1.0.2
##### BUG FIX
- Fixed the issue in the form where the popup appeared repeatedly

7
auto_save_restrict/static/src/js/form_controller.js

@ -6,6 +6,7 @@ patch(FormController.prototype, {
/* Patch FormController to restrict auto save in form views */ /* Patch FormController to restrict auto save in form views */
setup(){ setup(){
super.setup(...arguments); super.setup(...arguments);
this.beforeLeaveHook = false
useSetupView({ useSetupView({
beforeLeave: () => this.beforeLeave(), beforeLeave: () => this.beforeLeave(),
beforeUnload: (ev) => this.beforeUnload(ev), beforeUnload: (ev) => this.beforeUnload(ev),
@ -13,14 +14,16 @@ patch(FormController.prototype, {
}, },
async beforeLeave() { async beforeLeave() {
/* function will work before leave the form */ /* function will work before leave the form */
if(this.model.root.dirty){ if(this.model.root.isDirty && this.beforeLeaveHook == false){
if (confirm("Do you want to save changes before leaving?")) { if (confirm("Do you want to save changes before leaving?")) {
this.beforeLeaveHook = true
await this.model.root.save({ await this.model.root.save({
reload: false, reload: false,
onError: this.onSaveError.bind(this), onError: this.onSaveError.bind(this),
}); });
} else { } else {
this.discard(); this.beforeLeaveHook = true
this.model.root.discard();
} }
} }
}, },

Loading…
Cancel
Save