Skip to content

Commit 8389722

Browse files
committed
[IMP] project: Improve ux
Before this commit: - project.task > list view: Currently, the progress is displayed in purple if less than 100% and in red if above. The two colors don't contrast a lot, making it hard to read. In addition, it is not coherent with the color we usually apply for the remaining hours in the rest of the app. - onbording tour: the manual saving step is no longer necessary as records are now automatically saved. In addition, showing it doesn't provide a wow effect and is an extra opportunity to lose people in the process After this commit: - the following color code was applied for the progress bar: *if progress < 80 -> green *if progress is between 80 and 100 included -> orange *if progress > 100 -> red - step removed. task-3475170
1 parent c399d82 commit 8389722

File tree

8 files changed

+52
-13
lines changed

8 files changed

+52
-13
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** @odoo-module **/
2+
3+
import { registry } from "@web/core/registry";
4+
import { progressBarField, ProgressBarField } from "@web/views/fields/progress_bar/progress_bar_field";
5+
6+
export class ProjectTaskProgressBarField extends ProgressBarField {
7+
get progressBarColorClass() {
8+
if (this.currentValue > this.maxValue) {
9+
return super.progressBarColorClass;
10+
}
11+
12+
return this.currentValue < 80 ? "bg-success" : "bg-warning";
13+
}
14+
}
15+
16+
export const projectTaskProgressBarField = {
17+
...progressBarField,
18+
component: ProjectTaskProgressBarField,
19+
};
20+
21+
registry.category("fields").add("project_task_progressbar", projectTaskProgressBarField);

addons/hr_timesheet/static/tests/hr_timesheet_common_tests.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ export const getServerData = () => JSON.parse(JSON.stringify({
3535
fields: {
3636
name: { string: "Name", type: "string" },
3737
project_id: { string: "Project", type: "many2one", relation: "project.project" },
38+
progress: { string: "progress", type: "float" },
3839
},
3940
records: [
40-
{ id: 1, name: "Task 1\u00A0AdditionalInfo", project_id: 1 },
41-
{ id: 2, name: "Task 2\u00A0AdditionalInfo", project_id: 1 },
42-
{ id: 3, name: "Task 3\u00A0AdditionalInfo", project_id: 1 },
41+
{ id: 1, name: "Task 1\u00A0AdditionalInfo", project_id: 1, progress: 50 },
42+
{ id: 2, name: "Task 2\u00A0AdditionalInfo", project_id: 1, progress: 80 },
43+
{ id: 3, name: "Task 3\u00A0AdditionalInfo", project_id: 1, progress: 104 },
4344
],
4445
},
4546
},

addons/hr_timesheet/static/tests/task_with_hours_tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,22 @@ QUnit.module("hr_timesheet", (hooks) => {
6464
assert.containsN(firstRow, '.o_list_many2one[name=task_id] .dropdown ul li:contains("AdditionalInfo")', 3);
6565
});
6666

67+
QUnit.test("project task progress bar color", async function (assert) {
68+
await makeView({
69+
serverData,
70+
type: "list",
71+
resModel: "project.task",
72+
arch: `
73+
<tree>
74+
<field name="name"/>
75+
<field name="project_id"/>
76+
<field name="progress" widget="project_task_progressbar" options="{'overflow_class': 'bg-danger'}"/>
77+
</tree>
78+
`,
79+
});
80+
81+
assert.containsOnce(target, "div.o_progressbar .bg-success", "Task 1 having progress = 50 < 80 => green color")
82+
assert.containsOnce(target, "div.o_progressbar .bg-warning", "Task 2 having progress = 80 >= 80 => orange color")
83+
assert.containsOnce(target, "div.o_progressbar .bg-success", "Task 3 having progress = 101 > 100 => red color")
84+
});
6785
});

addons/hr_timesheet/views/project_task_sharing_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<field name="subtask_effective_hours" string="Sub-tasks Hours Spent" widget="timesheet_uom" sum="Sub-tasks Hours Spent" optional="hide"/>
1313
<field name="total_hours_spent" string="Total Hours" widget="timesheet_uom" sum="Total Hours" optional="hide"/>
1414
<field name="remaining_hours" widget="timesheet_uom" sum="Remaining Hours" optional="hide" decoration-danger="progress &gt;= 100" decoration-warning="progress &gt;= 80 and progress &lt; 100"/>
15-
<field name="progress" widget="progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}"/>
15+
<field name="progress" widget="project_task_progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}"/>
1616
</xpath>
1717
<xpath expr="//field[@name='partner_id']" position="after">
1818
<field name="encode_uom_in_days" invisible="1"/>

