summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
AgeCommit message (Collapse)Author
2017-04-27[FIX] web: BasicField: use `getSession`Martin Geubelle
`session` is not an field widget attribute anymore. One should use `getSession` instead. This commit also introduces tests for the `binary` field.
2017-04-24[FIX] hr_holidays,web: proper use of toggle_boolean in list viewGéry Debongnie
hr_holiday was the only module that used a widget=toggle_boolean on a button in a list view. That behaviour was implemented as a column widget in the previous list view, and was not reimplemented in the new views. The feature is useful, but this was not done properly: it is better to use a widget on a field (that was the intent) instead of doing a weird hack like it was done. With this commit, we update hr_holidays to use the ToggleBoolean widget, which is supposed to work on every views. Also, we fix the toggleboolean widget (it was not properly rendering tooltips, and changes were not saved in readonly list view). Note that it as the side effect of being better from the point of rpcs: before, the list view had to reload itself. Also, another advantage is that models do not need to implement custom methods (such as toggle_payslip_status) just to toggle a boolean...
2017-04-21[FIX] web: look for nolabel in attributes rather than optionsDavid Monjoie
2017-04-20[FIX] web: allow virtual ids for integer fieldsChristophe Matthieu
Before this change, the redering throw an exception when we try to open a form view with a virtual id. eg: recurrent event in calendar
2017-04-20[FIX] web: JournalDashboardGraph: empty $el at rerenderingAaron Bohy
The '_render' function of field widgets can be called several times in the widget's life cycle (each time its value changes). The JournalDashboardGraph appends a new 'svg' to its the $el at each rendering, so it must empty its $el at the beginning of each rendering. Before this fix, several graphs were displayed in the same kanban card in the Sales dashboard when, e.g., the user changed the color of the card.
2017-04-20[FIX] web: AceEditor tests: don't try to remove libsAaron Bohy
... to clean up once the test is finished, because it doesn't work. The previous solution to clean up only deleted ace and require from window, but doing this didn't force a reload of the libs for a potential second test using ace (because the scripts were still in the page). Trying to remove the scripts from the page doesn't work either because the loadJS function uses an internal cache to prevent from loading twice the same lib. So if we want to have more than one test on ace, we can't clean up the libs.
2017-04-19[FIX] web: use correct timezone for date fieldsChristophe Matthieu
before this commit when toggling allday flag in calendar form view, it was possible to have one day error. The input datetime is wrong when the user don't use the datepicker widget (insert date by keypress instead of click on datepicker) sometimes, the value could be null (crash because try to clone false)
2017-04-19[REF] web, *: implement modifiers behaviorsqsm-odoo
* account, mail, sale Since the views refactoring, modifiers were not properly handled anymore (readonly/required not recomputed, use of readonly/required of "python field" instead of "view field", ...). This commit tries to implement a system which allows to handle the modifiers (re)computation the same way for all the basic views. For this to work, many specialized renderers behaviors have been moved to the basic renderer so that more mechanisms are shared (especially by the form renderer and the list editable renderer). The list editable renderer is hugely impacted by this commit. Here is a list of key changes: - The basic renderer now has a `_renderFieldWidget` function which is used without modification by the form and the list renderers. - Modifiers have to be registered thanks to the basic renderer `_registerModifiersData` function (this is done automatically for fields by the `_renderFieldWidget` function for example). - All instantiated widgets are accessible, organized by record, and ordered in a special basic renderer variable. - The code which resets the widgets of the form view and the code which updates the row of a list editable view is now shared in the basic renderer and now also automatically updates the DOM according to the reevaluated modifiers. - The last point has an huge impact on list editable renderer: all the widgets have to be instantiated when editing a row (even readonly and invisible ones) as they can be switched to editable/visible during edition (after a modifiers update). - `replace_element` and `readonly` options of `AbstractField` are useless: widgets are now always replacing the list editable cells in edition and the `readonly` widget mechanism is replaced by the notion of 'focusable' widgets. (see `AbstractField.getFocusableElement`) - The 'tab' navigation mechanism is impacted by the previous point, some code sharing have been done in basic renderer for this too. - `AbstractField` does not care anymore of the 'required' status, this is the view responsability to check that a required field has a set value on save. - Some list editable bug fixing (e.g. it was possible to edit multiple rows at the same time, it was not possible to navigate towards the previous field, crash on o2m add an item click, ...) - The mockserver now properly simulates server modifiers computation. - ... Note: list editable style may be worse than before this commit but a CSS update is coming in a few days.
2017-04-18[FIX] web: date_picker empty input fieldPierre Masereel
When you try to empty a date or datetime field, you get a traceback saying that 'clone' and 'isSame' are not functions. This error occurs when you empty the field because the value is 'false' and you cannot call 'clone' or 'isSame' on false. To fix this, we ensure that value is not false before calling these methods on it. This bug has been introduced in rev: https://github.com/odoo/odoo/commit/c32724eae06c987e74a0600f1669696e499edc33
2017-04-13[FIX] web: calendar timezone with user configurationChristophe Matthieu
The client must receive the tzOffset to apply this on all hours. To use the date picker we must change the date to apply the change in the user's tzOffset, without this change the result is wrong. For datetime widget we must change like it to avoid max stack error. The server send the tzOffset, if it's undefined, by default the client use the browser time offset. Every test are change to use tzOffset. A test is added in calendar to use the click by position for the fullcalendar lib. This test create and drag and drop an event to check timezone error and error when we use default value in the context. Use formating date like 2026-04-04T08:00:00Z instead of 2026-04-04 08:00:00 is important for phantomjs, because it's crash without information if the formating is not the standard format. For the parsing, when the client receive a server date the date is utc formating but when it's parsed from the client is in the user's timezone
2017-04-13[FIX] web(_editor): field widget htmlAaron Bohy
The field widget html wasn't implemented yet in the new views. A very basic implementation was done in addon web. It only handled the readonly mode so that the field were displayed in studio. This commit removes this basic implementation from web, and re- introduced the old one, converted, in addon web_editor.
2017-04-11[FIX] web: AceEditor Field should be debouncedAaron Bohy
Debounced fields do not notify their environment each time their value changes, but rather wait for a given delay after the last change. Input fields allowing the user to type text should be debounced. The AceEditor is one of them. Note: this should be tested, but i can't find a way to simulate text entries in the ace editor.
2017-04-11[REF] web: Fields: DEBOUNCE is a DebouncedField attributeAaron Bohy
2017-04-11[FIX] web: digits precisionAdrien Dieudonne
- Remove unnecessary "round_decimals". Will be process by format_value - Fix json format value for digits attribute
2017-04-11[REF] web: don't debounce `DebouncedField._onInput` directlyqsm-odoo
The `DebouncedField` class has a `_onInput` method which is called when the user is typing text and which is debounced so that its action (setting the field's value) is not recalled too quickly. The problem is that if we have to do other actions which should not wait for the debouncing (or wait for another debouncing) when the user is typing text, this would imply to namespace the "input" event to add another handler, which is not very elegant. Instead, this commit changes the `DebouncedField` so that the `_onInput` handler is not debounced but instead calls a private method which is debounced (`_doDebouncedAction`).
2017-04-11[FIX] web: monetary should reset on currency changeqsm-odoo
This reverts commit 839a07fbed4720fc71c070507c591295722df350. Indeed, the system will need the `resetOnAnyFieldChange` option as the `FieldMonetary` will need to be re-rendered if the currency changes. This does not use the `_fetchSpecialData` system as it will be refactored later and the currency can be fetched without RPC.
2017-04-11[FIX] web: monetary field was adding DOM at each renderingqsm-odoo
Before this commit, the `render` method of the monetary field added the <input/> and currency elements without removing the previous ones. As this was called on each related `onchange`, the DOM was growing at each of these changes.
2017-04-11[FIX] web: format monetary field value as a float in edit modeqsm-odoo
Before this commit, if a field was declared as a "Monetary" field in the model, the `FieldMonetary` was adding the currency symbol in the <input/> in edit mode.
2017-04-11[REF] web: remove useless use of `empty()` in field renderingqsm-odoo
The jQuery `html` and `text` functions already empty the element, so no need to call `empty` before. + Lint the basic_fields.js file
2017-04-11[ADD] web: add percentpie widget tests and documentationDavid Monjoie
2017-04-11[ADD] web: add statinfo widget tests and documentationDavid Monjoie
2017-04-11[ADD] web: add label_selection widget tests and documentationDavid Monjoie
2017-04-11[ADD] web: add state_selection widget tests and documentationDavid Monjoie
This commit also adds the special_click property which is used to mark a DOM element such that clicks on it will not be intercepted by the list view. Basically, we need this on elements which rely on bootstrap events, since those need to bubble all the way up. If we catch them in the list view, to open a cell or a record, then they never get to bootstrap's level and so the widgets relying on these elements cannot work. We plan to remove it at some point, when we have more time to figure out a way for the click event to reach bootstrap from inside the list view without breaking the list view behavior itself.
2017-04-11[ADD] web: add priority widget tests and documentationDavid Monjoie
2017-04-11[REM] web: remove id widgetDavid Monjoie
The original reason why this widget was created is because sometimes, the id is a virtual one, represented by string in the webclient. As such, the integer widget could not render it properly since it could not parse the integer from the string. This led to the following bug, which in turn led to the creation of the id widget: https://bugs.launchpad.net/openerp-web/+bug/919184 Now, virtual ids are not handled within the record data itself anymore, making it a non-issue to render the id field in the webclient since it is not given a value until a proper id is created. The virtual id management is completely out of the view scope now, rendering this widget useless.
2017-04-11[ADD] web: add boolean button documentationDavid Monjoie
2017-04-11[ADD] web: add url widget tests and documentationDavid Monjoie
2017-04-11[FIX] web: debounce field changes for FieldTextAaron Bohy
like done previously for input fields.
2017-04-11[REF] web: properly confirm value change of debounced input fieldqsm-odoo
Input fields notify their changes when the user is typing text at a rate of max 1 per second (by default) and when a change is confirmed. This last case was handled by listening to the "focusout" event. The "change" event is however more suited to handle that. This commit also solves a problem with the related test. Before this commit, the test triggered some "input" events on an <input/>, then waited some time so that the debounced action is executed, then restarted triggering events... the problem is that this "some time" was long enough to trigger the onchange but not necessarily long enough to be sure another onchange can be started. Indeed, the mockserver get rid of RPC delays but not of CPU delay. As two subsequent onchange cannot be done at the same time (the second one is done after the first one is finished (see Mutex)) and that this test simulates a 3ms delay for the onchange, there is no guarantee that waiting x ms (even > 3ms) will be enough, indeed sometimes we had this sequence: 1) trigger "input" event 2) trigger "input" event 3) start delay of 75ms 4) debouncing time (3ms) is finished: call `_setValue` 5) basic model mutex (already resolved) 6) start async onchange RPC 7) (1) -> (6) took more than 75ms CPU time, the delay started in (3) is finished: trigger "change" event 8) call `_setValue` (no debouncing of "change" events) 9) basic model mutex... NOT resolved as the async onchange RPC started in (6) did not had the opportunity to continue its call sequence (no matter the time it would take) To solve this problem, the 75ms delay had to be replaced by a non arbitrary waiting: the mutex resolution. As the test does not know about this mutex, the only way to be sure it is finished is to wait for the `mockRPC` to be finished thanks to a deferred and then wait for another callstack to be completed thanks to a 0ms delay.
2017-04-11[FIX] web: typo in function name (FieldBoolean._onKeydown)qsm-odoo
When focusing a checkbox field and hitting the "enter" key, the checkbox should change its status. Before this commit, this produced a traceback instead as it was trying to call the `_onKeyDown` function while it was defined as `_onKeydown`. Also the `_onKeydown` method is in fact declared in the `AbstractField` parent implementation, so there is no point in declaring the event binding twice. Also, part of the `FieldBoolean._onKeydown` code was in common with its parent `AbstractField._onKeydown` code so remove it as there is no point in duplicating it. Note: this `_onKeydown` method has to be refactored as it is breaking form view navigation anyway. Also modify an existing test to check the checkbox keyboard navigation.
2017-04-11[IMP] web: domain & field selector usability (+ design)qsm-odoo
+ Document and refactor the files using the new guidelines * Now only non-technical names are used when building field chains and domains (technical names can be used in debug mode). * Better warnings are displayed when using the field and/or domain selector widgets (also checks domain validity in both domain field AND domain selector widget). Also improve design (thanks to original work of @stefanorigano): - Hovering 'remove' highlights the element that will be removed - Hovering 'add node' btns shows where the new node will be created - Restyle debug domain input field (make it similar to a text editor) - Improve design and layout - Resize inner fields
2017-04-11[FIX] web: debounce field changes for input fieldsGéry Debongnie
Before this commit, every field changes were sent upstream and triggered a notifyChange, potentially causing multiple (onchanges) RPCS in rapid succession. It is useful to have a feedback of the new values of the fields even without needing to lose the focus, but it should not be done for each keystroke. With this commit, we debounce the onInput handler, so the method setValue is in practice debounced as well. We need to add a handler on the focusout event to make sure that if the user changes input, the setValue is immediately called. Note that we had to add support for that in the test utils environment (and not only in the createView method: field widgets can be instantiated in other environment, such as the reconciliation widget)
2017-04-11[REF] web: extract _prepareInput from _renderEdit of InputField.David Monjoie
One might need all the preparation stuff that InputField does on its input but might need something else as its tagName and handle the input differently. This commit gets the input preparation code out from the rendering part of the widget so one can render a widget the way he likes and call _prepareInput on his input. This is used in monetary field which requires all the feature of InputField but with the input actually being one level deeper in the DOM than the standard InputField.
2017-04-11[ADD] web: add monetary field documentationDavid Monjoie
2017-04-11[ADD] web: add phone widget tests and documentationDavid Monjoie
2017-04-11[ADD] web: add email widget tests and documentationDavid Monjoie
2017-04-11[ADD] web: add handle widget documentationDavid Monjoie
2017-04-11[ADD] web: add text field documentationDavid Monjoie
2017-04-11[ADD] web: add float_time field tests and documentationDavid Monjoie
The functions for parsing and formatting float_time were completely duplicated between field_utils and basic_fields.
2017-04-11[ADD] web: add float field tests and documentationDavid Monjoie
2017-04-11[ADD] web: add integer field tests and documentationDavid Monjoie
2017-04-11[ADD] web: add boolean field tests and documentationDavid Monjoie
2017-04-11[ADD] web: add date and datetime fields tests and documentationDavid Monjoie
2017-04-11[ADD] web: add input field documentationDavid Monjoie
2017-04-11[FIX] web: prevent onchanges from re-rendering the current fieldDavid Monjoie
Input fields should not be re-rendered by the onchange mechanism as they might exhibit formatting that you do not want to have when typing. The list view was not propagating the original event to the lower functions like the form view does, so I added it there.
2017-04-11[FIX] web: apply digits option from view on float fieldsDavid Monjoie
Previously, only the value in the python description of the field could be used.
2017-04-11[REF] web: use `specialData` system in domain fieldqsm-odoo
The domain field needs two pieces of information that traditional fields do not have without extra RPCs and computation: the value of another field in the view to know the model to use and the number of records matched in this model with the current field value. While the first one can be retrieved synchronously by the field widget, the second one required an extra RPC during the rendering phase. The `_fetchSpecialData` system introduced in the `BasicModel` implementation allows to stop doing this extra RPC during rendering. As the RPC requires the model value to be done, the information is also fetched by the `_fetchSpecialData` code and given directly to the widget. This also removes the utility of the `resetOnAnyFieldChange` option used by this field widget.
2017-04-11[FIX] web: ace editor field was not properly saving changesqsm-odoo
Two changes were ignored: - The first change - The last done undo This commit refactores the field so that: - The ace setValue function is called only if the value really changed (prevent losing focus / undo stack / retrigger "change" event / ...) - As the ace setValue triggers multiple "change" events, only consider the last one - Same rendering function for edit/readonly modes - Only listen to "change" events in edit mode
2017-04-11[REF] *: use _rpc method for all rpcsGéry Debongnie
The _rpc method is now the preferred method to do a rpc, so we need to update all calls.
2017-04-11[IMP] web, *: compute contexts and domains from datapointqsm-odoo
This commit tries to refactore the management of contexts and domains in the webclient. - Get rid of CompoundDomain: use standard array manipulation to join multiple domains or use the Domain class (to be improved) - Get rid of data.js build_domain and build_context methods - Link this.record to the data point from the basic model for all fields (not only relational fields) - Add a getContext and a getDomain function to the basic model data point (localData element) so that AbstractField implementations can use them thanks to their this.record element. - Remove the autocontext binding for field RPCs (see FieldManagerMixin)