From 73bc1fec3e8171a85cbdf46da6e636000d2cf892 Mon Sep 17 00:00:00 2001 From: Hiren Jungi Date: Thu, 19 Jul 2018 17:02:41 +0530 Subject: [PATCH] [ADD] Added upstream patch for web_editor,website_gengo --- .../web_editor/static/src/js/backend/fields.js | 16 ++++++++++------ addons/web_editor/static/src/js/inline.js | 3 ++- .../static/src/less/web_editor.common.less | 1 + .../static/src/js/website_gengo.js | 17 +++++++---------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/fields.js b/addons/web_editor/static/src/js/backend/fields.js index 0c30a52d..b732c102 100644 --- a/addons/web_editor/static/src/js/backend/fields.js +++ b/addons/web_editor/static/src/js/backend/fields.js @@ -105,9 +105,9 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi attachedDocumentDomain.unshift('&'); attachedDocumentDomain.push(['create_uid', '=', session.uid]); } - if (this.recordData.model) { + if (this.recordData.res_model || this.recordData.model) { var relatedDomain = ['&', - ['res_model', '=', this.recordData.model], + ['res_model', '=', this.recordData.res_model || this.recordData.model], ['res_id', '=', this.recordData.res_id|0]]; if (!this.recordData.res_id) { relatedDomain.unshift('&'); @@ -136,7 +136,7 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], - ['insert', ['link', 'picture']], + ['insert', this.nodeOptions['no-attachment'] ? ['link'] : ['link', 'picture']], ['history', ['undo', 'redo']] ], prettifyHtml: false, @@ -144,6 +144,7 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi inlinemedia: ['p'], lang: "flectra", onChange: this._doDebouncedAction.bind(this), + disableDragAndDrop: !!this.nodeOptions['no-attachment'], }; var fieldNameAttachment =_.chain(this.recordData) @@ -158,8 +159,9 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi this.fieldNameAttachment = fieldNameAttachment; this.attachments = []; summernoteConfig.onUpload = this._onUpload.bind(this); - summernoteConfig.getMediaDomain = this._getAttachmentsDomain.bind(this); } + summernoteConfig.getMediaDomain = this._getAttachmentsDomain.bind(this); + if (config.debug) { summernoteConfig.toolbar.splice(7, 0, ['view', ['codeview']]); @@ -172,9 +174,9 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi */ _getValue: function () { if (this.nodeOptions['style-inline']) { - transcoder.linkImgToAttachmentThumbnail(this.$content); - transcoder.classToStyle(this.$content); + transcoder.attachmentThumbnailToLinkImg(this.$content); transcoder.fontToImg(this.$content); + transcoder.classToStyle(this.$content); } return this.$content.html(); }, @@ -220,6 +222,8 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi this.$content.trigger('mouseup'); if (this.nodeOptions['style-inline']) { transcoder.styleToClass(this.$content); + transcoder.imgToFont(this.$content); + transcoder.linkImgToAttachmentThumbnail(this.$content); } // reset the history (otherwise clicking on undo before editing the // value will empty the editor) diff --git a/addons/web_editor/static/src/js/inline.js b/addons/web_editor/static/src/js/inline.js index c6807ab7..325a2451 100644 --- a/addons/web_editor/static/src/js/inline.js +++ b/addons/web_editor/static/src/js/inline.js @@ -41,6 +41,7 @@ snippet_editor.Class.include({ start: function () { _.defer(function () { var $editable = $('#editable_area'); + transcoder.linkImgToAttachmentThumbnail($editable); transcoder.imgToFont($editable); transcoder.styleToClass($editable); @@ -53,7 +54,7 @@ snippet_editor.Class.include({ this._super.apply(this, arguments); var $editable = $('#editable_area'); - transcoder.linkImgToAttachmentThumbnail($editable); + transcoder.attachmentThumbnailToLinkImg($editable); transcoder.fontToImg($editable); transcoder.classToStyle($editable); diff --git a/addons/web_editor/static/src/less/web_editor.common.less b/addons/web_editor/static/src/less/web_editor.common.less index cfa9f683..447bf4a0 100644 --- a/addons/web_editor/static/src/less/web_editor.common.less +++ b/addons/web_editor/static/src/less/web_editor.common.less @@ -3,6 +3,7 @@ /// html, body { + position: relative; width: 100%; height: 100%; } diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js index 2017a785..c1274758 100644 --- a/addons/website_gengo/static/src/js/website_gengo.js +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -8,9 +8,6 @@ var Widget = require('web.Widget'); var weContext = require('web_editor.context'); require('web_editor.editor'); var translate = require('web_editor.translate'); -var websiteNavbarData = require('website.navbar'); - -var WebsiteNavbar = websiteNavbarData.WebsiteNavbar; var qweb = core.qweb; var _t = core._t; @@ -83,7 +80,7 @@ translate.Class.include({ 'lang': weContext.get().lang, }).then(function () { ajax.jsonRpc('/website/post_gengo_jobs', 'call', {}); - self.save_and_reload(); + self._save(); }).fail(function () { Dialog.alert(null, _t("Could not Post translation")); }); @@ -113,12 +110,12 @@ translate.Class.include({ }); var GengoTranslatorPostDialog = Widget.extend({ - events: _.extend({}, WebsiteNavbar.prototype.events, { + events: { 'hidden.bs.modal': 'destroy', 'click button[data-action=service_level]': function () { this.trigger('service_level'); }, - }), + }, template: 'website.GengoTranslatorPostDialog', init: function (new_words){ this.new_words = new_words; @@ -130,9 +127,9 @@ var GengoTranslatorPostDialog = Widget.extend({ }); var GengoTranslatorStatisticDialog = Widget.extend({ - events: _.extend({}, WebsiteNavbar.prototype.events, { + events: { 'hidden.bs.modal': 'destroy', - }), + }, template: 'website.GengoTranslatorStatisticDialog', init: function (res) { var self = this; @@ -154,10 +151,10 @@ var GengoTranslatorStatisticDialog = Widget.extend({ }); var GengoApiConfigDialog = Widget.extend({ - events: _.extend({}, WebsiteNavbar.prototype.events, { + events: { 'hidden.bs.modal': 'destroy', 'click button[data-action=set_config]': 'set_config' - }), + }, template: 'website.GengoApiConfigDialog', init:function (company_id){ this.company_id = company_id;