This commit is contained in:
gsinghpal
2026-03-13 12:38:28 -04:00
parent db4b9aa278
commit fc3c966484
2975 changed files with 1614 additions and 498 deletions

View File

@@ -0,0 +1,99 @@
import { useState, onWillStart, useEffect } from '@odoo/owl';
import { browser } from '@web/core/browser/browser';
import { patch } from '@web/core/utils/patch';
import { session } from '@web/session';
import {ControlPanel} from '@web/search/control_panel/control_panel';
patch(ControlPanel.prototype, {
setup() {
super.setup(...arguments);
this.autoLoadState = useState({
active: false,
counter: 0,
});
onWillStart(() => {
if (
this.checkAutoLoadAvailability() &&
this.getAutoLoadStorageValue()
) {
this.autoLoadState.active = true;
}
});
useEffect(
() => {
if (!this.autoLoadState.active) {
return;
}
this.autoLoadState.counter = (
this.getAutoLoadRefreshInterval()
);
const interval = browser.setInterval(
() => {
this.autoLoadState.counter = (
this.autoLoadState.counter ?
this.autoLoadState.counter - 1 :
this.getAutoLoadRefreshInterval()
);
if (this.autoLoadState.counter <= 0) {
this.autoLoadState.counter = (
this.getAutoLoadRefreshInterval()
);
if (this.pagerProps?.onUpdate) {
this.pagerProps.onUpdate({
offset: this.pagerProps.offset,
limit: this.pagerProps.limit
});
} else if (typeof this.env.searchModel?.search) {
this.env.searchModel.search();
}
}
},
1000
);
return () => browser.clearInterval(interval);
},
() => [this.autoLoadState.active]
);
},
checkAutoLoadAvailability() {
return ['kanban', 'list'].includes(this.env.config.viewType);
},
getAutoLoadRefreshInterval() {
return (session.pager_autoload_interval ?? 30000) / 1000;
},
getAutoLoadStorageKey() {
const keys = [
this.env?.config?.actionId ?? '',
this.env?.config?.viewType ?? '',
this.env?.config?.viewId ?? '',
];
return `pager_autoload:${keys.join(',')}`;
},
getAutoLoadStorageValue() {
return browser.localStorage.getItem(
this.getAutoLoadStorageKey()
);
},
setAutoLoadStorageValue() {
browser.localStorage.setItem(
this.getAutoLoadStorageKey(), true
);
},
removeAutoLoadStorageValue() {
browser.localStorage.removeItem(
this.getAutoLoadStorageKey()
);
},
toggleAutoLoad() {
this.autoLoadState.active = (
!this.autoLoadState.active
);
if (this.autoLoadState.active) {
this.setAutoLoadStorageValue();
} else {
this.removeAutoLoadStorageValue();
}
},
});

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-inherit="web.ControlPanel" t-inherit-mode="extension">
<xpath expr="//Pager/.." position="before">
<div
t-if="this.checkAutoLoadAvailability()"
class="d-inline-flex align-items-center gap-1 align-self-center"
>
<span
t-if="this.autoLoadState.active and this.autoLoadState.counter &gt; 0"
class="small text-muted"
>
<t t-out="this.autoLoadState.counter"/>s
</span>
<button
t-if="!env.isSmall"
class="btn btn-link p-0 d-inline-flex align-items-center justify-content-center"
type="button"
t-on-click.stop="this.toggleAutoLoad"
>
<i
class="fa fa-refresh fa-fw"
t-att-class="this.autoLoadState.active ? 'text-info fa-spin' : 'text-muted'"
/>
</button>
</div>
</xpath>
</t>
</templates>

View File

@@ -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 = 'fusion_backend_theme.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 });

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="fusion_backend_theme.CollapseGroups">
<DropdownItem
class="'o_fusion_collapse_groups'"
onSelected.bind="onCollapseButtonClicked"
>
<i class="fa fa-fw fa-compress me-1"/>Collapse All
</DropdownItem>
</t>
</templates>

View File

@@ -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 = 'fusion_backend_theme.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 });

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="fusion_backend_theme.ExpandGroups">
<DropdownItem
class="'o_fusion_expand_groups'"
onSelected.bind="onExpandButtonClicked"
>
<i class="fa fa-fw fa-expand me-1"/>Expand All
</DropdownItem>
</t>
</templates>