[MIG] document_page: migration Browse Wiki Content to 17.0

This commit is contained in:
natuan9 2024-11-05 17:25:08 +07:00 committed by Justine Doutreloux
parent d0df693b95
commit 3482986272
7 changed files with 47 additions and 54 deletions

View File

@ -32,6 +32,8 @@
"assets": { "assets": {
"web.assets_backend": [ "web.assets_backend": [
"document_page/static/src/scss/document_page.scss", "document_page/static/src/scss/document_page.scss",
"document_page/static/src/js/document_page_kanban_controller.esm.js",
"document_page/static/src/js/document_page_kanban_view.esm.js",
], ],
}, },
} }

View File

@ -94,7 +94,7 @@ class DocumentPage(models.Model):
compute="_compute_backend_url", compute="_compute_backend_url",
) )
image = fields.Binary("Image", attachment=True) image = fields.Binary(attachment=True)
color = fields.Integer(string="Color Index") color = fields.Integer(string="Color Index")
@api.depends("menu_id", "parent_id.menu_id") @api.depends("menu_id", "parent_id.menu_id")

View File

@ -1,26 +0,0 @@
odoo.define("document_page.update_kanban", function (require) {
"use strict";
var KanbanRecord = require("web.KanbanRecord");
KanbanRecord.include({
// --------------------------------------------------------------------------
// Private
// --------------------------------------------------------------------------
/**
* @override
* @private
*/
_openRecord: function () {
if (
this.modelName === "document.page" &&
this.$(".o_document_page_kanban_boxes a").length
) {
this.$(".o_document_page_kanban_boxes a").first().click();
} else {
this._super.apply(this, arguments);
}
},
});
});

View File

@ -0,0 +1,19 @@
/** @odoo-module **/
import {KanbanController} from "@web/views/kanban/kanban_controller";
export class DocumentPageKanbanController extends KanbanController {
/**
* @param {Object} record
*/
async openRecord(record) {
const element = document.querySelector(
`.o_kanban_record[data-id="${record.id}"] .o_document_page_kanban_boxes a`
);
if (this.props.resModel === "document.page" && element) {
element.click();
} else {
await super.openRecord(record);
}
}
}

View File

@ -0,0 +1,11 @@
/** @odoo-module **/
import {registry} from "@web/core/registry";
import {kanbanView} from "@web/views/kanban/kanban_view";
import {DocumentPageKanbanController} from "./document_page_kanban_controller.esm";
export const documentPageKanbanView = {
...kanbanView,
Controller: DocumentPageKanbanController,
};
registry.category("views").add("document_page_kanban_view", documentPageKanbanView);

View File

@ -45,7 +45,12 @@
/> />
<field name="active" invisible="1" /> <field name="active" invisible="1" />
<field name="type" invisible="1" /> <field name="type" invisible="1" />
<field name="image" widget="image" class="oe_avatar" /> <field
name="image"
widget="image"
class="oe_avatar"
style="z-index:1"
/>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
<field name="name" placeholder="Name" /> <field name="name" placeholder="Name" />

View File

@ -94,7 +94,7 @@
<field name="name">document.page.browse.kanban</field> <field name="name">document.page.browse.kanban</field>
<field name="model">document.page</field> <field name="model">document.page</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<kanban> <kanban js_class="document_page_kanban_view">
<field name="id" /> <field name="id" />
<field name="name" /> <field name="name" />
<field name="display_name" /> <field name="display_name" />
@ -149,35 +149,13 @@
<img <img
t-att-src="kanban_image('document.page', 'image', record.parent_id.raw_value)" t-att-src="kanban_image('document.page', 'image', record.parent_id.raw_value)"
t-att-alt="record.parent_id.display_name" t-att-alt="record.parent_id.display_name"
width="24" style="margin-right:5px; width:24px; height:24px;"
height="24"
/> />
<field name="parent_id" /> <field name="parent_id" />
</small> </small>
</div> </div>
</div> </div>
<div
class="o_dropdown_kanban dropdown"
groups="base.group_user"
>
<a
role="button"
class="dropdown-toggle o-no-caret btn"
data-toggle="dropdown"
data-display="static"
href="#"
aria-label="Dropdown menu"
title="Dropdown menu"
>
<span class="fa fa-ellipsis-v" />
</a>
<div class="dropdown-menu" role="menu">
<ul
class="oe_kanban_colorpicker"
data-field="color"
/>
</div>
</div>
<div class="o_kanban_record_body"> <div class="o_kanban_record_body">
<div class="o_kanban_tags_section"> <div class="o_kanban_tags_section">
</div> </div>
@ -216,6 +194,10 @@
</div> </div>
</div> </div>
</t> </t>
<t t-name="kanban-menu">
<ul class="oe_kanban_colorpicker" data-field="color" />
</t>
</templates> </templates>
</kanban> </kanban>
</field> </field>
@ -300,7 +282,7 @@
/> />
<menuitem <menuitem
id="menu_browse_content" id="menu_browse_content"
parent="knowledge.menu_document_root" parent="document_knowledge.menu_document_root"
name="Browse Wiki Content" name="Browse Wiki Content"
action="action_browse_top_content" action="action_browse_top_content"
sequence="5" sequence="5"