mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-25 00:32:01 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
|
|
@ -0,0 +1,33 @@
|
|||
import { ActionMenus } from "@web/search/action_menus/action_menus";
|
||||
import { getActionRecords, getPresenceActionItems } from "../../views/hooks";
|
||||
|
||||
/**
|
||||
* @extends ActionMenus
|
||||
*/
|
||||
export class HrPresenceActionMenus extends ActionMenus {
|
||||
static template = "hr_presence.actionmenu";
|
||||
|
||||
get PresenceActionItems() {
|
||||
return (this.presenceActionItems || []).map((action) => {
|
||||
return {
|
||||
action,
|
||||
description: action.name,
|
||||
key: action.id,
|
||||
groupNumber: action.groupNumber,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async getActionItems(props) {
|
||||
const records = await getActionRecords(this.orm);
|
||||
const result = getPresenceActionItems(props.items.action, records);
|
||||
|
||||
props.items.action = result[0];
|
||||
this.presenceActionItems = result[1];
|
||||
|
||||
return await super.getActionItems(props);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="hr_presence.actionmenu" t-inherit="web.ActionMenus" t-inherit-mode="primary">
|
||||
<xpath expr="//div[@t-if='props.items.print?.length']" position="before">
|
||||
<t t-if="PresenceActionItems.length" class="d-inline-block">
|
||||
<t t-call="hr_presence.menu">
|
||||
<t t-set="is_actionmenu" t-value="'True'"/>
|
||||
</t>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import { FormCogMenu } from "@web/views/form/form_cog_menu/form_cog_menu";
|
||||
import { onWillStart } from "@odoo/owl";
|
||||
import { getActionRecords, getPresenceActionItems } from "../../views/hooks";
|
||||
|
||||
/**
|
||||
* @extends CogMenu
|
||||
*/
|
||||
export class HrPresenceCogMenu extends FormCogMenu {
|
||||
static template = "hr_presence.cogmenu";
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
this.presenceActionItems = [];
|
||||
|
||||
onWillStart(async () => {
|
||||
await super.onWillStart;
|
||||
this.records = await getActionRecords(this.orm);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
get cogItems() {
|
||||
var result = super.cogItems;
|
||||
result = getPresenceActionItems(result, this.records);
|
||||
this.presenceActionItems = result[1];
|
||||
return result[0];
|
||||
}
|
||||
|
||||
get PresenceActionItems() {
|
||||
return this.presenceActionItems;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="hr_presence.cogmenu" t-inherit="web.FormCogMenu" t-inherit-mode="primary">
|
||||
<xpath expr="//t[@t-if='state.printItems.length']" position="after">
|
||||
<t t-if="PresenceActionItems.length">
|
||||
<t t-call="hr_presence.menu">
|
||||
<t t-set="is_actionmenu" t-value="''"/>
|
||||
</t>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-name="hr_presence.menu">
|
||||
<Dropdown>
|
||||
<button t-attf-class="{{ is_actionmenu ? 'btn btn-secondary' : '' }}">
|
||||
<i class="fa fa-clock-o me-1"/>
|
||||
<span class="o_dropdown_title">Presence Control</span>
|
||||
</button>
|
||||
<t t-set-slot="content">
|
||||
<t t-foreach="PresenceActionItems" t-as="item" t-key="item.key">
|
||||
<t t-if="currentGroup !== null and currentGroup !== item.groupNumber">
|
||||
<div role="separator" class="dropdown-divider"/>
|
||||
</t>
|
||||
<DropdownItem class="'o_menu_item'" onSelected="() => this.onItemSelected(item)">
|
||||
<t t-esc="item.description"/>
|
||||
</DropdownItem>
|
||||
<t t-set="currentGroup" t-value="item.groupNumber"/>
|
||||
</t>
|
||||
</t>
|
||||
</Dropdown>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
export async function getActionRecords(orm) {
|
||||
return await orm.call("hr.employee", "get_presence_server_action_data", [[]]);
|
||||
}
|
||||
export function getPresenceActionItems(actions, records) {
|
||||
const presenceActionItems = [];
|
||||
const presenceRecords = {
|
||||
group_1: records
|
||||
.filter((record) => record.value === "presence_group_1")
|
||||
.map((record) => record.id),
|
||||
group_2: records
|
||||
.filter((record) => record.value === "presence_group_2")
|
||||
.map((record) => record.id),
|
||||
};
|
||||
actions = (actions || []).filter((action) => {
|
||||
const isInGroup1 = presenceRecords["group_1"].includes(action.key || action.id);
|
||||
const isInGroup2 = presenceRecords["group_2"].includes(action.key || action.id);
|
||||
if (isInGroup1 || isInGroup2) {
|
||||
action.groupNumber = isInGroup1 ? 50 : 60;
|
||||
presenceActionItems.push(action);
|
||||
return false; // Exclude this object from the resulting array
|
||||
}
|
||||
return true; // Include this object in the resulting array
|
||||
});
|
||||
return [actions, presenceActionItems];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { EmployeeFormController } from "@hr/views/form_view";
|
||||
import { HrPresenceCogMenu } from "../search/hr_presence_cog_menu/hr_presence_cog_menu";
|
||||
|
||||
patch(EmployeeFormController, {
|
||||
components: {
|
||||
...EmployeeFormController.components,
|
||||
CogMenu: HrPresenceCogMenu,
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { EmployeeListController } from '@hr/views/list_view';
|
||||
import { HrPresenceActionMenus } from "../search/hr_presence_action_menus/hr_presence_action_menus";
|
||||
|
||||
patch(EmployeeListController, {
|
||||
components: {
|
||||
...EmployeeListController.components,
|
||||
ActionMenus: HrPresenceActionMenus,
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue