[IMP] project: new ProjectControlPanel class
The reporting views are going to be converted to OWL so that their extensions (like the project_graph and project_pivot views) have to be converted too. We thus need an owl version of the ProjectControlPanel class. Here we introduce that control panel and refactor a bit the legacy code. Part-of: odoo/odoo#73311
This commit is contained in:
committed by
Aaron Bohy
parent
e7a9ebec31
commit
23e84c1750
@@ -59,6 +59,7 @@
|
||||
'post_init_hook': '_project_post_init',
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'project/static/src/project_control_panel/*',
|
||||
'project/static/src/css/project.css',
|
||||
'project/static/src/js/project_activity.js',
|
||||
'project/static/src/js/project_control_panel.js',
|
||||
@@ -85,7 +86,7 @@
|
||||
'project/static/src/js/portal_rating.js',
|
||||
],
|
||||
'web.assets_qweb': [
|
||||
'project/static/src/xml/**/*',
|
||||
'project/static/src/**/*.xml',
|
||||
],
|
||||
'web.qunit_suite_tests': [
|
||||
'project/static/tests/burndown_chart_tests.js',
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { ControlPanel } from "@web/search/control_panel/control_panel";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
|
||||
export class ProjectControlPanel extends ControlPanel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.orm = useService("orm");
|
||||
this.user = useService("user");
|
||||
const { active_id, show_project_update } = this.env.searchModel.globalContext;
|
||||
this.showProjectUpdate = this.env.searchModel.view.type === "form" || show_project_update;
|
||||
this.projectId = this.showProjectUpdate ? active_id : false;
|
||||
}
|
||||
|
||||
async willStart() {
|
||||
const proms = [super.willStart(...arguments)];
|
||||
if (this.showProjectUpdate) {
|
||||
proms.push(this.loadData());
|
||||
}
|
||||
await Promise.all(proms);
|
||||
}
|
||||
|
||||
async willUpdateProps() {
|
||||
const proms = [super.willUpdateProps(...arguments)];
|
||||
if (this.showProjectUpdate) {
|
||||
proms.push(this.loadData());
|
||||
}
|
||||
await Promise.all(proms);
|
||||
}
|
||||
|
||||
async loadData() {
|
||||
const [data, isProjectUser] = await Promise.all([
|
||||
this.orm.call("project.project", "get_last_update_or_default", [this.projectId]),
|
||||
this.user.hasGroup("project.group_project_user"),
|
||||
]);
|
||||
this.data = data;
|
||||
this.isProjectUser = isProjectUser;
|
||||
}
|
||||
|
||||
async onStatusClick(ev) {
|
||||
ev.preventDefault();
|
||||
this.actionService.doAction("project.project_update_all_action", {
|
||||
additionalContext: {
|
||||
default_project_id: this.projectId,
|
||||
active_id: this.projectId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
ProjectControlPanel.template = "project.ProjectControlPanel";
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="project.ProjectControlPanelContentBadge" owl="1">
|
||||
<t t-tag="isProjectUser ? 'button' : 'span'" class="badge border d-flex p-2 ml-2 bg-white">
|
||||
<span t-attf-class="o_status_bubble o_color_bubble_{{data.color}}"/>
|
||||
<span class="font-weight-normal ml-1" t-esc="data.status"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="project.ProjectControlPanelContent" owl="1">
|
||||
<t t-if="showProjectUpdate">
|
||||
<li t-if="isProjectUser" class="o_project_updates_breadcrumb pl-3" t-on-click="onStatusClick">
|
||||
<t t-call="project.ProjectControlPanelContentBadge"></t>
|
||||
</li>
|
||||
<li t-else="" class="o_project_updates_breadcrumb pl-3">
|
||||
<t t-call="project.ProjectControlPanelContentBadge"></t>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="project.Breadcrumbs" t-inherit="web.Breadcrumbs" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="//ol" position="inside">
|
||||
<t t-call="project.ProjectControlPanelContent"/>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-name="project.ProjectControlPanel" t-inherit="web.ControlPanel" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="//t[@t-call='web.Breadcrumbs']" position="replace">
|
||||
<t t-call="project.Breadcrumbs"/>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -19,28 +19,13 @@
|
||||
|
||||
<div t-name="project.ControlPanel" t-inherit="web.Legacy.ControlPanel" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//ol[hasclass('breadcrumb')]" position="inside">
|
||||
<t t-call="project.ControlPanelContent"/>
|
||||
<t t-call="project.ProjectControlPanelContent">
|
||||
<t t-set="showProjectUpdate" t-value="show_project_update"/>
|
||||
<t t-set="isProjectUser" t-value="is_project_user"/>
|
||||
</t>
|
||||
</xpath>
|
||||
</div>
|
||||
|
||||
<t t-name="project.ControlPanelContentBadge" owl="1">
|
||||
<t t-tag="is_project_user ? 'button' : 'span'" class="badge border d-flex p-2 ml-2 bg-white">
|
||||
<span t-attf-class="o_status_bubble o_color_bubble_{{data.color}}"/>
|
||||
<span class="font-weight-normal ml-1" t-esc="data.status"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="project.ControlPanelContent" owl="1">
|
||||
<t t-if="show_project_update">
|
||||
<li t-if="is_project_user" class="o_project_updates_breadcrumb pl-3" t-on-click="onStatusClick">
|
||||
<t t-call="project.ControlPanelContentBadge"></t>
|
||||
</li>
|
||||
<li t-else="" class="o_project_updates_breadcrumb pl-3">
|
||||
<t t-call="project.ControlPanelContentBadge"></t>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="project.ProjectRightPanel" owl="1">
|
||||
<div class="o_rightpanel">
|
||||
<t t-call="project.StatButtonsSection"/>
|
||||
|
||||
Reference in New Issue
Block a user