[init/add] generic backend theme
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { Component } from '@odoo/owl';
|
||||
import { registry } from '@web/core/registry';
|
||||
import { DropdownItem } from '@web/core/dropdown/dropdown_item';
|
||||
|
||||
const cogMenuRegistry = registry.category('cogMenu');
|
||||
|
||||
export class CollapseAll extends Component {
|
||||
|
||||
static template = 'muk_web_group.CollapseAll';
|
||||
static components = { DropdownItem };
|
||||
static props = {};
|
||||
|
||||
async onCollapseButtonClicked() {
|
||||
let groups = this.env.model.root.groups;
|
||||
while (groups.length) {
|
||||
const unfoldedGroups = groups.filter(
|
||||
(group) => !group._config.isFolded
|
||||
);
|
||||
if (unfoldedGroups.length) {
|
||||
for (const group of unfoldedGroups) {
|
||||
await group.toggle();
|
||||
}
|
||||
}
|
||||
const subGroups = unfoldedGroups.map(
|
||||
(group) => group.list.groups || []
|
||||
);
|
||||
groups = subGroups.reduce(
|
||||
(a, b) => a.concat(b), []
|
||||
);
|
||||
}
|
||||
await this.env.model.root.load();
|
||||
this.env.model.notify();
|
||||
}
|
||||
}
|
||||
|
||||
export const collapseAllItem = {
|
||||
Component: CollapseAll,
|
||||
groupNumber: 15,
|
||||
isDisplayed: async (env) => (
|
||||
['kanban', 'list'].includes(env.config.viewType) &&
|
||||
env.model.root.isGrouped
|
||||
)
|
||||
};
|
||||
|
||||
cogMenuRegistry.add('collapse-all-menu', collapseAllItem, { sequence: 2 });
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="muk_web_group.CollapseAll">
|
||||
<DropdownItem
|
||||
class="'mk_collapse_all_menu'"
|
||||
onSelected.bind="onCollapseButtonClicked"
|
||||
>
|
||||
<i class="fa fa-fw fa-compress me-1"/>Collapse All
|
||||
</DropdownItem>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Component } from '@odoo/owl';
|
||||
import { registry } from '@web/core/registry';
|
||||
import { DropdownItem } from '@web/core/dropdown/dropdown_item';
|
||||
|
||||
const cogMenuRegistry = registry.category('cogMenu');
|
||||
|
||||
export class ExpandAll extends Component {
|
||||
|
||||
static template = 'muk_web_group.ExpandAll';
|
||||
static components = { DropdownItem };
|
||||
static props = {};
|
||||
|
||||
async onExpandButtonClicked() {
|
||||
let groups = this.env.model.root.groups;
|
||||
while (groups.length) {
|
||||
const foldedGroups = groups.filter(
|
||||
(group) => group._config.isFolded
|
||||
);
|
||||
if (foldedGroups.length) {
|
||||
for (const group of foldedGroups) {
|
||||
await group.toggle();
|
||||
}
|
||||
}
|
||||
const subGroups = foldedGroups.map(
|
||||
(group) => group.list.groups || []
|
||||
);
|
||||
groups = subGroups.reduce(
|
||||
(a, b) => a.concat(b), []
|
||||
);
|
||||
}
|
||||
await this.env.model.root.load();
|
||||
this.env.model.notify();
|
||||
}
|
||||
}
|
||||
|
||||
export const expandAllItem = {
|
||||
Component: ExpandAll,
|
||||
groupNumber: 15,
|
||||
isDisplayed: async (env) => (
|
||||
['kanban', 'list'].includes(env.config.viewType) &&
|
||||
env.model.root.isGrouped
|
||||
)
|
||||
};
|
||||
|
||||
cogMenuRegistry.add('expand-all-menu', expandAllItem, { sequence: 1 });
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="muk_web_group.ExpandAll">
|
||||
<DropdownItem
|
||||
class="'mk_expand_all_menu'"
|
||||
onSelected.bind="onExpandButtonClicked"
|
||||
>
|
||||
<i class="fa fa-fw fa-expand me-1"/>Expand All
|
||||
</DropdownItem>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Reference in New Issue
Block a user