addons/hr_timesheet/views/project_task_views.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<field name="subtask_effective_hours" widget="timesheet_uom" sum="Sub-tasks Hours Spent" optional="hide" groups="hr_timesheet.group_hr_timesheet_user"/>
1313
<field name="total_hours_spent" widget="timesheet_uom" sum="Total Hours" optional="hide" groups="hr_timesheet.group_hr_timesheet_user"/>
1414
<field name="remaining_hours" widget="timesheet_uom" sum="Remaining Hours" optional="hide" decoration-danger="progress &gt;= 100" decoration-warning="progress &gt;= 80 and progress &lt; 100" groups="hr_timesheet.group_hr_timesheet_user"/>
15-
<field name="progress" widget="progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}" groups="hr_timesheet.group_hr_timesheet_user"/>
15+
<field name="progress" widget="project_task_progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}" groups="hr_timesheet.group_hr_timesheet_user"/>
1616
</xpath>
1717
<xpath expr="//label[@for='date_deadline']" position="before">
1818
<field name="encode_uom_in_days" invisible="1"/>
@@ -148,7 +148,7 @@
148148
<field name="subtask_effective_hours" widget="timesheet_uom" optional="hide" groups="hr_timesheet.group_hr_timesheet_user"/>
149149
<field name="total_hours_spent" widget="timesheet_uom" optional="hide" groups="hr_timesheet.group_hr_timesheet_user"/>
150150
<field name="remaining_hours" widget="timesheet_uom" sum="Remaining Hours" optional="hide" decoration-danger="progress &gt;= 100" decoration-warning="progress &gt;= 80 and progress &lt; 100" groups="hr_timesheet.group_hr_timesheet_user"/>
151-
<field name="progress" widget="progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}" groups="hr_timesheet.group_hr_timesheet_user"/>
151+
<field name="progress" widget="project_task_progressbar" optional="hide" options="{'overflow_class': 'bg-danger'}" groups="hr_timesheet.group_hr_timesheet_user"/>
152152
</xpath>
153153
</field>
154154
</record>
@@ -166,7 +166,7 @@
166166
<field name="subtask_effective_hours" widget="timesheet_uom" sum="Sub-Tasks Total Effective Hours" optional="hide"/>
167167
<field name="total_hours_spent" widget="timesheet_uom" sum="Total Hours" optional="hide"/>
168168
<field name="remaining_hours" widget="timesheet_uom" sum="Total Remaining Hours" optional="hide" decoration-danger="progress &gt;= 100" decoration-warning="progress &gt;= 80 and progress &lt; 100" invisible="allocated_hours == 0"/>
169-
<field name="progress" widget="progressbar" avg="Average of Progress" optional="show" groups="hr_timesheet.group_hr_timesheet_user" invisible="allocated_hours == 0" options="{'overflow_class': 'bg-danger'}" />
169+
<field name="progress" widget="project_task_progressbar" avg="Average of Progress" optional="show" groups="hr_timesheet.group_hr_timesheet_user" invisible="allocated_hours == 0" options="{'overflow_class': 'bg-danger'}" />
170170
</field>
171171
</field>
172172
</record>

addons/project/static/src/js/tours/project.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ registry.category("web_tour.tours").add('project_tour', {
121121
}, {
122122
trigger: ".ui-autocomplete > li > a:not(:has(i.fa))",
123123
auto: true,
124-
}, {
125-
trigger: ".o_form_button_save",
126-
extra_trigger: '.o_form_project_tasks .o_form_dirty',
127-
content: markup(_t("You have unsaved changes - no worries! Odoo will automatically save it as you navigate.<br/> You can discard these changes from here or manually save your task.<br/>Let's save it manually.")),
128-
position: "bottom",
129124
}, {
130125
trigger: ".breadcrumb-item:not(.active):last",
131126
extra_trigger: '.o_form_project_tasks',

addons/web/static/src/views/fields/progress_bar/progress_bar_field.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export class ProgressBarField extends Component {
5454
return this.props.record.data[this.maxValueField] || 100;
5555
}
5656

57+
get progressBarColorClass() {
58+
return this.currentValue > this.maxValue ? this.props.overflowClass : "bg-primary";
59+
}
60+
5761
formatCurrentValue(humanReadable = !this.state.isEditing) {
5862
const formatter = formatters.get(Number.isInteger(this.currentValue) ? "integer" : "float");
5963
return formatter(this.currentValue, { humanReadable });

addons/web/static/src/views/fields/progress_bar/progress_bar_field.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="o_progressbar w-100 d-flex align-items-center" t-ref="numpadDecimal">
66
<div t-if="props.title" class="o_progressbar_title text-nowrap pe-1"><t t-esc="props.title"/></div>
77
<div class="o_progress align-middle overflow-hidden" aria-valuemin="0" t-att-aria-valuemax="this.maxValue" t-att-aria-valuenow="this.currentValue">
8-
<div t-attf-class="{{ this.currentValue > this.maxValue ? props.overflowClass : 'bg-primary' }} h-100" t-att-style="'width: min(' + 100 * this.currentValue / this.maxValue + '%, 100%)'"></div>
8+
<div t-attf-class="{{ progressBarColorClass }} h-100" t-att-style="'width: min(' + 100 * this.currentValue / this.maxValue + '%, 100%)'"></div>
99
</div>
1010
<div class="o_progressbar_value d-flex">
1111
<t t-if="isPercentage">

0 commit comments

Comments
 (0)