Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion project_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Project UX",
"version": "19.0.2.1.0",
"version": "19.0.2.2.0",
"category": "Project Management",
"sequence": 14,
"author": "ADHOC SA",
Expand All @@ -35,6 +35,12 @@
"views/project_project_views.xml",
"views/project_task_type_views.xml",
],
"assets": {
"web.assets_backend": [
"project_ux/static/src/**/*.js",
"project_ux/static/src/**/*.xml",
],
},
"demo": [],
"installable": True,
"auto_install": False,
Expand Down
23 changes: 23 additions & 0 deletions project_ux/static/src/js/project_task_control_panel_patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { patch } from "@web/core/utils/patch";
import { ProjectTaskControlPanel } from "@project/views/project_task_control_panel/project_task_control_panel";
import { hasSubtaskLeaf } from "./subtask_domain";

patch(ProjectTaskControlPanel.prototype, {
/**
* The "Is Sub-Task" filter forces sub-tasks to be visible: the model drops
* the `display_in_project` restriction while that filter is active (see
* project_task_list_model_patch). While it is active the "Show Sub-Tasks"
* toggle has no real effect.
*/
get isSubtaskFilterActive() {
return hasSubtaskLeaf(this.env.searchModel.domain);
},

/**
* State the toggle is painted with: also selected when the filter forces
* it, to avoid the confusing "off but showing sub-tasks" state.
*/
get effectiveShowSubtasks() {
return this.state.showSubtasks || this.isSubtaskFilterActive;
},
});
25 changes: 25 additions & 0 deletions project_ux/static/src/js/project_task_list_model_patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { patch } from "@web/core/utils/patch";
import { Domain } from "@web/core/domain";
import { ProjectTaskRelationalModel } from "@project/views/project_task_relational_model";
import { hasSubtaskLeaf } from "./subtask_domain";

patch(ProjectTaskRelationalModel.prototype, {
/**
* When the user filters explicitly by sub-tasks ("Is Sub-Task" filter),
* the core still hides them while the "Show Sub-Tasks" mode is off: it
* injects `display_in_project = True`, which is False for any sub-task
* sharing its parent's project. The result is an empty list with no hint,
* so the sub-task looks like it does not exist.
*
* If the sub-task filter is active, drop that leaf to honor the filter and
* show the sub-tasks without requiring the user to toggle the display mode
* by hand.
*/
_processSearchDomain(domain) {
const processed = super._processSearchDomain(domain);
if (hasSubtaskLeaf(domain)) {
return Domain.removeDomainLeaves(processed, ["display_in_project"]).toList({});
}
return processed;
},
});
26 changes: 26 additions & 0 deletions project_ux/static/src/js/subtask_domain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Whether a search domain explicitly restricts results to sub-tasks, i.e. it
* contains a `parent_id != False` leaf (as emitted by the "Is Sub-Task"
* filter). Walks the domain in list form, including nested sub-domains.
*
* @param {Array} domain domain in list form
* @returns {boolean}
*/
export function hasSubtaskLeaf(domain) {
if (!Array.isArray(domain)) {
return false;
}
for (const item of domain) {
if (!Array.isArray(item)) {
continue;
}
if (item.length === 3) {
if (item[0] === "parent_id" && item[1] === "!=" && item[2] === false) {
return true;
}
} else if (hasSubtaskLeaf(item)) {
return true;
}
}
return false;
}
20 changes: 20 additions & 0 deletions project_ux/static/src/xml/project_task_control_panel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="project_ux.ProjectTaskControlPanel"
t-inherit="project.ProjectTaskControlPanel"
t-inherit-mode="extension">
<xpath expr="//DropdownItem[@onSelected=&quot;() =&gt; this.onClickShowSubtasks()&quot;]" position="attributes">
<attribute name="class">effectiveShowSubtasks ? 'selected' : ''</attribute>
</xpath>
</t>

<t t-name="project_ux.MobileCombinedActionsDropdown"
t-inherit="project.MobileCombinedActionsDropdown"
t-inherit-mode="extension">
<xpath expr="//DropdownItem[@onSelected=&quot;() =&gt; this.onClickShowSubtasks()&quot;]" position="attributes">
<attribute name="class">effectiveShowSubtasks ? 'selected' : ''</attribute>
</xpath>
</t>

</templates>