Skip to content

Commit

Permalink
[FIX] figures: deleting a sheet will remove all figures
Browse files Browse the repository at this point in the history
when deleting a sheet, we expect all the figures of that sheet to be deleted.
However overrides of figures might only implement "DELETE_FIGURE".
Also, implementing correctly "DELETE_SHEET" in all plugins that extends figures
means that they would have to use beforeHandle to store the references of
the figures of the sheet to be deleted, then in the handle do the deleting
based on the saved values. It's a bit ugly.

From 16.0, we need to remove the figures in the beforeHandle because
the figures themselves need the sheet to still be present to be removed.

opw-3783745

closes #3838

X-original-commit: fe43a5b
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
  • Loading branch information
VincentSchippefilt committed Mar 15, 2024
1 parent 3d5b815 commit 1fc912d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/core/figures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export class FigurePlugin extends CorePlugin<FigureState> implements FigureState
}
}

beforeHandle(cmd: CoreCommand) {
switch (cmd.type) {
case "DELETE_SHEET":
this.getters.getFigures(cmd.sheetId).forEach((figure) => {
this.dispatch("DELETE_FIGURE", { id: figure.id, sheetId: cmd.sheetId });
});
break;
}
}

handle(cmd: CoreCommand) {
switch (cmd.type) {
case "CREATE_SHEET":
Expand Down

0 comments on commit 1fc912d

Please sign in to comment.