summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core
AgeCommit message (Collapse)Author
2021-05-28[IMP] web: add findWhere utilsBruno Boi
closes odoo/odoo#70936 Taskid: 2412172 Related: odoo/enterprise#18366 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-05-28[FIX] web: parseDateTime util optimizationsBruno Boi
- `parseDateTime` util: we now caches "without zero" date and time formats Taskid: 2412172
2021-05-17[FIX] web: domain: (=)(i)like operatorsAaron Bohy
Before this commit, evaluating a domain containing a like/ilike operator with an evaluation context in which the value was false crashed. Moreover, those operators were wrong w.r.t. the case sensitivity: like was case insensitive, whereas ilike was case sensitive, and both =like and =ilike were case insensitive. This commit fixes thoses issues. The first issue was spotted on our prod, as we tried to add an invisible attrs in a form view, using the ilike operator (it thus crashed in create mode). The second issue was spotted while writting the test cases. To the best of our knowledge, those operators aren't used in attrs (for now), explaining why those issues haven't been found before. closes odoo/odoo#70876 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-05-05[FIX] web: Aria attributes on buttons Export All & optional columnsLuis González
Some aria attributes were missing or incorrectly set on these new buttons: - The button "Export All" was missing an `aria-label` attribute - The button to show/hide optional columns was also missing an `aria-label` attribute, and its menu items (checkboxes to show/hide columns) were missing a proper role - Ever since the debug manager was added in frontend on 73327db0656b, the `aria-label` attribute was not being rendered correctly on the button to open developer tools closes odoo/odoo#70390 X-original-commit: 620e4cc28cefed6f4a3b5ca89b11cc37222acfaf Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-04-29[FIX] *: bunch of mismarked translation specifiersXavier Morel
`_(xyz)` will wrap them in an underscore.js object, which when used in a string context will just return the string. So it's basically a no-op, but it certainly doesn't translate the terms. closes odoo/odoo#70000 Related: odoo/enterprise#18001 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-04-15[FIX] web: do not use default en_US lang when loading translations from sessionAnh Thao Pham (pta)
When loading translations from Session, if no lang is defined in context or html, it is loading translations of en_US lang by default. No default should be used to fallback on the language of the current user. opw-2501708 closes odoo/odoo#69318 X-original-commit: a93a0a33c7447505403097c7ba0707d55d252e64 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2021-03-11[FIX] web: prevent popover race condition between unmount and eventSébastien Theys
These are throttled/debounced so the handlers are sometimes called after the component has been destroyed. opw-2451752 closes odoo/odoo#67723 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-11[FIX] web: keep null/false/true strings in domainsAaron Bohy
Before this commit, occurences of 'null', 'true' and 'false' strings as autocomplete values in the search view were replaced respectively by None, True and False. Fixes #65743 closes odoo/odoo#65900 X-original-commit: 74311c753e7286c27b83dca2b598e040ed9e586f Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-10[FIX] web: call do_hide/do_show on a destroyed widgetAaron Bohy
Before this commit, calling do_hide/do_show/do_toggle on a widget that had been destroyed before being rendered crashed (because this.$el was undefined). Obviously, calling those methods in this situation is useless, but with asynchronous code, it might happen that you call them in an handler, and they have been destroyed meanwhile. This commit checks if this.$el is set before accessing it to avoid the crash. closes odoo/odoo#65889 X-original-commit: 320c29f5b37d4f02b4d5f7b1b6ff64462b000c92 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-01-19[FIX] website: an erroneous Google font makes website not editablenie
Steps: - Go to "Website" > "Go to Website" - Click Edit in the top right corner - Click Options - Select "Add a Google Font" in the Font Family field - Insert an erroneous Google Font link (e.g. https://fonts.google.com/specimen/Robotoj ) - Save & Reload - Click Edit again Bug: The Edit button is not responding anymore Explanation: We try to `@import` the link in multiple files. For example, here: https://github.com/odoo/odoo/blob/70eb39b0cf30c1acf9a7116e109874b60e27aa2c/addons/website/static/src/scss/website.scss#L10 An erroneous font family results in an error 400 from the Google Fonts server. This prevents parts of the JS to load and makes it impossible to enter the edition mode. `EditPageMenu` handles the behavior when clicking on the Edit button. This menu depends on `website.compiled_assets_wysiwyg` as seen here: https://github.com/odoo/odoo/blob/b02a99bec709b5a6dc4dabb6cb81435dadc24e7e/addons/website/static/src/js/menu/edit.js#L10-L14 Since there is an error generating the file, the Promise fails but the error is not handled: https://github.com/odoo/odoo/blob/70eb39b0cf30c1acf9a7116e109874b60e27aa2c/addons/web/static/src/js/core/ajax.js#L164-L168 This commit prevents CSS loading errors from silently failing. The crash screen will only show up if the user is logged in and has edition rights. This commit also prevents the user from posting the form if the font is not accessible. At the moment, querying an unknown Google font from a script will result in a CORS error. A valid one will pass just fine. In case Google changes the behavior of these queries and allows the 400 to be sent, the fix also checks if the query returned an `ok` status code. opw:2439073 closes odoo/odoo#64695 Signed-off-by: backspac <backspac@users.noreply.github.com>
2021-01-20[FIX] web: Dialog widget should always call on_{attach|detach}_callbackPierre Paridans
Before this commit, the `on_attach_callback` and `on_detach_callback` callbacks are not called all the time on the `Dialog` widget when it's attached/detached to the DOM. Relying on those callbacks could result in unpredictable behaviours. To be more precise, the `on_attach_callback` isn't executed on a regular Dialog#open() call. But Dialog spawned by the ActionManager will execute it. This difference prevents from properly binding those callbacks later on through an extend or include of the Dialog widget as we have no way to know if they have already been called or not (e.g. which can result in calling them twice). This commit normalize this situation by ensuring that the `on_attach_callback` and `on_detach_callback` callbacks are properly called by the Dialog widget and allows any extension of this widget to rely on them. Therefore the ActionManager is adapted accordingly. opw-2438534 closes odoo/odoo#64780 Related: odoo/enterprise#15849 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2021-01-14[FIX] web: make Popover patchablePierre Paridans
Allows customization for enterprise. Task ID: 2347640
2021-01-14[FIX] web: make OwlDialog patchablePierre Paridans
Allows customization for enterprise. Task ID: 2347640
2021-01-11[FIX] web_editor, website: prevent multiple click on saveRomain Derie
Clicking on save on html editor is taking quite some time. The user might think something is not happening and need to click again. If he does click again, 2 write RPC will be sent, making the COW business code being triggered twice, ultimately leading to create 2 COW. Instead of A / \ B B' It will be A / | \ B B' B' With as many B' than there is click on save. This commit adds a generic helper to make a button load/spin. closes odoo/odoo#63417 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-09-25[FIX] web, web_editor: fix scroll to hidden dropped snippetsBenjamin Vray
Fix the scroll when the snippet is the dynamic one because it did not work as we tried to get the offset of an element with the d-none class. Remove the scrollValue variable because we don't need it anymore. It was used before the code was reviewed in a previous commit. task-2312878 closes odoo/odoo#58486 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-09-24[FIX] website, *: review modal behaviors with right-panelizationqsm-odoo
*: web, web_editor Since the right-panelization made with [1], the modals were not compensating the body scrollbar when opened anymore and the backdrop was misplaced. This commit fixes the problems generically, to support modals with non-body scrolling. [1]: https://github.com/odoo/odoo/pull/57975 closes odoo/odoo#58414 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-09-23[FIX] web: properly compute popover positionSébastien Theys
- avoid updating default position list in place - ensure computed position takes into account enough margin with border - fallback to requested position instead of bottom Part of task-2270731 closes odoo/odoo#58368 X-original-commit: 3fad17421518732db2085c3eec596600cfe34f03 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-09-23[FIX] web, mail: recompute popover on content changeSébastien Theys
Because the position of the popover depends on the size of its content. Part of task-2270731 X-original-commit: 3066a946ef1ca0973503207d0486515798168fa2
2020-09-22[IMP] website, *: move page scrollbar to #wrapwrapqsm-odoo
*: web, web_editor, portal, account, website_blog, website_forum This is probably not ideal to move the scrolling behavior out of the html element but this will be needed for the editor to not have a double scrollbar on the right. This is actually also useful for the scrollbar to appear under the purple odoo menu instead of its right. This commit, if to be reverted in the future, however contains many improvements to make the transition easier that should be kept: jQuery and Odoo functions to be able to scrollTo a specific element, get the top scrollable element, check if an element is scrollable, etc. Also, some magic was done: if some code tries to scroll to a specific scroll position via jQuery's scrollTop or animate functions on the html/body element, those will still work as intended (obviously, using the new utils to do that is however recommended). This commit also reviews our scroll behaviors to make them more robust and share the code. Part of https://github.com/odoo/odoo/pull/57975 task-2344227
2020-09-10[IMP] auth_totp: notify user on activation and deactivation of OTPXavier Morel
Was not super visible, especially without HR as the dialog immediately closes (limitation of the web client), or when an administrator user massively disables totp. Show a toast notification indicating the success of the action. Also fix the logging of `totp_disable` so it correctly handles being called on more than one record, and change the logging data to <browse_record> (<logins>) across the board. Also add a way to provide an action to execute after a notification: by default nothing happens, which leads to dialogs not closing and forms not reloading, and there is no good way to show a notification and/then do some other thing, which is inconvenient.
2020-09-10[IMP] web, website: prevent auto scroll from left panelLaurent Stukkens (LTU)
* Prior to this commit, when starting to drag a new snippet from the left panel, the auto scroll feature was triggered if the snippet was one of the top or bottom ones. * After this commit, the auto scroll feature will be disabled from the left panel. task-2307404 closes odoo/odoo#56208 Related: odoo/enterprise#12539 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-08-27[FIX] web: implement more complete menu autohiding featureqsm-odoo
The code in charge of adding inside a dropdown the menu items that would be forced on a second line was not doing it properly when there were some display: none items and especially not when there were neighbours using the m*-*-auto classes. Part of https://github.com/odoo/odoo/pull/56427 task-2264627
2020-07-23[IMP] web: Model: extensions registryJulien Mougenot
Refactoring of the Model class of `model.js` to support multiple extensions. The purpose is to build a model having the appropriate modules for a given situation. For instance, we don't need the control panel model if we don't have a control panel to start with. Some logic of the control panel model (which was until now the "main" search model) has been given to another model extension named "Search Model Extension" which will synchronize the informations of all models providing search data (domain, context, etc.). The model instantiated in the actions/views is now an instance of the "Action Model" (which directly extends the Model) and is meant to replace the view model in the long term. It might however need some improvements to hold such a role (partial interface rendering, etc.). Part of task 2228968 Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2020-07-23[IMP] web: add Registry predicateJulien Mougenot
Before this commit, any value could be added to registries and the class needed to be overridden to assert that added values would answer to a certain predicate. Now, the registry can be instantiated with a given predicate function that all added value must pass to be registered (default: all values are accepted). Existing implentations have been adapted: - FieldRegistry - FieldRegistryOwl.
2020-07-23[REF] web: Registry goes ESNextJulien Mougenot
Converted the Registry class to an ES6 class with the new framework standards.
2020-07-14[IMP] web: improve eval context datesJulien Mougenot
This commit handles 2 things: 1) the merging of the `py_utils.context()` into the evaluation context returned by `BasicModel._getEvalContext` to access the same time-related keys, 2) the addition of 2 new keys into the `py_utils.context` (thus transmitted to the basic model): `today` (an alias for the already present `current_date`) and `now` which represents the current date and time value. Task 2269697
2020-07-13[FIX] web_editor, web: fix traceback with drag & drop when no headerqsm-odoo
Commit [1] introduced the bug by relying on the fact an element with id=top is in the edited DOM. As the website header can be disabled, this induced a crash as soon as the header was indeed disabled. Also, the editor is not meant to edit the website only so we cannot rely at all on the presence of a #top element. [1]: https://github.com/odoo/odoo/commit/6df67a28c2f113572acd4a3db19ab6b1bd37e7da closes odoo/odoo#54409 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-07-13[IMP] web,*: do not deploy services in testsAaron Bohy
*mail,point_of_sale,web_editor,website In the tests, required services are deployed for each test independently. There is no need to have, in additon, all services deployed globally. Worse, it could conflict and lead to unexpected results. This commit ensures services are no longer deployed globally in tests. It turns the module 'web.env' into a declarative module with no side-effect, by moving the service deployment to main.js, which isn't added to the tests page. Task 2287397 closes odoo/odoo#53817 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-07-10[FIX] web: remove forgotten console.logqsm-odoo
Commit [1] merged a debug console.log. This commit removes it. [1]: https://github.com/odoo/odoo/commit/6df67a28c2f113572acd4a3db19ab6b1bd37e7da Part of https://github.com/odoo/odoo/pull/54311 closes odoo/odoo#54311 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-07-08[REF] web_editor,web: reuse the autoscroll on drag featureLaurent Stukkens (LTU)
Prior to this commit, the autoscroll on drag feature was accessible and only used in the web_editor application. After this commit, the autoscroll on drag feature will be available in the web application and has been refactored in order to allow its usage in other application (as for the sign application). task-2280965 closes odoo/odoo#54072 Related: odoo/enterprise#11656 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-30[IMP] web, *: replace the bootstrap backdrop element with a bg on modalsBenjamin Vray
*: web_editor Do not display the backdrop element added by bootstrap in the body and add a background on the modal to keep the same effect. The bootstrap backdrop was probably useful for compatibility with <IE9 but is no longer needed. This also avoids z-index issues because modals could be opened in an element (e.g. the website #wrapwrap) whose stacking context is different of the body one (where the backdrop is opened). This would make the backdrop appears on top of the modal. Part of https://github.com/odoo/odoo/pull/49142 Related to task-2229551 Co-authored-by: qsm-odoo <qsm@odoo.com>
2020-06-22[IMP] web: add support of "sample" attribute in viewsJérémy Hennecart
With this commit, it is now possible to display sample (fake) data in empty views, in the hope of easing user onboarding. This can be enabled (in list and kanban views) with attribute sample="1" on the arch root element. In this case, if there is no data to display, sample data will be generated based on heuristics (depending on field types and names). This can be used in addition to the no content helper. Task 2232801 X-original-commit: 7c8e627ff5029cb539d702705e5ce53d658c76ed Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Jérémy Hennecart <jeh@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-22[IMP] web: utils: add groupBy functionJulien Mougenot
This commit introduces a new utility function: 'groupBy'. It is similar in API and result as the underscore method of the same name. X-original-commit: 834a1967161dc537cb2d5543314a062dbac08f9c
2020-06-19[FIX] web: disable the autohide menu feature for hamburger menusqsm-odoo
Before this commit, checking if the menu was visible or not combined with checking if we are on desktop or not was enough. Now that we have website header templates using hamburger which can be enabled in desktop, this was not enough anymore. closes odoo/odoo#53307 X-original-commit: 04e95bc191bba8bc3aaa36aec7b61e085744e85b Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-06-17[FIX] web: load_translation fallback to url languagejvm-odoo
This commit is fine tuning of 9f142c8ff5a383. Apparently, context_get callback is never called. I guess this is due to the fact that we are higher. context_get is defined in public/public_root.js and we are in core/session.js The only way to fix is to retrieve the HTML tag language. OPW-2244843 closes odoo/odoo#53155 X-original-commit: 2bbb8fbf7ae909da03d97d16b228ae5a95de7d18 Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-06-17[FIX] web: fix in and not in js domainjvm-odoo
This commit fix the in and not in operators in domain.js. _.contains works only if you have an array in the left part. So if you have an array in the right part it will not work correctly. Using _.intersection solves the problem. OPW-2274990 closes odoo/odoo#53150 X-original-commit: 7e3fbfaf5a39f7e26b3a9073144f682086265920 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
This commit is a significant rewriting of client-side discuss, chatter, chat window, and messaging menu using OWL. The behavior should be broadly the same, with some slight functional changes here and there. From a technical standpoint, the code of messaging is mainly organized in 2 main groups of modules: - models, which are logical entities that depict the client-side state of messaging as a whole. - components, which are in charge of displaying information from models. This refactoring also introduces new JS guidelines regarding folder structure (/static) and naming rules for JS modules. Community PR: https://github.com/odoo/odoo/pull/39023 Enterprise PR: https://github.com/odoo/enterprise/pull/6249 Task-1914207 This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier, with the precious help of Lucas to speed it up towards the end. closes odoo/odoo#39023 Related: odoo/enterprise#6249 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre Kühn <aku@odoo.com> Co-authored-by: Julien Giannone <jgi@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com> Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-12[IMP] web,*: properly define env in the frontendAaron Bohy
*bus,mail This commit extracts the common basis of the env to use both in the frontend and the backend. The public env now contains most of the features that were previously (only) in the webclient env. Moreover, the PublicRoot no longer uses the ServiceProviderMixin, such that services are only deployed once, in the (public) env. Owl components can now be defined in the website, and rely on a properly built env. Legacy widgets still works as they access services through the PublicRoot (via trigger_up) which redirects those requests to the env.
2020-06-11[FIX] web: load_translation fallback to url languagejvm-odoo
Issue - Install eCommerce, Sales, Stock, Product availability - Install another language & add it to website too - Create a product - eCommerce tab select 'Availability Show ': inventory below a threshold and prevent sales if not enough stock - Go to website, publish it - Private tab > go on your website url - Open the product page Availability text should show up - Switch language without debugger open Availability text not translated - Open debugger with disable cache - Refresh Availability text translated Cause In this case, we have no user_context, but the load_translation is based on the user_context language. Since lang = undefined, we use the cached language Solution Fallback to the context language if the user_context langague is not defined OPW-2244843 closes odoo/odoo#52868 X-original-commit: a9a756cf75963e0771a05859b29b03f08ae592b1 Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-06-10[FIX] web: don't forget initial registry entriesMathieu Duckerts-Antoine
The entries comming from the optional parameter 'mapping' passed at the instantiation of a registry were never considered when returning the registry keys or entries. This is no longer the case. closes odoo/odoo#52768 X-original-commit: e094ddd0ffaf3357e64ca5941ffc2e0454c24ab7 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-06-10[IMP] web,*: make notification title optionalDhruv Patel
*odoo_referral,portal Currently, it is not possible to have one line notification, when you are not passing the title parameter as an option when generating the notification,then it will display the blank div with the default button icon only. so it is not possible to have one-line notifications since the title is mandatory. So the purpose of the task is to make the title optional, allowing for more minimalistic notification. Also removed some unnecessary titles from the notification and some stying change. This commit also increase the autoclose delay of non sticky notifications, from 2.5s to 4s. task : 2264749 closes odoo/odoo#52229 Related: odoo/enterprise#10981 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Dhruv Patel <dhp@odoo.com>
2020-06-04[IMP] web: Comparison menuMathieu Duckerts-Antoine
This commit replaces the "time range menu" in the control panel by a new component: the "comparison menu". Its purpose is roughly the same: compare a period of data in a reporting view with the previous period or the previous year. Its implementation is a bit simpler: it will only appear if at least one date filter is selected in the search view, and will suggest to compare each selected date option with the previous period or the previous year. Task ID: 2245719 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-05-15[IMP] web: various Popover improvementsSébastien Theys
Close can now be requested by children (slot content) with the event `o-popover-close`. This feature is necessary if we want a "close" button inside the popover itself, which is the case for mail.activity "Mark Done". Clicking on the popover target now acts as a toggle, which is also a feature that was expected from the previous popover implementation. Add a specific class (`o_is_open`) when the popover is displayed to be able to style its target depending on whether it is displayed or not. Ensure computed position is whole number of pixels to prevent flicker issue on Firefox. Remove forced width to let the component grow with its content. Add appropriate z-index to prevent overlap issue with the rest of our interface. closes odoo/odoo#50850 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-14[IMP] *: convert to private methodsMartin Trigaux
render, render_template, load, activity_schedule_with_view, get_website_pages should all be private: It should not be possible to render an aribtrary template only with its name or id Still need to render some qweb views from js so the method render_template is kept public. This explains why the website editor still need read access on ir.ui.view as we want to allow any snippet to be rendered.
2020-05-05[IMP] web: Standardize FALSE and TRUE leaves/domainsJulien Mougenot
Add four static properties on the Domain.js class: (TRUE|FALSE)_(LEAF|DOMAIN). This increases consistency for domains using these concepts.
2020-05-05[IMP] web: add sortBy to core.utilsJulien Mougenot
Add a "sortBy" helper to core utils. This function takes an array and an optional criterion as arguments and returns a new array sorted according to the given criterion.
2020-04-27[IMP] web: handling of escaping in literalsXavier Morel
Handling of escapes (`\`) was performed during evaluation rather than parsing, so strings in the AST stored the escaped form (rather than the proper one), and _formatAST had to mess around in order to try and get it back into a semblance of relevance (especially as the AST would store the escaped string without delimiters). Fix: perform the escapes handling (aka normalisation) during tokenization where it belongs. This means the AST formatter can now just JSON.stringify the data. Until and unless we decide to produce a cpython-compliant repr (https://github.com/python/cpython/blob/0169d3003be3d072751dd14a5c84748ab63a249f/Objects/unicodeobject.c#L12902-L13006) which is unlikely. closes odoo/odoo#50236 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-04-16[REF] web,mail: use patchMixin and patch instead of utils.patchMichael Mattiello (mcm)
This commit replaces the use of utils.patch by the new class patcher and makes the renderers that are converted to owl patchable. closes odoo/odoo#47700 Related: odoo/enterprise#9551 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-04-16[IMP] web: add es6 class patcherMichael Mattiello (mcm)
This commit implements a new way to monkey-patch ES6 classes (for instance, Owl Components). Usage ----- odoo.module('module.BaseClass', function (require) { const patchMixin = require('web.patchMixin'); // Define your class as usual class BaseClass { constructor() { this.foo = 'foo'; } bar() { console.log(this.foo); } } // but export it like this to have a "patchable" version return patchMixin(BaseClass); }); odoo.module('module.Patch', function (require) { // imports the "patchable" version const BaseClass = require('module.BaseClass'); BaseClass.patch('key', T => class extends T { constructor() { super(); this.foo = 'patched foo'; } bar() { super.bar(); console.log('patched bar()'); } } ); }); odoo.module('module.instance', function (require) { // imports the "patchable" version const BaseClass = require('module.BaseClass'); const obj = new BaseClass(); obj.bar(); // if module.patch is loaded before this module the patch // will be apply and calling obj.bar() will log: // patched foo // patched bar() // You can unpatch a patchable class BaseClass.unpatch('key'); });
2020-04-14[IMP] web: add a <Popover> componentDamien Bouvy
Using bootstrap popover with owl is possible, but with a lot of friction. This commit adds a Popover element to ease developments that require a popover. This component takes 2 props: - position='bottom' (optional): 'top', 'bottom', 'left', 'right' - title (optional) Its usage requires setting an `opened` slot for the content of the popover, whilst the 'trigger' of the popover uses the default slot. E.g. ```xml <Parent> <Popover> <t t-set="opened"> <p>You have opened the popover, congratulations!</p> <button t-on-click='_handlerOnParent'>Dispatch cake</button> </t> <button class="btn btn-primary">Click me!</button> </Popover> </Parent> ``` Note that: - only one popover can be opened at a time (opening a popover will close any previously opened popover) - `Popover` uses `Portal` under the hood, so events are propagated correctly even though the popover is teleported elsewhere in the dom (see example in this commit message with `_handlerOnParent`) - `<Popover>` is registed as a global component in QWeb and does not need to be added to a Component's subcomponents list closes odoo/odoo#47710 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>