mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-22 13:22:19 -06:00
[MIG] document_page_reference: Migration to 17.0
[FIX]document_page_reference :log warning updated [FIX]document_page_reference: null value issue fixed Co-authored-by: Anusha <anusha.pp@calin.co.in>
This commit is contained in:
@@ -387,7 +387,7 @@ the link between document pages.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
|
||||
<p>When editing a document page add elements like ${XXX} where XXX is the
|
||||
<p>When editing a document page add elements like {{XXX}} where XXX is the
|
||||
reference of another page. Now, when viewing the document, it will link
|
||||
directly to the page. Also, the name will be parsed as the display name.</p>
|
||||
</div>
|
||||
|
||||
33
document_page_reference/static/src/js/editor.esm.js
Normal file
33
document_page_reference/static/src/js/editor.esm.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @odoo-module **/
|
||||
import {HtmlField, htmlField} from "@web/views/fields/html/html_field";
|
||||
import {onMounted} from "@odoo/owl";
|
||||
import {registry} from "@web/core/registry";
|
||||
import {useService} from "@web/core/utils/hooks";
|
||||
|
||||
class DocumentPageReferenceField extends HtmlField {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.orm = useService("orm");
|
||||
this.action = useService("action");
|
||||
onMounted(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const links = document.querySelectorAll(".oe_direct_line");
|
||||
links.forEach((link) => {
|
||||
link.addEventListener("click", (event) =>
|
||||
this._onClickDirectLink(event)
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
_onClickDirectLink(event) {
|
||||
const {oeModel: model, oeId} = event.target.dataset;
|
||||
const id = parseInt(oeId, 10);
|
||||
this.orm.call(model, "get_formview_action", [[id]], {}).then((action) => {
|
||||
this.action.doAction(action);
|
||||
});
|
||||
}
|
||||
}
|
||||
registry.category("fields").add("document_page_reference", {
|
||||
...htmlField,
|
||||
component: DocumentPageReferenceField,
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
odoo.define("document_page_reference.backend", function (require) {
|
||||
"use strict";
|
||||
|
||||
var field_registry = require("web.field_registry");
|
||||
var FieldTextHtmlSimple = require("web_editor.field.html");
|
||||
var FieldDocumentPage = FieldTextHtmlSimple.extend({
|
||||
events: _.extend({}, FieldTextHtmlSimple.prototype.events, {
|
||||
"click .oe_direct_line": "_onClickDirectLink",
|
||||
}),
|
||||
_onClickDirectLink: function (event) {
|
||||
var self = this;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var element = $(event.target).closest(".oe_direct_line")[0];
|
||||
var default_reference = element.name;
|
||||
var model = $(event.target).data("oe-model");
|
||||
var id = $(event.target).data("oe-id");
|
||||
var context = this.record.getContext(this.recordParams);
|
||||
if (default_reference) {
|
||||
context.default_reference = default_reference;
|
||||
}
|
||||
this._rpc({
|
||||
model: model,
|
||||
method: "get_formview_action",
|
||||
args: [[parseInt(id, 10)]],
|
||||
context: context,
|
||||
}).then(function (action) {
|
||||
self.trigger_up("do_action", {action: action});
|
||||
});
|
||||
},
|
||||
});
|
||||
field_registry.add("document_page_reference", FieldDocumentPage);
|
||||
return FieldDocumentPage;
|
||||
});
|
||||
Reference in New Issue
Block a user