diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-02-07 16:41:52 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-02-26 17:09:22 +0000 |
| commit | 335a505d1f9b6a978c0fe0f6ea760a45b0d0a67f (patch) | |
| tree | 208507b876971e1b8a4f25077a16262e3a95dfcd /addons/web/static/src/js | |
| parent | 27fca749af30d7dce448f6632132422df8d8a7c1 (diff) | |
[REF] website, *: move and review the notion of edit mode
* 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
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/public/public_root.js | 10 | ||||
| -rw-r--r-- | addons/web/static/src/js/public/public_widget.js | 28 |
2 files changed, 10 insertions, 28 deletions
diff --git a/addons/web/static/src/js/public/public_root.js b/addons/web/static/src/js/public/public_root.js index eedc6cf5377..ebf9bb0937d 100644 --- a/addons/web/static/src/js/public/public_root.js +++ b/addons/web/static/src/js/public/public_root.js @@ -136,6 +136,14 @@ var PublicRoot = publicWidget.RootWidget.extend(ServiceProviderMixin, { return this._getContext(context); }, /** + * @private + * @param {Object} [options] + * @returns {Object} + */ + _getPublicWidgetsRegistry: function (options) { + return publicWidget.registry; + }, + /** * As the root instance is designed to be unique, the associated * registry has been instantiated outside of the class and is simply * returned here. @@ -176,7 +184,7 @@ var PublicRoot = publicWidget.RootWidget.extend(ServiceProviderMixin, { this._stopAnimations($from); - var defs = _.map(publicWidget.registry, function (WebsiteWidget) { + var defs = _.map(this._getPublicWidgetsRegistry(options), function (WebsiteWidget) { var selector = WebsiteWidget.prototype.selector || ''; var $target = $from.find(selector).addBack(selector); diff --git a/addons/web/static/src/js/public/public_widget.js b/addons/web/static/src/js/public/public_widget.js index 2f720c019f1..ed99c5da457 100644 --- a/addons/web/static/src/js/public/public_widget.js +++ b/addons/web/static/src/js/public/public_widget.js @@ -207,41 +207,15 @@ var PublicWidget = Widget.extend({ * @type {Object} */ events: {}, - /** - * Acts as @see Widget.events except that the events are only binded if the - * Animation instance is instanciated in edit mode. - */ - edit_events: {}, - /** - * Acts as @see Widget.events except that the events are only binded if the - * Animation instance is instanciated in readonly mode. - */ - read_events: {}, /** - * Initializes the events that will need to be binded according to the - * given mode. - * * @constructor * @param {Object} parent - * @param {Object} options - * @param {boolean} options.editableMode - true if the page is in edition mode + * @param {Object} [options] */ init: function (parent, options) { this._super.apply(this, arguments); - - // Note that the notion of editable mode is kept here for now even - // though nothing can be edited here. This allows to have a readable - // code for frontend widgets and mainly to prevent having loading - // problems an "include" could have caused. this.options = options || {}; - this.editableMode = this.options.editableMode || false; - - if (this.editableMode) { - this.events = _.extend({}, this.events || {}, this.edit_events || {}); - } else { - this.events = _.extend({}, this.events || {}, this.read_events || {}); - } }, /** * Destroys the animation and basically restores the target to the state it |
