1
This commit is contained in:
@@ -99,6 +99,7 @@ patch(SearchModel.prototype, {
|
||||
// Array.from(group.values.values()).map(item => item.__count).reduce((acc, cur) => acc + cur, 0)
|
||||
group.__count = (section.values.values().find(item => item.id === key)?.__count ?? 0)
|
||||
const group_id = section.values.values().find(item => item.id === key)?.group_id
|
||||
if (!group_id) return;
|
||||
if (ids.includes(group_id)) {
|
||||
if (group_id === key) {
|
||||
group.parent = false;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"version": "0.0.4",
|
||||
"depends":
|
||||
[
|
||||
"base",
|
||||
"web",
|
||||
"web_enterprise",
|
||||
"mail",
|
||||
@@ -65,7 +66,6 @@
|
||||
"web.assets_web_dark": [
|
||||
'sh_backmate_theme_adv_enterprise/static/src/scss/night_mode/night_mode.scss',
|
||||
],
|
||||
|
||||
'web.assets_backend': [
|
||||
#new_style_1_view#
|
||||
"sh_backmate_theme_adv_enterprise/static/src/scss/list_view/list_view_style.scss",
|
||||
@@ -282,7 +282,13 @@
|
||||
'web/static/lib/pdfjs/build/pdf.js',
|
||||
'web/static/lib/pdfjs/build/pdf.worker.js',
|
||||
'web/static/lib/pdfjs/web/viewer.js',
|
||||
|
||||
|
||||
# edit_save_button
|
||||
'sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.xml',
|
||||
'sh_backmate_theme_adv_enterprise/static/src/views/form/form_controller.js',
|
||||
|
||||
# breadcrumb_to_back_button
|
||||
'sh_backmate_theme_adv_enterprise/static/src/search/control_panel/*',
|
||||
],
|
||||
|
||||
'web.assets_web': [
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/** @odoo-module **/
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { ControlPanel } from "@web/search/control_panel/control_panel";
|
||||
|
||||
|
||||
patch(ControlPanel.prototype, {
|
||||
|
||||
onBreadcrumbBackClicked(ev) {
|
||||
const jsId = this.breadcrumbs[this.breadcrumbs.length - 2].jsId;
|
||||
this.onBreadcrumbClicked(jsId);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
.breadcrumb-back-div {
|
||||
display: flex;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="web.Breadcrumbs" t-inherit-mode="extension">
|
||||
<xpath expr="//ol[hasclass('breadcrumb')]" position="attributes">
|
||||
<attribute name="style">display: none !important;</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@t-if='collapsedBreadcrumbs.length || visiblePathBreadcrumbs.length']/div[last()]" position="attributes">
|
||||
<attribute name="style">display: none !important;</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//ol[hasclass('breadcrumb')]" position="after">
|
||||
<div class="breadcrumb-back-div">
|
||||
<button t-if="breadcrumbs.length" class="btn btn-secondary o_attach" t-on-click="(ev) => this.onBreadcrumbBackClicked(ev)" data-tooltip="BACK">
|
||||
<i class="fa fa-chevron-left"/>
|
||||
返回
|
||||
</button>
|
||||
<div class="d-flex gap-1 text-truncate">
|
||||
<div class="o_last_breadcrumb_item active d-flex gap-2 align-items-center min-w-0 lh-sm">
|
||||
<span class="min-w-0 text-truncate" t-call="web.Breadcrumb.Name"/>
|
||||
</div>
|
||||
<t t-call="web.Breadcrumb.Actions"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,80 @@
|
||||
/** @odoo-module **/
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { session } from "@web/session";
|
||||
import { FormController } from "@web/views/form/form_controller";
|
||||
|
||||
const originalSetup = FormController.prototype.setup;
|
||||
const originalEdit = FormController.prototype.edit;
|
||||
const originalSaveButtonClicked = FormController.prototype.saveButtonClicked;
|
||||
const originalDiscard = FormController.prototype.discard;
|
||||
|
||||
|
||||
patch(FormController.prototype, {
|
||||
setup() {
|
||||
// change this to true if you want to prevent editing for admin
|
||||
// this.isAdmin = session.name === "Administrator";
|
||||
// if (this.isAdmin) {
|
||||
// this.props.preventEdit = this.env.inDialog ? false : true;
|
||||
// }
|
||||
this.props.preventEdit = this.env.inDialog ? false : true;
|
||||
originalSetup.call(this);
|
||||
},
|
||||
|
||||
async edit() {
|
||||
if (originalEdit) {
|
||||
await originalEdit.call(this);
|
||||
}
|
||||
|
||||
if (this.model && this.model.root) {
|
||||
// 添加管理员才会变只读
|
||||
// if (this.isAdmin) {
|
||||
await this.model.root.switchMode("edit");
|
||||
// }
|
||||
} else {
|
||||
console.error("Model or model root is not defined");
|
||||
}
|
||||
},
|
||||
|
||||
async saveButtonClicked(params = {}) {
|
||||
if (originalSaveButtonClicked) {
|
||||
await originalSaveButtonClicked.call(this, params);
|
||||
}
|
||||
if (!this.env.inDialog) {
|
||||
// 添加管理员才会变只读
|
||||
// if (this.isAdmin) {
|
||||
await this.model.root.switchMode("readonly");
|
||||
// }
|
||||
} else {
|
||||
this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
|
||||
}
|
||||
},
|
||||
|
||||
async discard() {
|
||||
if (originalDiscard) {
|
||||
await originalDiscard.call(this);
|
||||
}
|
||||
|
||||
if (!this.env.inDialog) {
|
||||
// 添加管理员才会变只读
|
||||
// if (this.isAdmin) {
|
||||
await this.model.root.switchMode("readonly");
|
||||
// }
|
||||
} else {
|
||||
this.model.actionService.doAction({ type: 'ir.actions.act_window_close' });
|
||||
}
|
||||
},
|
||||
|
||||
// async beforeLeave() {
|
||||
// if (this.model.root.isDirty) {
|
||||
// if (confirm("The changes you have made will save Automatically!")) {
|
||||
// await this.model.root.save();
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="web.FormView" t-inherit-mode="extension">
|
||||
|
||||
<xpath expr="//Layout/t[@t-set-slot='control-panel-create-button'][2]" position="inside">
|
||||
<t t-if="!canEdit and !model.root.isInEdition">
|
||||
<button type="button" class="btn btn-outline-primary o_form_button_edit" t-on-click="edit" data-hotkey="a">编辑</button>
|
||||
</t>
|
||||
<t t-if="model.root.isInEdition">
|
||||
<div class="o_form_buttons_edit">
|
||||
<button id="editButton" type="button" class="btn btn-primary o_form_button_save" t-on-click="saveButtonClicked" data-hotkey="s">
|
||||
<i class="fa fa-cloud-upload fa-fw" />
|
||||
保存
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary o_form_button_cancel" t-on-click="discard" data-hotkey="j">
|
||||
<i class="fa fa-undo fa-fw" />
|
||||
丢弃
|
||||
</button>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user