summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/content/website_root.js
AgeCommit message (Collapse)Author
2019-06-03[MERGE] forward port branch saas-12.2 up to 995aa1685eeChristophe Simonis
2019-05-21[IMP] website: add specific object for Optimize SEORomain Derie
Before this commit, the object used by Optimize SEO 'wizard' was always the main object, without any possibility to change that (except by changing the main object but that would cause a lot of other issue, eg edit in backend). This commit add the possibility to explicitly set a seo object on the html data attribute. If set, this one will be used instead of the main object. This is useful for event.event where all the event pages (with website menu enabled) would share the same SEO since the main object would be the event.event. With this commit, the seo object is now the website.page, thus giving the possibility to have a separate SEO for every event pages. (Required for Odoo.com website for OXP) closes odoo/odoo#33194 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-02[MERGE] forward port branch saas-12.1 up to b11930047f6Denis Ledoux
2019-04-15[FIX] website: submit formNicolas Martinelli
Example where the issue occurs: - Publish an event - Go to the website, register for that event - At confirmation, when the email address is requested, click quickly several times on the 'Continue' button Several registrations are created since nothing prevents multi-clicks. The stateful button feature of the `button.js` jQuery plugin has been dropped in Bootstrap 4 (see [1]). [1] https://getbootstrap.com/docs/4.1/migration/#buttons opw-1958580 closes odoo/odoo#32571 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-03-06[REF] website: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-26[REF] website, *: stop using 'animation' confusing nameqsm-odoo
* web, website_blog, website_sale, website_twitter Before this PR, all website widgets were named 'Animation'. Now that they are 'Public Widgets', we can at last stop using the confusing 'animation' name. Part of https://github.com/odoo/odoo/pull/29442 task-1932066
2019-02-26[REF] website, *: move and review the notion of edit modeqsm-odoo
* portal, sale, web, website_blog, website_crm_partner_assign, website_forum, website_event_track, website_links, website_mail, website_slides, website_mail_channel, website_mass_mailing, website_sale, website_sale_comparison, website_sale_delivery, website_sale_wishlist The `editableMode` option and its related options in public widget should only be part of website, this commit moves them there. This is also the occasion to implement something that is long overdue: stop creating 'animations' / public widgets in edit mode by default. Indeed, lots of 'animations' were defined by beginning with 'if not edit mode'. Now, if a public widget should be considered in edit mode, it must be defined explicitely through a property at *definition* of the widget. Part of https://github.com/odoo/odoo/pull/29442 task-1932066
2019-02-26[REF] *: use 'frontend' system in non-website appsqsm-odoo
* account, auth_signup, payment, portal, project, sale, sale_management, web_unsplash, website, website_mail, website_rating, website_sale This commit does probably not do what is stated for all non-website apps but it is a first step. It also uses the system in apps which could have already used it but did not. Part of https://github.com/odoo/odoo/pull/29442 task-1932066
2019-02-26[REF] website, web, *: move part of website into webqsm-odoo
* im_livechat, survey, website_forum When website is installed, the JavaScript code has access to utilities to define improved widgets which are automatically attached to existing DOM elements on page load. Those mechanics are more and more needed in portal which does not depend on website (as it is website which depends on portal). This commit moves part of website JS to web, so that it can be used by all 'frontend' apps whose only common dependency is web (portal, survey, auth_signup, ...). This PR also questioned several other similar issues which will be handled later like: - website should maybe not depends on portal but only on http_routing - part of portal should be moved to http_routing and http_routing should be renamed (especially for frontend layouts, etc) so that apps like survey can reuse some common code Part of https://github.com/odoo/odoo/pull/29442 task-1932066
2019-02-26[REF] website: split WebsiteRoot definition / instantiationqsm-odoo
In preparation to future commits, the WebsiteRoot instantiation is moved in an other file than its definition. Part of https://github.com/odoo/odoo/pull/29442 task-1932066
2019-02-05[REF] website, *: remove 'website.context' moduleqsm-odoo
* website_forum, website_gengo, website_mail_channel, website_sale Retrieving the global context is now the root's job, this will prevent problems when trying to extend the values the context has. See upcoming improvements with https://github.com/odoo/odoo/pull/29442 closes odoo/odoo#30816
2019-01-31[REF] website: merge `BodyManager` and `WebsiteRoot`qsm-odoo
Following the new editor's merge at https://github.com/odoo/odoo/pull/29775, 'web_editor.BodyManager' stopped being used by the editor and the related file was moved to website without being renamed or considered. Hopefully, the editor replaced it by something else so the `BodyManager` makes no sense on its own anymore. This commit merges its features with the only other component which still used it: `WebsiteRoot` See upcoming improvements at https://github.com/odoo/odoo/pull/29442 (related to task-1932066) closes odoo/odoo#30740
2019-01-24[FIX] website, *: restore 'animation' system to the way it workedqsm-odoo
* website_forum Following the new editor's merge at https://github.com/odoo/odoo/pull/29775, the website 'animation' system was 'extended' to vaguely use a 'Registry' instance instead of an object. This was however left undocumented, with a require in the middle of a file, restarting all animations when used, only used by website_forum... with more code for no reason at all, ... This commit restores the system to the way it was before and re-adapts website_forum: - No need to check if website_forum is in the DOM as it is already checked by the animation system (on top of that... the new code was checking the DOM before it was ready...). - No need of a dynamic add on a registry, this is always done before the DOM is ready, so before the animations are started. - No need to know the root instance in website forum, just use the animation as the Wysiwyg instance's parent. The goal of this commit is also to avoid useless conflicts with https://github.com/odoo/odoo/pull/29442 (that should not have had any conflict at all as totally independent of the editor task...) closes odoo/odoo#30478
2019-01-22[REF] website, *: rename and simplify web_editor.contextChristophe Matthieu
* website_forum, website_gengo, website_mail_channel, website_sale Following the new editor's merge at https://github.com/odoo/odoo/pull/29775, the web_editor.context module was moved to website without being renamed. This commit renames it to website.context but also merge the website extension that was made to that context directly within its definition. closes odoo/odoo#30409
2019-01-17[IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' fieldChristophe Matthieu
* Creating a new structure by transforming all the plugins in the library using the odoo inheritance system. Plugins are easier to implement with the AbstractPlugin to add Odoo behaviors. * From now on, the methods of the library (in this case Summernote) can no longer be called by other modules or files. Only the wysiwyg widgets can access it, to simplify the updating process. The wysiwyg object serves as an interface. * Depending on the options the snippets will be loaded or not, the editor will be in an iframe or not... all of this is transparent from the outside. * Regarding iframes, all controllers related to editing have been removed: the new API no longer needs them. This speeds up loading, eases testing and removes complexity for the same features. PUBLIC FEATURES There are several public methods on the Wysiwyg class: * Wysiwyg.prepare (WidgetParent): returns a deferred resolved when the library (xml, lazy, assets...) is loaded. * Wysiwyg.getRange (DOM): returns the range (selection in the dom) * Wysiwyg.setRange (startNode, startOffset, endNode, endOffset): creates a range (selection in the dom) * Wysiwyg.setRangeFromNode (DOM, options) that creates a range from an element (option available to select all, start or end) A jQuery selector was added: :o_editable, which indicates whether the current element is editable. That is, if it is contained in a tag with the attribute 'contentEditable = "true"' or in a tag with the class o_editable. Several methods are also present: * focusIn: makes a focus and places the cursor at the beginning of the element * focusInEnd: makes a focus and places the cursor at the end of the element * selectContent: makes a focus and selects the content HTML FIELD The HTML field can receive different options: * style-inline: {boolean} transforms a class into an inline style when saving and vice versa when reading. * no-attachment: {boolean} prevents the use of attachments (in media dialog) * cssEdit: {xml_id} to use a template containing the css to loaded in an iframe when editing * cssReadonly: {xml_id} to use a template containing the css to load into an iframe when viewing in readonly * snippets: {xml_id} snippets template (can be used with or without cssEdit) * wrapper: {template} qweb static template (containing a tag: id = "wrapper") that will include the content during editing (removed on save) MASS MAILING A widget was created for mass mailing. There are now two fields: body_html and body_arch. body_arch contains the code with the class without conversion into inline style, useful when editing and one with the inline style that is visible in readonly mode and sent by email. Advantage: no spreading errors, able to update css/theme, able to do more changes when converting to inline style so that a maximum of mail clients have an impeccable rendering. Co-authored-by: Antoine Guenet <age@odoo.com>
2018-09-25[FIX] website: website forced on wrong session with website selectorRomain Derie
Forcing website on session before navigating to the other website would not work as expected if the other website has a different URL (hostname). It would force the website on session on current website, then navigate to second website which could still had another website in session. Now, we force the website in session once we land on the website in the dispatch() method. Step to reproduce: - Set website1 to 127.0.0.10 - Set website2 to 127.0.0.20 - From website1 click on website2 in website selector - Website2 is forced on website1 session (wrong) - You land correctly on website2 and see website2 - From there (website2) click on website1 in website selector - Website1 is forced on website2 session (wrong) - You land on website1 but see website2 since website2 was forced on website1 session at steps 3/4. This is even more trickier when there is a third website without a domain in the equation (meaning this website can be seen from website1 and website2 without changing URL (hostname)).
2018-09-13[FIX] website: multi website and company switcherJeremy Kersten
Remove domain based Use domain if set That will imply that you need to reconnect on your new website too. task-1878245
2018-08-31[FIX] website: allow to switch from company from the front endJeremy Kersten
In some case, you can be on website 2 (where company_id = 2) with your user into the company 1. In this case, you will not see the product on ecommerce from company 2 while you stay in company 1.
2018-08-24[FIX] website: move `main_object_request` event in website_rootRomain Derie
`main_object_request` was added in the navbar widget. It would not work with `PageManagement` widget as it is added in the website_root widget and not the navbar. Moving it to the website_root will make the event accessible when triggering up the event.
2018-08-13[FIX] website: improve/fix menu, copy on unlink, clone page, unique_path, ↵Jeremy Kersten
sale_report, ... Fix bug from the initial poc of JOV Fix menu creation - creating a menu would create a 'container' menu in the DB (.create is call without website_id) then writing on it would copy (if condition to cow) the menu with a website_id leaving the first one as a menu container unused. - website_menu should always have a website_id we dont want to support the multiwebsite system that allow to have generic/specific menu unlink/write is useless now since we always have a website_id Make unique_path website dependent, 2 distinct website can have a page with same name Make Sale report multiwebsite compliant Make website_id on sale_order / account.invoice as a related stored from partner_id. Co-authored-by: Derie Romain <rde@odoo.com> Co-authored-by: Kersten Jérémy <jke@odoo.com>
2018-08-13[REF] website: small diff pep, renaming, make generic functionJeremy Kersten
This commit should not change the behaviour in most cases. Co-authored-by: Derie Romain <rde@odoo.com> Co-authored-by: Kersten Jérémy <jke@odoo.com>
2018-08-13[IMP] website,*: support multiple websitesJoren Van Onder
This implements support to administer multiple websites. Although the core functionality already existed, managing multiple websites was fairly technical. In the interest of database updates and migration this attempts to keep duplicated data to a minimum. To do this the usual generic records are rendered unless some website-specific record exists that replaces it. Copy-on-write (COW) is used to create these website-specific records. Through this mechanism creating a website-specific record is delayed until necessary. A COW mechanism has been implemented on 4 models: ir.ui.view, website.page, website.menu and ir.attachment. These COW mechanisms are activated when editing data through the website (aka frontend). These frontend edits (e.g. with web_editor) will be website-specific, possibly creating a website-specific record when necessary. When editing data in the backend nothing special will happen, even when editing a generic record. Note that because of this mechanism also facilitates the ability to create new, uncustomized websites because the generic data is kept. Support is provided for a website to have any theme. Themes are fairly complex to handle. Standalone themes can depend on other standalone themes (e.g. theme_beauty depends on theme_loftspace) and themes usually modify some data of the themes they depend on. Because a theme can be installed on multiple websites, using website_id m2o fields does not work well. It would require duplicate data, making updates and migration harder. Because of this, data for themes (ir.ui.view and ir.attachment specifically) have a theme_id m2o. website has a theme_ids m2m that identifies all theme modules currently installed on it. Through these fields we figure out what to render. A theme is only fully uninstalled when it's no longer active on any website. The advantage of this approach is that upgrading or migrating theme data is no different from the single-website case. The website.published.mixin class was modified to handle multiple websites. A wizard was added in the backend to easily manage this for multiple website. Although not used anywhere in this commit, a 'website_id' variable has been added in the evaluation context of ir.rule. It allows to easily make any model multi-website aware, all that's needed is a custom website_id m2o field on a model and a custom record rule.
2018-08-13[REF] web_editor, website: improve animations' restartqsm-odoo
- Before this commit, when we asked to (re)start animations on an element, we checked the animations to be started on the element and started them after destroying the animations with the same name which were already running on that element. This is in fact not correct. Indeed, if an animation was running on element but that the conditions that made the animation start are now gone, asking to restart the animations on that element should destroy the deprecated ones. (e.g. an animation "A" is to be started on all elements which have a class "a", if we remove the class "a" on an element then restart animations, the animation "A" should be destroy). The implementation is in fact even simpler: when asking a restart, a full stop is performed then a simple start. Note: this does not need to be a fix as multiple animations on a same element was recently introduced and the described case never occurs with current features. - When stopping the animations on an element, stops the animations of all its descendants too. - Add an helper method in the `SnippetOption` class to restart the animations running on the `$target` element.
2018-04-06[MERGE] forward port branch 11.0 up to d277adf4d59Christophe Simonis
2018-03-29[FIX] website: remove ribbon on unpublished pages (new specs)Romain Derie
This commit reverts part of f5912cb since the spec changed afterwards. Unpublished page will have a red toggle, which even if it is small should be enough to draw user attention, and not a ribbon anymore. Task-44005
2018-03-22[MERGE] forward port branch 11.0 up to 39d9c362c5bChristophe Simonis
2018-03-22[IMP] website: make it more noticeable when a page is unpublishedRomain Derie
Before this commit, 2 usability issues were reported: 1. Some people would get stuck with unpublished content without even knowing it since they would not understand the page is unpublished. 2. People would have a hard time finding the publish button (small toggle on the navbar). Now: 1. We now display a red ribbon on the top right corner specifying the page is unpublished. Hopefully it can't be missed. 2. This publish button will be more visible for unpublished content since it will be red (danger) color. Hopefully people will notice it at first look. Note: It is implemented in a generic way so any 'o_switch' can be turned into this version by simply adding the 'o_switch_danger' class to it. task-44005 Closes #23282
2018-02-12[FIX] web{_site,_editor}: transparent root instance 'root widget'Alexandre Kühn
With this commit, any component that needs an instance of the root widget can simply require the module 'root.widget'. Based on the context (backend, frontend, iframe), the real root.widget will resolve to either the webclient, the website root instance, or the iframe root instance. This is desirable in order for the tour_manager to become a child of the root widget, as tours are enabled in any of the above contexts. This commit is a requirement in order to solve an issue with JS services, in which there should be only one service provider at any given time.
2018-01-17[FIX] web_editor, website: properly clean snippets before savingqsm-odoo
/!\ Partial backport of https://github.com/odoo/odoo/commit/0a31cb9b4ae461119ecafdd05c5b979621ffb039 /!\ Should not be forward-ported Before the websitepocalypse introduced in 11.0 (saas-17), when saving a page in the editor, every `cleanForSave` method of snippet options were called, even for snippet options which were not initialized (so if a snippet was left unchanged before saving, the related `cleanForSave` methods were called anyway). This behavior was bad code and did not make much sense and was so removed with the websitepocalypse (see https://github.com/odoo/odoo/commit/2972976962617d4b8a0113bae58c640ab41cdff8#diff-4c580abda3220e45c6b3f6bdcf77c733L415) Unfortunatly, the behavior was necessary given the states of our snippet options. Indeed, for the "latest posts" snippet, the `cleanForSave` method removes the entire snippet content (as it is dynamically loaded). The dynamic loading is performed by the snippet *animation*... and removing the dynamic content should logically be done by the animation too... which is the case. The problem is that animations are not stopped before the editor is saved. This behavior was only implemented in saas-11.1 (for future version 12.0) with commit https://github.com/odoo/odoo/commit/0a31cb9b4ae461119ecafdd05c5b979621ffb039 As a stable fix for 11.0, part of the mentioned commit is backported here and some specific `cleanForSave` will be reviewed as animations if necessary. Note: `cleanForSave` made useless by this commit are left anyway as this is a stable fix. See https://github.com/odoo/odoo/issues/22089
2017-12-01[MERGE] forward port branch 11.0 up to c201cf2b77cChristophe Simonis
2017-11-29[FIX] website: properly start all dropped snippets' animationsqsm-odoo
When a snippet is dropped into a page, all its animations are started. The problem was that all its children's animations have to be started and that was not the case anymore since recent big website refactoring. Fortunately, this allows to improve and optimize animations start function: now all animations are (re)started for a portion of a given DOM (default to #wrapwrap) while it was only possible to restart animation of a given DOM *element* before.
2017-11-09[IMP] website, *: improve 'animation' APIqsm-odoo
* web_editor, website_twitter - There can now be multiple animation widget on the same element - Animation are destroyed before saving the editor (allows to not be forced to do that destruction / code duplication in many cleanForSave) - .data('snippet-view') is definitely dead
2017-10-18[FIX] website: new class to disable button after first clickrde
Before this commit, if you had a simple link (just a href, not handled in JS), you couldn't simply make it clickable only once. This could be a problem in some cases. (eg: a btn creating a record, it would create as many record as many times you clicked on it) The same behavior could occur for link/button redirecting to a route creating a record. There is a window of time between the click on the btn and the moment the page is getting redirected. You have time to click multiple time on it and it would call the URL multiple time. Now, there is a class 'js_disable_on_click' that will be handled in website_root.js and will disabled the button after the first click. The fix was originally aimed to fix multiple click on "Create Page" btn on 404
2017-10-10[FIX] website: allow starting website 'animations' on #wrapwrapqsm-odoo
Before 11.0, website 'animations' were able to be started on any DOM element. Since 11.0, this was reduced to any DOM element inside the main website element (#wrapwrap). This commit allows this element to be attached a website 'animation' too.
2017-09-15[ADD] website: add new page managementrde
website.page = old ir.ui.view with page=True website.redirect is a new mechanism to replace in the futur the ir.attachment mechanism of redirect. From now, we don't have a specific /page controller to serve 'page'. We use a new model website.page which is rendered if none route matches the url and that the field 'url' on website.page matches the request.httprequest.path. The order to serve a path is: - Routes defines in controllers (/shop, /blog, ...) - ir.attachment with name matching the path - website.page with url matching the path - website.redirect with url_from matching the path - 404 To improve: - allow regexp in website.redirect model - allow to edit the view_arch from the page.management via redirect backend (needed when traceback in the page, or when modifying a js/css/less/...)
2017-08-16[REF] web_editor, website, *: complete refactoringqsm-odoo
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour, website_blog, website_crm_partner_assign, website_event, website_event_questions, website_form, website_forum, website_gengo, website_hr_recruitment, website_links, website_mail, website_mail_channel, website_mass_mailing, website_quote, website_sale, website_sale_options, website_slides, website_twitter This commit reviews the whole "JS side" of the web_editor and website apps. This is a first step to be able to improve them with new and better functionnalities; this commit is not supposed to change any visual behavior. The main goal was to achieve a structure similar to the backend one. Now, the frontend side also has a root widget (like the WebClient) and all other widgets are attached to it one way or another. This allows the benefits of using the 'trigger_up' functionnality for example. As RPC are now mainly done with the `this._rpc` functionnality (being possible thanks to the parent hierarchy), the frontend will also be possible to test thanks to QUnit in a future update (besides the "text" editor side which still requires a refactoring to be able to do that). --- Here are some of the changes: (-) conventions and documentation The code has been updated to follow JS conventions and a lot of code has been commented (around +2000 lines of comment). This also means that lots of functions have been renamed to use camelCase or simply to make their name understandable. See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines. (-) deprecated: web_editor.base The "web_editor.base" module has been split and does not force the modules which require it to wait for DOM ready anymore. This was indeed slowing loading times, but also prevented to use some modules in some contexts (see the LESS editor use in web_studio which is the subject of another task). Now the "editor context" can be got thanks to the "web_editor.context" JS module with its "get" function. The "web_editor.base" module should probably not be used anymore (see its code and recent updates). (-) new: web.dom_ready If a JS module should wait for the DOM to be ready to be executed, a new JS module has been created: "web.dom_ready". This should always be used in a module which only want to instantiate stuff. Do not extend (or worst, include) classes after DOM ready. (-) website.website The "website.website" module has been split. "website.website" does not return anything useful anymore, it just initialize some miscellaneous stuff, without waiting for the DOM to be ready. You might want to check "website.utils", "website.content.compatibility" or `WebsiteRoot`. Also `website.form` has been deleted (use `this._rpc`), so has been `website.error`. `website.prompt` will be removed in a future update to be replaced by `Dialog.prompt`. (-) widgets are great Many classes which were not widgets are now widgets. This allows them to use the 'events', the 'xmlDependencies' and the 'this._rpc' features for example. Here are some of the main ones: - Snippet options: these were classes with a `$el` for the menu element and `$target` for the customized element. This is still the case but following standard `Widget` structure (one exception: using `this.$(...)` searches in the `$target` as before this update). - Snippet animations: instead of class instances with a `$target` element which can be `start` and `stop`, these are now standard widgets which can be `start` and `destroy`. `this.$target` is an alias to `this.$el` for ease of compatibility. - Snippet editors: instead of class instances in charge of an editor overlay, these are now widgets. Each "child" snippet editor is properly attached as a "child", which allows editors to communicate and to be properly destroyed. (-) root widgets and website navbar The frontend is different of the backend. In the backend, the page has an empty <body/> element and all the components are instantiated from parent to children (i.e. the `WebClient` is instantiated and is in charge of instantiating the `ControlPanel`, etc). The frontend cannot work like that on page loadings as they are way more frequent than in the backend and we do not want them to flicker. A frontend page is loaded as a <body/> element which already contains the website navbar and its menus and the whole content page. JS code has to be "attached" to these existing elements. This is possible thanks to the `RootWidget` instances and the specialized `WebsiteRoot`, `IframeRoot` and `WebsiteNavbar` (see code for details). (-) lazy loading No more (or at least a lot less) XML/JS has to be loaded on page loading, thanks to the use of the `Widget.xmlDependencies` feature. XML which have to be lazy loaded is loaded only on related Widget instantiation if necessary, which allows to execute a lot of JS code before the DOM is ready and to start many widgets on DOM ready (not later). A visual benefit of this is clicking on the 'edit' button as soon as it is possible: before this commit, this was sometimes not doing anything as event handlers were not binded yet. Still a possible exception: loading the session and locales. This may be asynchronous stuff which is still required before widget instantiations but this will be the subject of another task. (-) deprecated code and code location More than reviewing code and organizing it, many apparent dead code was removed. More importantly, mislocated code was put in the right app. This is the case for snippet animations which is a concept for website apps but was defined in the web_editor app, or some translation concepts which were part of website but should have been part of web_editor. --- There are probably more things to say about this commit but I will let the comments speak for those.