Skip to content

Commit 42a539b

Browse files
committed
start apply o_dirty when start editon
1 parent fc89a31 commit 42a539b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

addons/html_builder/static/src/core/save_plugin.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class SavePlugin extends Plugin {
1212
static shared = ["save"];
1313

1414
resources = {
15-
handleNewRecords: this.handleMutations,
15+
handleNewRecords: this.handleMutations.bind(this),
16+
start_edition_handlers: this.startObserving.bind(this),
1617
// Resource definitions:
1718
before_save_handlers: [
1819
// async () => {
@@ -33,6 +34,10 @@ export class SavePlugin extends Plugin {
3334
get_dirty_els: () => this.editable.querySelectorAll(".o_dirty"),
3435
};
3536

37+
setup() {
38+
this.canObserve = false;
39+
}
40+
3641
async save() {
3742
// TODO: implement the "group by" feature for save
3843
const proms = [];
@@ -173,13 +178,19 @@ export class SavePlugin extends Plugin {
173178
return escapedEl;
174179
}
175180

181+
startObserving() {
182+
this.canObserve = true;
183+
}
176184
/**
177185
* Handles the flag of the closest savable element to the mutation as dirty
178186
*
179187
* @param {Object} records - The observed mutations
180188
* @param {String} currentOperation - The name of the current operation
181189
*/
182190
handleMutations(records, currentOperation) {
191+
if (!this.canObserve) {
192+
return;
193+
}
183194
if (currentOperation === "undo" || currentOperation === "redo") {
184195
// Do nothing as `o_dirty` has already been handled by the history
185196
// plugin.

0 commit comments

Comments
 (0)