From e343f5f5f95607b91a61fed167a6f11f0eeaeaa8 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Mon, 3 Sep 2018 16:20:06 +0200 Subject: [IMP] web: x2many adds a new line by tabbing on a not dirty line Before this change, when the focus was on the first field on a x2many field, and the user pressed TAB, the line would be discarded and the focus moved to the next field (at the level of the x2many) in the form. This was an issue because if the first field was required, the focus could not be moved out of the field with TAB so the user had to discard the line manually (with ESC) before moving to the next field This change works with 2 changes: 1. detecting if a line is dirty (has been modified by the user) and at the end of the line, decide to either - discard the line and move the next field, if the line is not dirty - commit the line and add a new line, if the line is dirty 2. allow users to use TAB through required field inside x2many so they can easilly go to the end of the line. Task id : 1872248 --- addons/web/static/src/js/fields/basic_fields.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 08b6d47f0f5..41885837353 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -334,7 +334,8 @@ var InputField = DebouncedField.extend({ } if (ev.data.direction ==='next' && this.attrs.modifiersValue && - this.attrs.modifiersValue.required) { + this.attrs.modifiersValue.required && + this.viewType !== 'list') { if (!this.$input.val()){ this.setInvalidClass(); ev.stopPropagation(); @@ -388,7 +389,7 @@ var NumericField = InputField.extend({ * * Note: We have to overwrite this method to set the input's type to number if * option setted into the field. - * + * * @override * @private */ -- cgit v1.2.3 From c2b4790be426f039ec47b0888b5e58c7970c3dae Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Tue, 25 Sep 2018 20:48:22 +0200 Subject: [FIX] web: fix date picker fields do not capture the focus event when invisible Before this fix, in form view, when a datepicker was not visible (because they were on another page or literally invisible), when the user pressed TAB and the datepicker was positionned after the current field in the form, it was capturing the focus during the activate phase of the navigation_move. This is not correct for invisible elements. After this fix, only focusable datepickers get the focus during the activation phase of the navigation_move. co-author: aab-odoo (aab@odoo.com) --- addons/web/static/src/js/fields/basic_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 41885837353..0c28f0f4b61 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -538,7 +538,7 @@ var FieldDate = InputField.extend({ * @override */ activate: function () { - if (this.datewidget) { + if (this.isFocusable() && this.datewidget) { this.datewidget.focus(); return true; } -- cgit v1.2.3 From 1be50fdeafcd2b94f7b2f47d6e5bc4b6ebaceadd Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 Aug 2018 23:36:33 +0200 Subject: [ADD] *: support SVG images Introduce official support for SVG files in the framework, including the following parts: 1. When client-side SVG images are uploaded, the content is displayed until you save using data URI scheme according RFC 2397 [1]. This scheme requires to specify content format. Using hardcoded "image/png" works for all images types except SVG. Type-sniffing is done using "magic byte" detection via the first base64 encode byte, so that the proper data URI scheme can be used. This should not cause SVG-related security problems as the file is displayed through `` tag, which does not allow SVG scripting [2]. 2. Make /web/image controller compatible with SVG 3. Add support for SVG files for company logo, which uses a dedicated controller. 4. Resizing of SVG files is a no-op, as it makes little sense for a vector-based format. We also want to avoid micro-alterations to the SVG document (in "natural" viewport parameters) as we would store multiple copies of the files in the filestore. 5. Because SVG files are inherently dangerous, upload of SVG files is restricted to administrators, either by blocking it directly before saving it in the database (binary fields with attachment=False), or by neutering them to text/plain mimetype (for binary fields with attachment=True) 6. Add tests for the SVG upload cases and for the non-admin uploads. [1] https://tools.ietf.org/html/rfc2397 [2] https://www.w3.org/wiki/SVG_Security Closes #26635 --- addons/web/static/src/js/fields/basic_fields.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 0c28f0f4b61..12b7b8f302c 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1471,12 +1471,19 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ }, }), supportedFieldTypes: ['binary'], + file_type_magic_word: { + '/': 'jpg', + 'R': 'gif', + 'i': 'png', + 'P': 'svg+xml', + }, _render: function () { var self = this; var url = this.placeholder; if (this.value) { if (!utils.is_bin_size(this.value)) { - url = 'data:image/png;base64,' + this.value; + // Use magic-word technique for detecting image type + url = 'data:image/' + (this.file_type_magic_word[this.value[0]] || 'png') + ';base64,' + this.value; } else { url = session.url('/web/image', { model: this.model, -- cgit v1.2.3