[FIX] web_widget_ckeditor: ir.config_parameter read permissions

(+) some small linter warning fixes
This commit is contained in:
Ivàn Todorovich
2022-02-07 10:41:02 -03:00
committed by Justine Doutreloux
parent 40c7f7a728
commit 0c871301bd
4 changed files with 27 additions and 10 deletions

View File

@@ -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(