Some initial code to hook into the WithSearch component and check if we are using a HierarchicalListViewController.
This commit is contained in:
parent
8cf4d716b3
commit
43d2ed0172
6 changed files with 53 additions and 9 deletions
|
|
@ -28,7 +28,7 @@
|
||||||
'data': [],
|
'data': [],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'bemade_hierarchical_tree_view/src/*/**',
|
'bemade_hierarchical_tree_view/static/src/*/**',
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/** @odoo-module **/
|
|
||||||
|
|
||||||
import { ListController } from "@web/views/list/list_controller";
|
|
||||||
import { ListRenderer } from "@web/views/list/list_renderer";
|
|
||||||
|
|
||||||
export class HierarchicalTreeViewController extends ListController {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import { ListController } from "@web/views/list/list_controller";
|
||||||
|
|
||||||
|
export class HierarchicalTreeViewController extends ListController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HierarchicalTreeViewController.props = {
|
||||||
|
...ListController.props,
|
||||||
|
parentField: String,
|
||||||
|
childField: String,
|
||||||
|
}
|
||||||
|
HierarchicalTreeViewController.defaultProps = {
|
||||||
|
...ListController.defaultProps,
|
||||||
|
parentField: 'parent_id',
|
||||||
|
childField: 'child_id',
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import {patch} from "@web/core/utils/patch";
|
||||||
|
import {WithSearch} from "@web/search/with_search/with_search";
|
||||||
|
import {onWillRender} from "@odoo/owl";
|
||||||
|
import {HierarchicalTreeViewController} from "./hierarchical_tree_view_controller";
|
||||||
|
|
||||||
|
patch(WithSearch.prototype, "bemade_hierarchical_tree_view/with_search", {
|
||||||
|
setup() {
|
||||||
|
onWillRender(() => {
|
||||||
|
let children = Object.hasOwn(this.__owl__, 'children') ? this.__owl__.children : null;
|
||||||
|
if (children && Object.keys(children).length !== 0) {
|
||||||
|
for (let childProp in children) {
|
||||||
|
let child = children[childProp];
|
||||||
|
if (Object.hasOwn(child, 'component')) {
|
||||||
|
let childComponent = child.component;
|
||||||
|
if (childComponent.prototype == HierarchicalTreeViewController.prototype) {
|
||||||
|
let parentField, childField = (childComponent.parentField, childComponent.childField)
|
||||||
|
let parentIndex = this.groupBy.indexOf(parentField);
|
||||||
|
let childIndex = this.groupBy.indexOf(childField);
|
||||||
|
if (parentIndex) {
|
||||||
|
this.groupBy.splice(parentField, 1);
|
||||||
|
}
|
||||||
|
if (childField) {
|
||||||
|
this.groupBy.splice(childField, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this._super();
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue