[IMP] project: refactor to easily create right side panel components

Before this commit, the components created and used in the right side
panel are components for the `project.milestone` and we cannot reused
some components for another context.

This commit refactors a little bit to create a parent component with the
common code useful for another components than `project.milestone` ones.

task-2710808
This commit is contained in:
Xavier BOL (xbo)
2022-04-01 15:33:00 +02:00
committed by Laurent Stukkens (LTU)
parent 518a5becd6
commit 7df8cf0496
@@ -7,7 +7,26 @@ import { useService } from "@web/core/utils/hooks";
const { Component, onWillUpdateProps, useState } = owl;
class MilestoneComponent extends Component {
export class ProjectRightSidePanelComponent extends Component {
setup() {
super.setup();
this.contextValue = {};
}
async openLegacyFormDialog(params) {
const adapterParent = standaloneAdapter({ Component });
const dialog = new FormViewDialog(adapterParent, {
context: this.contextValue,
res_id: false,
...params,
});
await dialog.open();
return dialog;
}
}
ProjectRightSidePanelComponent.components = { ComponentAdapter };
class MilestoneComponent extends ProjectRightSidePanelComponent {
setup() {
super.setup();
this.contextValue = Object.assign({}, {
@@ -15,30 +34,14 @@ class MilestoneComponent extends Component {
}, this.props.context);
}
get context() {
return this.contextValue;
}
set context(value) {
this.contextValue = Object.assign({}, {
'default_project_id': value.active_id,
}, value);
}
async openLegacyFormDialog(params) {
const adapterParent = standaloneAdapter({ Component });
const dialog = new FormViewDialog(adapterParent, {
context: this.context,
return super.openLegacyFormDialog({
res_model: "project.milestone",
res_id: false,
on_saved: this.props.onMilestoneUpdate,
...params,
});
await dialog.open();
return dialog;
}
}
MilestoneComponent.components = { ComponentAdapter };
export class AddMilestone extends MilestoneComponent {
onAddMilestoneClick(event) {