mirror of https://github.com/OCA/web.git
[FIX] web_widget_ckeditor: ir.config_parameter read permissions
(+) some small linter warning fixespull/2142/head
parent
585e5e6df1
commit
e1140a7a88
|
@ -1 +1 @@
|
|||
# from . import models
|
||||
from . import models
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from . import ir_config_parameter
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
|
||||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class IrConfigParameter(models.Model):
|
||||
_inherit = "ir.config_parameter"
|
||||
|
||||
@api.model
|
||||
def get_web_widget_ckeditor_config(self):
|
||||
get_param = self.sudo().get_param
|
||||
return {
|
||||
"toolbar": get_param("web_widget_ckeditor.toolbar"),
|
||||
}
|
|
@ -17,15 +17,14 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
|
|||
const TranslatableFieldMixin = basic_fields.TranslatableFieldMixin;
|
||||
|
||||
// Load configuration for the editor
|
||||
const defaultCKEditorToolbarPromise = rpc.query({
|
||||
const getCKEditorConfigPromise = rpc.query({
|
||||
model: "ir.config_parameter",
|
||||
method: "get_param",
|
||||
args: ["web_widget_ckeditor.toolbar"],
|
||||
method: "get_web_widget_ckeditor_config",
|
||||
});
|
||||
|
||||
// Load CKEditor localization files
|
||||
async function loadCKEditorLanguageSource(languageCode) {
|
||||
if (languageCode == "en") {
|
||||
if (languageCode === "en") {
|
||||
return;
|
||||
}
|
||||
const languageURL = `/web_widget_ckeditor/static/lib/ckeditor/build/translations/${languageCode}.js`;
|
||||
|
@ -87,9 +86,10 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
|
|||
* @override
|
||||
*/
|
||||
isSet: function () {
|
||||
var value =
|
||||
// Removing spaces & html spaces
|
||||
const value =
|
||||
this.value &&
|
||||
this.value.split(" ").join("").replace(/\s/g, ""); // Removing spaces & html spaces
|
||||
this.value.split(" ").join("").replace(/\s/g, "");
|
||||
return (
|
||||
value &&
|
||||
value !== "<p></p>" &&
|
||||
|
@ -143,9 +143,9 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
|
|||
*/
|
||||
_getCKEditorToolbarItems: async function () {
|
||||
try {
|
||||
const toolbarConfig = await defaultCKEditorToolbarPromise;
|
||||
if (toolbarConfig) {
|
||||
return toolbarConfig.split(/[\s,]+/).filter((item) => item);
|
||||
const ckconfig = await getCKEditorConfigPromise;
|
||||
if (ckconfig.toolbar) {
|
||||
return ckconfig.toolbar.split(/[\s,]+/).filter((item) => item);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
|
|
Loading…
Reference in New Issue