From 3df24d258605da3d4456a3cb1593f5bb503346ca Mon Sep 17 00:00:00 2001 From: natuan9 Date: Tue, 5 Nov 2024 17:25:08 +0700 Subject: [PATCH] [MIG] document_page: migration Browse Wiki Content to 17.0 --- document_page/__manifest__.py | 2 ++ .../static/src/js/document_page_kanban.js | 26 -------------- .../src/js/document_page_kanban_controller.js | 19 +++++++++++ .../src/js/document_page_kanban_view.js | 11 ++++++ document_page/views/document_page.xml | 2 +- .../views/document_page_category.xml | 34 +++++-------------- 6 files changed, 41 insertions(+), 53 deletions(-) delete mode 100644 document_page/static/src/js/document_page_kanban.js create mode 100644 document_page/static/src/js/document_page_kanban_controller.js create mode 100644 document_page/static/src/js/document_page_kanban_view.js diff --git a/document_page/__manifest__.py b/document_page/__manifest__.py index e7a125a72be..57e6ded0e3e 100644 --- a/document_page/__manifest__.py +++ b/document_page/__manifest__.py @@ -32,6 +32,8 @@ "assets": { "web.assets_backend": [ "document_page/static/src/scss/document_page.scss", + "document_page/static/src/js/document_page_kanban_controller.js", + "document_page/static/src/js/document_page_kanban_view.js", ], }, } diff --git a/document_page/static/src/js/document_page_kanban.js b/document_page/static/src/js/document_page_kanban.js deleted file mode 100644 index 7c95985c2b2..00000000000 --- a/document_page/static/src/js/document_page_kanban.js +++ /dev/null @@ -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); - } - }, - }); -}); diff --git a/document_page/static/src/js/document_page_kanban_controller.js b/document_page/static/src/js/document_page_kanban_controller.js new file mode 100644 index 00000000000..9fc613ee01a --- /dev/null +++ b/document_page/static/src/js/document_page_kanban_controller.js @@ -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); + } + } +} diff --git a/document_page/static/src/js/document_page_kanban_view.js b/document_page/static/src/js/document_page_kanban_view.js new file mode 100644 index 00000000000..eb240416134 --- /dev/null +++ b/document_page/static/src/js/document_page_kanban_view.js @@ -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"; + +export const documentPageKanbanView = { + ...kanbanView, + Controller: DocumentPageKanbanController, +}; + +registry.category("views").add("document_page_kanban_view", documentPageKanbanView); diff --git a/document_page/views/document_page.xml b/document_page/views/document_page.xml index 1156d6a6d8a..eaba6d3c4f9 100644 --- a/document_page/views/document_page.xml +++ b/document_page/views/document_page.xml @@ -45,7 +45,7 @@ /> - +

diff --git a/document_page/views/document_page_category.xml b/document_page/views/document_page_category.xml index 1e0a199e428..1f0528c8470 100644 --- a/document_page/views/document_page_category.xml +++ b/document_page/views/document_page_category.xml @@ -97,7 +97,7 @@ document.page.browse.kanban document.page - + @@ -152,35 +152,13 @@

- +
@@ -219,6 +197,10 @@
+ + +
    + @@ -302,7 +284,7 @@ />