diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-06-28 19:01:52 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-06-28 19:01:52 +0200 |
| commit | c8bb02141d2801c243ae65ba6800b07f090bb5c6 (patch) | |
| tree | 2d099c5577df4783a6db3d853cf0141bf41c1aa9 /addons/web_editor | |
| parent | 4e2733e83a1f42773fb28f66431a0d6fb0393be9 (diff) | |
| parent | 3cdcbce93cbde548d2d24426ee8de1d93f06706e (diff) | |
[MERGE] forward port branch saas-11.3 up to 3cdcbce93cb
Diffstat (limited to 'addons/web_editor')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 7 | ||||
| -rw-r--r-- | addons/web_editor/models/ir_qweb.py | 1 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/editor/transcoder.js | 18 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/widgets/widgets.js | 8 |
4 files changed, 23 insertions, 11 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index f573342570e..22a1e514d88 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -273,7 +273,7 @@ class Web_Editor(http.Controller): ## @param bundles - True if the bundles views must be fetched (default to False) ## @param bundles_restriction - Names of the bundle in which to look for scss files (if empty, search in all of them) ## @returns a dictionary with views info in the views key and style info in the scss key - @http.route("/web_editor/get_assets_editor_resources", type="json", auth="user") + @http.route("/web_editor/get_assets_editor_resources", type="json", auth="user", website=True) def get_assets_editor_resources(self, key, get_views=True, get_scss=True, bundles=False, bundles_restriction=[]): # Related views must be fetched if the user wants the views and/or the style views = request.env["ir.ui.view"].get_related_views(key, bundles=bundles) @@ -390,16 +390,17 @@ class Web_Editor(http.Controller): # Check if the file to save had already been modified custom_attachment = IrAttachment.search([("url", "=", custom_url)]) + datas = base64.b64encode((content or "\n").encode("utf-8")) if custom_attachment: # If it was already modified, simply override the corresponding attachment content - custom_attachment.write({"datas": base64.b64encode(content.encode("utf-8"))}) + custom_attachment.write({"datas": datas}) else: # If not, create a new attachment to copy the original scss file content, with its modifications IrAttachment.create(dict( name = custom_url, type = "binary", mimetype = "text/scss", - datas = base64.b64encode(content.encode("utf-8")), + datas = datas, datas_fname = url.split("/")[-1], url = custom_url, # Having an attachment of "binary" type with an non empty "url" field # is quite of an hack. This allows to fetch the "datas" field by adding diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py index a9492dac645..6926775ccbc 100644 --- a/addons/web_editor/models/ir_qweb.py +++ b/addons/web_editor/models/ir_qweb.py @@ -178,6 +178,7 @@ class Contact(models.AbstractModel): @api.model def attributes(self, record, field_name, options, values): attrs = super(Contact, self).attributes(record, field_name, options, values) + options.pop('template_options') # remove options not specific to this widget attrs['data-oe-contact-options'] = json.dumps(options) return attrs diff --git a/addons/web_editor/static/src/js/editor/transcoder.js b/addons/web_editor/static/src/js/editor/transcoder.js index fb3e69eda29..84fe3cf8c93 100644 --- a/addons/web_editor/static/src/js/editor/transcoder.js +++ b/addons/web_editor/static/src/js/editor/transcoder.js @@ -108,9 +108,14 @@ function getMatchedCSSRules(a) { // The css generates all the attributes separately and not in simplified form. // In order to have a better compatibility (outlook for example) we simplify the css tags. // e.g. border-left-style: none; border-bottom-s .... will be simplified in border-style = none - _.each([['margin'], ['padding'], ['border', 'style']], function (attr) { - var p = attr[0]; - var e = attr[1] ? '-' + attr[1] : ''; + _.each([ + {property: 'margin'}, + {property: 'padding'}, + {property: 'border', propertyEnd: '-style', defaultValue: 'none'}, + ], function (propertyInfo) { + var p = propertyInfo.property; + var e = propertyInfo.propertyEnd || ''; + var defVal = propertyInfo.defaultValue || 0; if (style[p+'-top'+e] || style[p+'-right'+e] || style[p+'-bottom'+e] || style[p+'-left'+e]) { if (style[p+'-top'+e] === style[p+'-right'+e] && style[p+'-top'+e] === style[p+'-bottom'+e] && style[p+'-top'+e] === style[p+'-left'+e]) { @@ -119,7 +124,7 @@ function getMatchedCSSRules(a) { } else { // keep => property: [top value] [right value] [bottom value] [left value]; - style[p+e] = (style[p+'-top'+e] || 0) + ' ' + (style[p+'-right'+e] || 0) + ' ' + (style[p+'-bottom'+e] || 0) + ' ' + (style[p+'-left'+e] || 0); + style[p+e] = (style[p+'-top'+e] || defVal) + ' ' + (style[p+'-right'+e] || defVal) + ' ' + (style[p+'-bottom'+e] || defVal) + ' ' + (style[p+'-left'+e] || defVal); if (style[p+e].indexOf('inherit') !== -1 || style[p+e].indexOf('initial') !== -1) { // keep => property-top: [top value]; property-right: [right value]; property-bottom: [bottom value]; property-left: [left value]; delete style[p+e]; @@ -277,11 +282,12 @@ function classToStyle($editable) { } // Outlook - if (node.nodeName === 'A' && $target.hasClass('btn') && !$target.children().length) { - var $hack = $('<table class="o_outlook_hack"><tr><td></td></tr></table>'); + if (node.nodeName === 'A' && $target.hasClass('btn') && !$target.hasClass('btn-link') && !$target.children().length) { + var $hack = $('<table class="o_outlook_hack" style="display: inline-table;"><tr><td></td></tr></table>'); $hack.find('td') .attr('height', $target.outerHeight()) .css({ + 'text-align': $target.parent().css('text-align'), 'margin': $target.css('padding'), 'border-radius': $target.css('border-radius'), 'background-color': $target.css('background-color'), diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index 92ebf9ec4fe..e2dc7ea73a7 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -291,6 +291,10 @@ var ImageWidget = MediaWidget.extend({ } var img = this.images[0]; + if (!img) { + return this.media; + } + var def = $.when(); if (!img.access_token) { def = this._rpc({ @@ -1223,7 +1227,7 @@ var MediaDialog = Dialog.extend({ } return $.when(this.active.save()).then(function (media) { - if (!self.media) { + if (!self.media && media) { self.range.insertNode(media, true); } self.media = media; @@ -1235,7 +1239,7 @@ var MediaDialog = Dialog.extend({ // Update editor bar after image edition (in case the image change to icon or other) _.defer(function () { - if (!self.media.parentNode) { + if (!self.media || !self.media.parentNode) { return; } range.createFromNode(self.media).select(); |
