summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
AgeCommit message (Collapse)Author
2018-10-22[MERGE] forward port branch saas-11.4 up to 3c108977c1eChristophe Simonis
2018-10-18[FIX] web: File upload input on_clear event not propagatedTWA
The handler function was used directly in the code. The MouseEvent wasn't provided in that case. This FIX split the handler function and the processing function so that it doesn't interfere. closes odoo/odoo#27929
2018-10-17[MERGE] forward port branch saas-11.3 up to 0de06a41326Christophe Simonis
2018-10-16[MERGE] forward port branch 11.0 up to b29b545fe84Christophe Simonis
2018-10-10[MERGE] forward port branch 11.0 up to a69f117bbf5Christophe Simonis
2018-10-12[FIX] web: prevent URL click from opening a recordSébastien Theys
If we click on a link, we only want to open the URL, and not the record when the button is on a list. PR: #27230
2018-10-09[FIX] web: Make datetimepicker configurable in datetime fieldssvs-odoo
The datetimepicker option was introduced to be able to customize the datetime picker widget in date/datetime fields. However, due to the way the _makeDatePicker function was coded, it did not work in datetime fields. Thank to Yajo for the initial fix closes odoo/odoo#27541
2018-10-03[ADD] *: support SVG imagesPedro M. Baeza
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 `<img>` 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
2018-09-26[FIX] web: fix date picker fields do not capture the focus event when invisibleVincent Schippefilt
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)
2018-09-25[IMP] web: x2many adds a new line by tabbing on a not dirty lineVincent Schippefilt
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
2018-09-18[MERGE] forward port branch saas-11.4 up to a1b384d66beChristophe Simonis
2018-09-17[MERGE] forward port branch saas-11.3 up to 2de573440ebChristophe Simonis
2018-09-17[MERGE] forward port branch 11.0 up to f2b8caff07bChristophe Simonis
2018-09-17[FIX] web: datepicker: correctly use libAaron Bohy
The datepicker lib has been updated to tempus dominus (BS4) recently, but our code hasn't been adapted correctly to the requirements of the new version of the lib. As a consequence, the datepicker didn't close itself when the input was focused out anymore. This required a slight change in the DomainSelector widget as it produced a crash when a focused datepicker widget is removed from the DOM (before the datepicker is destroyed), e.g. by a call to html() on one of its parent. Task 1878254
2018-09-14[FIX] web: JournalDashboardGraph widget crash Mk.IIMOENS Alexandre
Hardening of commit:995610c065bf0242cb5023cfad2940234395739e The JournalDashboardGraph requires nv, which is lazyloaded. However it requires nvd3.js which is loaded after nv.d3.js. A function called in destroy is defined by nv.d3.js, which can make the crashhappen with the right (wrong) timing. opw 1873749
2018-09-07[MERGE] forward port branch saas-11.4 up to d78f23df848Christophe Simonis
2018-09-07[IMP] web: FieldInteger and FieldFloat can use input of type numbersvs-odoo
This allow the browser/device to handle the experience of handling number in a more native way. FieldInteger and FieldFloat now inherits from NumericField because we want to format it or not dependent of the view (readonly or edit) and the NumericField will manage it. We do that because input type number can't take a value with comma on Chrome (FireFox is more permissive but not perfect because comma is the separator for decimal in this case). Task #1880376
2018-09-07[MERGE] forward port branch saas-11.3 up to 4850fb08385Christophe Simonis
2018-09-05[MERGE] forward port branch 11.0 up to 213759b03e5Christophe Simonis
2018-08-30[FIX] web: fix evaluation context of the domain selectorAaron Bohy
The domain was instantiated without being given any evaluation context. As a result, the uid variable was not defined, crashing the js if present in a user-defined filter. opw 1866852
2018-08-28[FIX] web: accept false value in comparisonMartin Trigaux
momentjs `isSame` method considers undefined values but not false our method _isSameValue does consider false Correct the error when running web tests Deprecation warning: value provided is not in a recognized ISO format
2018-08-28[FIX] web: prevent handle from crashing with text fieldSébastien Theys
289adeb63f51a9af26b8f383ba80089aa7aa6d87 introduced a bug where we tried to trigger an event on an element that didn't exist. Indeed there is no input if it's not in edit mode. This commit fixes it. PR: none Task: none
2018-08-24[FIX] web: force formatType for float_time after instanciationjem-odoo
Since in hr_timesheet, we are binding 'timesheet_uom' widget on existing one (and it might change according to the session info), we came to the case a formatType is different from the one of the widget in the registry. Then, the AbstractField fallbacks on the field type as formatter. Example; timesheet_uom widget is blind on float_time, but their keys are differents in field registry, so the formatter will be 'float' and not 'float_time'. This commit override the formatType determined by the AbstractField for the float_time widget.
2018-08-23[FIX] web: BS4, restore slider checkboxesqsm-odoo
Take advantage of the new BS4 checkbox structure to simplify the widget too.
2018-08-22[FIX] web: properly resize textarea when its value changesSébastien Theys
Before this commit, a textarea would not resize when its value changed if the event was different than "input" or "focus". This commit fixes it by also listening to the "change" event, and by triggering it at appropriate times. PR: #26430 Task: 1869469
2018-08-22[FIX] web: allow o2m navigation to work from required inputsSébastien Theys
In a one2many, pressing ENTER or TAB from a required input (of type text or char) that is on the last editable column of its line would fail to navigate to next line. The issue was that the validation of the required field would happen before the change to its value was actually applied. This commit fixes it. PR: #26430 Task: 1869469
2018-08-16[FIX] web: render JournalDashboardGraph when in DOMAlexandre Kühn
The lib 'nvd3' renders graph when they are attached to the DOM. However, widgets are rendered in fragments and appended to the DOM when ready (to prevent flickering). Before this commit, we used a `setTimeout(0)` and cross fingers that the widget was attached to the DOM when the `render` method was called. With this commit, the render method is called when it is attached to the DOM. Task-ID 1868252 Closes #26410
2018-08-16[IMP] web: add/remove from favorite outside of i tagDavid Monjoie
When paced inside the i tag, the text used to inherit from the style of the star, which means the text was yellow when starred.
2018-08-13[IMP] base, *: use a many2one for the company report layoutChristophe Matthieu
Before this rev. one could set the report layout on the company using a hardcoded list (background, clean, standard, etc.). Other modules (typically accounting modules) could add options in this list. The used template was built on the layout key. Now, the layout is a many2one field to a newly created model `report.layout`, which is linked to a view with the layout architecture. This gives more control to customize reports and create a new layout (without creating a python module that extend the layout selection).
2018-08-13[IMP] web: float_factor and float_toggle widgetsjem-odoo
This commit provides new js widgets for list, kanban and form views on float field. 1/ 'float_factor' displays the normal float field, but takes a conversion factor as option. The displays value is the normal one multiplied by the factor. You can use the widget like <field name="my_float_field" widget="float_factor" option="{'factor': 2}"/> 2/ 'float_toggle' displays a button (in edit mode) looping on a range of given value at each click. A conversion factor is optional (default will be 1) to display a converted value, but sent to non converted one to the server. You can use the widget like <field name="my_float" widget="float_toggle" option="{'range': [0, 0.5, 1], 'factor': 2}"/> 'range' and 'factor' are put in the options. In simple read mode, the widget display the value as a traditionnal text (like a normal char field). This commit provides tests and documentation for those 2 widgets. Task #39079
2018-08-06[FIX] ClipboardJS update for Bootstrap Modals focus issue in ChromeDavid Beguin
Since Bootstrap 4, ClipboardJS does not copy the value in the clipboard anymore as Bootstraps modals give the focus to another element. As the focus need to be given back to the correct element, ClipboardJS has to be updated as the container parameter is only added in v1.7. We were in 1.5. That container parameter allow to give the focus back to the correct element. See doc on https://clipboardjs.com/ + Issue : https://github.com/zenorocha/clipboard.js/issues/155
2018-08-01[MERGE] forward port branch saas-11.4 up to 8d9366197e1Christophe Simonis
2018-07-30[MERGE] forward port branch saas-11.3 up to b4555df336dChristophe Simonis
2018-07-27[FIX] web: empty input for empty password fieldAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/4b3588feb2b7e260bf237b0f3944c90cdc47c3b5 In order to not replace characters with '*' in edit mode (because of `input` with type 'password'), the above commit did not format the value at all. The formatter of a char with the option 'isPassword' turns all of its characters into '*'. That is not intended for password inputs, because the content is hidden by the browser with the 'password' type. The issue with not using the formatter is that an empty field has the value `false`, so an empty password field produces an non-empty password input with its value to 'false'. This commit fixes the issue by forcing empty string for empty password values. Note: if you use an integer field with password, falsy values (e.g. `0`) become empty strings in the input value.
2018-07-27[FIX] web: edited password fields should not contain '*'Alexandre Kühn
Before this commit, when someone was editing a password, the stored password may not be the expected one by the user. Steps to reproduce: 1. Open "Outgoing Mail Servers" form. 2. Set a password (e.g. "yop"). 3. Save, then edit. 4. Add "y" at the end of the password field. > Expected value: "yopy" > Actual value: "***y" This is due to the use of the char field formatter, which displays passwords by replacing the characters with '*'. It is not necessary to do this in edit mode, because it uses an input field of type 'password'. The browser automatically hides the value of such inputs. Any changes on a input field in edit mode uses the value of the input, so the value of an password input should contain the password, without '*'. This commit fixes the issue by using the formatter in edit mode for the input of type 'password'. Task-ID 1869565
2018-07-27[REF] *: BS4, adapt the label component structureqsm-odoo
The '.label' elements have been replaced by '.badge' elements without the 'badge-pill' class.
2018-07-27[REF] web, *: BS4, use custom BS4 checkbox everywhereqsm-odoo
Before this commit, Odoo used checkboxes in three different ways: - A simple <input type="checkbox"/>, mainly in the frontend. The style is browser dependant. - Same as above but with the BS3, checkbox structure. The style is still the same, but the alignement is supposed to be better (which is not always the case). - The Odoo official structure: ``` <div class="o_checkbox"> <input type="checkbox"/> <span/> </div> ``` which allows to have a cross-browser checkbox style and correct alignements. The goal after this commit is to only use the BS4 *custom* checkbox structure to achieve the same goal as our official structure (and remove that one): ``` <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="customCheck1"> <label class="custom-control-label" for="customCheck1">...</label> </div> ``` /!\ Labels are now required (use a zero-width space if necessary)
2018-07-27[REF] *: BS4, adapt col-related classesqsm-odoo
col-lg-* -> col-xl-* col-md-* -> col-lg-* col-sm-* -> col-md-* col-xs-* -> col-* col-lg-offset-* -> offset-xl-* col-md-offset-* -> offset-lg-* col-sm-offset-* -> offset-md-* col-xs-offset-* -> offset-* col-lg-pull-* -> order-xl-1 col-md-pull-* -> order-lg-1 col-sm-pull-* -> order-md-1 col-xs-pull-* -> order-1 col-lg-push-* -> order-xl-2 col-md-push-* -> order-lg-2 col-sm-push-* -> order-md-2 col-xs-push-* -> order-2
2018-07-27[REF] *: BS4, 'img-responsive' -> 'img-fluid'qsm-odoo
2018-07-27[REF] *: BS4, adapt dropdowns and caretsqsm-odoo
- The dropdown structure was simplified, allowing to get rid of the 3-levels structure induced by <ul/> elements and dropdowns can now contain anything. The class 'dropdown-item' is now mandatory for each dropdown clickable element. The class 'dropdown-item-text' can be used to add same padding and style but without making the element have a clickable look. - Dividers now use the class 'dropdown-divider' - The way dropdowns are opened and hidden also changed (before the 'open' class was added on the `.dropdown-menu` parent, now the 'show' class is added on both the `.dropdown-menu` parent and the `.dropdown-menu` itself). - JS-wise, no click event handlers can be put on `.dropdown-toggle` elements anymore (instead, use handlers for dropdown events). - Carets are automatically put on `.dropdown-toggle` elements, so this commit replaces the `.caret` elements with this. This feature was possible to disable but would prevent us from adding a caret with scss. Also, this simplifies the DOM. The 'o-no-caret' class was also introduced to allow using the 'dropdown-toggle' class on non-caret elements. - Also adapt the scss to use $caret-width instead of $caret-width-base
2018-07-24[MERGE] forward port branch saas-11.2 up to 3c521f6d05cChristophe Simonis
2018-07-23[MERGE] forward port branch 11.0 up to 219d2296d67Christophe Simonis
2018-07-19[FIX] web: format value of statinfo widgetlen-odoo
The value of the statinfo widget is rendered by the qweb after a t-esc. Say if the python rounding returned 14.0000000001 (supposed to be a two digits precision number through the magic of floats) then the statinfo widget would print it as-is. We now format the value at assignation. opw 1865426
2018-07-09[FIX] *: fix some side-effects of ↵qsm-odoo
https://github.com/odoo/odoo/commit/9de1bc0eef6f5bfaa2a8d745431caa361ae91548 - JS Modals were not correctly built anymore, their .modal-body element was duplicated and many without-effect JS lines were introduced (as a side effect, the form view design was broken when inside modals) - Tests were changed to make bugs go unnoticed. For example, the media dialog functionnality was entirely broken because the .modal-dialog element was not receiving the correct class anymore. - The JS translation function is _t, not _ - Do not use the <title/> tag as a regular DOM element, it is meant to be unique, in the <head/> section - CSS rules were added to the utils.scss file, which is meant to contain functions and mixins, otherwise, the rule is duplicated in every asset - Some icons were still broken, as missed by https://github.com/odoo/odoo/commit/f90cf060a3cfeb37a67bec83264c0aaab8892b56 - Tests were changed to use [role="dialog"]/footer/header in their selectors without any reason, this commit restores some of that to avoid rebase conflicts with the BS4 work. - ... Note: other elements should still be discussed, like the direct use of the 'o_form_label' class in views definition... but those do not cause direct problems.
2018-06-29[MERGE] forward port branch saas-11.4 up to d54a3726ecaChristophe Simonis
2018-06-28[MERGE] forward port branch saas-11.3 up to 3cdcbce93cbChristophe Simonis
2018-06-27[MOV] web,im_livechat: Move clipboard widget to webYannick Tivisse
2018-06-27[MERGE] forward port branch saas-11.2 up to 12ddec3a767Christophe Simonis
2018-06-22[IMP] Improve compatibility with screen readers (accessibility) (#24574)kujiu
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable. This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader. * [IMP] Labels must have a for attribute. Improve accessibility. * [IMP] Better error message when trying to read a missing cached value * [FIX] Add some aria-label and title attributes for screen readers. * [FIX] Template name is not included in the error message in case of SyntaxError in QWeb * [FIX] Improve the Tour failed at step error message to be more explicit. * [IMP] Add aria-labels * [FIX] Add missing aria-label on failing test * [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all. * [IMP] Color names on kanban views and many2many tags * [IMP] Add some checks on views for accessibility. * [IMP] Add `alt` attribute on `img` tags. * [IMP] Add aria-label and title on non-described icons * [IMP] Add button role to widgets with btn class * [IMP] Translate aria and formatted attributes. * [IMP] Remove wrong aria-labelledby * [IMP] Add menu role on dropdowns * [IMP] Buttons must be focusable * [IMP] Add aria attributes on progress bars * [IMP] Improve accessibility of basic widgets * [IMP] Change main layout to more semantic tags * [IMP] Add menuitem role when missing * [IMP] Remove wrong role='presentation' * [IMP] Improve accessibility of tab panels * [IMP] Add aria-invalid on invalid fields * [IMP] Add aria-sort on ordered columns * [IMP] Add role on alerts * [IMP] Use dialog role, header, main and footer tags for modals * [IMP] Add labels on o_status * [IMP] Improve accessibility of kanban view with feeds and articles * [IMP] Add alerts in case of new messages * [IMP] Add widget, navigation or img role to aria-labelled items
2018-06-21[MERGE] forward port branch 11.0 up to c5ed3729709Christophe Simonis