mirror of https://github.com/OCA/web.git
[FIX] web_widget_ckeditor: ir.config_parameter read permissions
(+) some small linter warning fixespull/2373/head
parent
40c7f7a728
commit
0c871301bd
|
@ -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;
|
const TranslatableFieldMixin = basic_fields.TranslatableFieldMixin;
|
||||||
|
|
||||||
// Load configuration for the editor
|
// Load configuration for the editor
|
||||||
const defaultCKEditorToolbarPromise = rpc.query({
|
const getCKEditorConfigPromise = rpc.query({
|
||||||
model: "ir.config_parameter",
|
model: "ir.config_parameter",
|
||||||
method: "get_param",
|
method: "get_web_widget_ckeditor_config",
|
||||||
args: ["web_widget_ckeditor.toolbar"],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load CKEditor localization files
|
// Load CKEditor localization files
|
||||||
async function loadCKEditorLanguageSource(languageCode) {
|
async function loadCKEditorLanguageSource(languageCode) {
|
||||||
if (languageCode == "en") {
|
if (languageCode === "en") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const languageURL = `/web_widget_ckeditor/static/lib/ckeditor/build/translations/${languageCode}.js`;
|
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
|
* @override
|
||||||
*/
|
*/
|
||||||
isSet: function () {
|
isSet: function () {
|
||||||
var value =
|
// Removing spaces & html spaces
|
||||||
|
const value =
|
||||||
this.value &&
|
this.value &&
|
||||||
this.value.split(" ").join("").replace(/\s/g, ""); // Removing spaces & html spaces
|
this.value.split(" ").join("").replace(/\s/g, "");
|
||||||
return (
|
return (
|
||||||
value &&
|
value &&
|
||||||
value !== "<p></p>" &&
|
value !== "<p></p>" &&
|
||||||
|
@ -143,9 +143,9 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
|
||||||
*/
|
*/
|
||||||
_getCKEditorToolbarItems: async function () {
|
_getCKEditorToolbarItems: async function () {
|
||||||
try {
|
try {
|
||||||
const toolbarConfig = await defaultCKEditorToolbarPromise;
|
const ckconfig = await getCKEditorConfigPromise;
|
||||||
if (toolbarConfig) {
|
if (ckconfig.toolbar) {
|
||||||
return toolbarConfig.split(/[\s,]+/).filter((item) => item);
|
return ckconfig.toolbar.split(/[\s,]+/).filter((item) => item);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|
Loading…
Reference in New Issue