mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: prevent saving on switching tab
Auto save mechanism when switching tab is unwanted in runbot, most of the time we will use other tabs to get the data necessary for the record we are modifying/creating and we don't care about saving yet. We also prevent closing the window if the record is dirty. Auto save in pager and context switch is still kept.
This commit is contained in:
parent
d8d9f411b1
commit
761e671aa6
@ -64,6 +64,7 @@
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'runbot/static/src/libs/diff_match_patch/diff_match_patch.js',
|
||||
'runbot/static/src/js/views/**/*',
|
||||
'runbot/static/src/js/fields/*',
|
||||
],
|
||||
'runbot.assets_frontend': [
|
||||
|
19
runbot/static/src/js/views/form_controller.js
Normal file
19
runbot/static/src/js/views/form_controller.js
Normal file
@ -0,0 +1,19 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { FormController } from '@web/views/form/form_controller';
|
||||
import { patch } from '@web/core/utils/patch';
|
||||
|
||||
|
||||
patch(FormController.prototype, {
|
||||
// Prevent saving on tab switching
|
||||
beforeVisibilityChange: () => {},
|
||||
// Prevent closing page with dirty fields
|
||||
async beforeUnload(ev) {
|
||||
if (await this.model.root.isDirty()) {
|
||||
ev.preventDefault();
|
||||
ev.returnValue = 'Unsaved changes';
|
||||
} else {
|
||||
super.beforeUnload(ev);
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user