!9302 Merge branch 'dev' of <a href="https://gitee.com/jinan-pengyusen-data/gzth">https://gitee.com/jinan-pengyusen-data/gzth</a> into dev_wang
Merge pull request !9302 from 李鹏宇/dev_wang
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { ganttView } from "@web_gantt/gantt_view";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
|
||||
class RoomBookingGanttController extends ganttView.Controller {
|
||||
/**
|
||||
@@ -30,10 +32,46 @@ class RoomBookingGanttModel extends ganttView.Model {
|
||||
}
|
||||
}
|
||||
|
||||
class RoomBookingGanttRenderer extends ganttView.Renderer {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.userService = useService("user");
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* 只有系统管理员或会议创建人才显示"编辑"按钮,其他人不显示该按钮。
|
||||
*/
|
||||
getPopoverProps(pill) {
|
||||
const props = super.getPopoverProps(pill);
|
||||
const { record } = pill;
|
||||
const currentUserId = this.userService.userId;
|
||||
const isAdmin = this.userService.isAdmin;
|
||||
// organizer_id 是 [id, name] 格式
|
||||
const organizerId = record.organizer_id && record.organizer_id[0];
|
||||
const isOrganizer = organizerId === currentUserId;
|
||||
|
||||
if (!isAdmin && !isOrganizer) {
|
||||
// 没有编辑权限,不显示按钮
|
||||
const { button: _removed, ...rest } = props;
|
||||
return rest;
|
||||
}
|
||||
// 有权限,按钮文字统一为"编辑"
|
||||
return {
|
||||
...props,
|
||||
button: {
|
||||
text: _t("编辑"),
|
||||
onClick: props.button && props.button.onClick,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const roomBookingGanttView = {
|
||||
...ganttView,
|
||||
Controller: RoomBookingGanttController,
|
||||
Model: RoomBookingGanttModel,
|
||||
Renderer: RoomBookingGanttRenderer,
|
||||
};
|
||||
|
||||
registry.category("views").add("room_booking_gantt", roomBookingGanttView);
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
<div t-name="gantt-popover">
|
||||
<div class="o_gantt_popover">
|
||||
<ul class="ps-1 mb-0 list-unstyled">
|
||||
<li>
|
||||
<strong>会议标题:</strong>
|
||||
<t t-out="name"/>
|
||||
</li>
|
||||
<li>
|
||||
<strong>创建人:</strong>
|
||||
<t t-out="organizer_id[1]"/>
|
||||
|
||||
Reference in New Issue
Block a user