summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/dropdown_menu.js
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:28 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 14:08:33 +0000
commitfbf347498f1cc7b74ef373179b7bcae201715c24 (patch)
treeb8d1eb29ec93b6c2e43dbade712e636d32fe6716 /addons/web/static/src/js/widgets/dropdown_menu.js
parent0a129284e4856b6485c48a194fd86c3ab5c736e7 (diff)
[REF] web: Control panel Owl
Refactoring of the control panel with the Owl framework. The MVC structure of the control panel has been changed to a 'component <-> model' relationship. As such: - Removed the old control panel: view/model/controller/renderer - Created a new Owl Component (ControlPanel) - Created a new class: the Model (an Owl Store did not fit here) and a newly designed ControlPanelModel extending it Refactored all inner subcomponents, including: - Pager - ActionMenus (peviously SideBar) - Filter menu > Custom filter item - Group by menu > Custom group by item > Removal of groupby_menu_mixin (and refactored graph controller in sibling commit) - Time range menu - Favorite menu > Custom favorite item > Moved the favorite menu registry to the favorite_menu file - Search bar > Removed and splitted auto-completion dropdown logic between the new SearchBar Component (descriptions) and to the new ControlPanelModel (domains). The templates (all in web/base.xml) have been adapted to the new standards. Most of the DOM structure remains unchanged with some occasional improvements (replace hiding with not rendering, removed pointless wrapper divs, etc.). Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/widgets/dropdown_menu.js')
-rw-r--r--addons/web/static/src/js/widgets/dropdown_menu.js145
1 files changed, 0 insertions, 145 deletions
diff --git a/addons/web/static/src/js/widgets/dropdown_menu.js b/addons/web/static/src/js/widgets/dropdown_menu.js
deleted file mode 100644
index d8663731c67..00000000000
--- a/addons/web/static/src/js/widgets/dropdown_menu.js
+++ /dev/null
@@ -1,145 +0,0 @@
-odoo.define('web.DropdownMenu', function (require) {
-"use strict";
-
-var core = require('web.core');
-var Widget = require('web.Widget');
-
-var QWeb = core.qweb;
-
-var _t = core._t;
-
-var DropdownMenu = Widget.extend({
- template: 'web.DropdownMenu',
-
- events: {
- 'click .o_menu_item': '_onItemClick',
- 'click .o_item_option': '_onOptionClick',
- 'click span.o_trash_button': '_onTrashButtonClick',
- 'hidden.bs.dropdown': '_onBootstrapClose',
- 'click .dropdown-item-text': '_onDropDownItemTextClick',
- },
-
- init: function (parent, items) {
- this._super(parent);
- // should be specified
- this.dropdownCategory = null;
- this.dropdownTitle = null;
- this.dropdownIcon = null;
- this.dropdownSymbol = false;
- // this parameter fixes the menu style. By default,
- // the style used is the one used in the search view
- this.dropdownStyle = {
- el: {class: 'btn-group o_dropdown', attrs: {}},
- mainButton: {
- class: 'o_dropdown_toggler_btn btn btn-secondary ' +
- 'dropdown-toggle ' +
- (this.dropdownSymbol ? 'o-no-caret' : '')
- },
- };
- this.items = items;
- this.openItems = {};
- },
- /**
- * @override
- */
- start: function () {
- this.$menu = this.$('.o_dropdown_menu');
- this.$dropdownReference = this.$('.o_dropdown_toggler_btn');
-
- if (_t.database.parameters.direction === 'rtl') {
- this.$menu.addClass('dropdown-menu-right');
- }
- return this._super.apply(this, arguments);
- },
-
- //--------------------------------------------------------------------------
- // Public
- //--------------------------------------------------------------------------
-
- /**
- * @param {Object} items
- */
- update: function (items) {
- this.items = items;
- this._renderMenuItems();
- },
-
- //--------------------------------------------------------------------------
- // Private
- //--------------------------------------------------------------------------
-
- /**
- * @private
- */
- _renderMenuItems: function () {
- var newMenuItems = QWeb.render('DropdownMenu.MenuItems', {widget: this});
- this.$el.find('.o_menu_item, .dropdown-divider[data-removable="1"]').remove();
- this.$('.o_dropdown_menu').prepend(newMenuItems);
- },
-
- //--------------------------------------------------------------------------
- // Handlers
- //--------------------------------------------------------------------------
-
- /**
- * This method is called when Bootstrap trigger a 'close' event (for example
- * when the user clicks outside the dropdown menu).
- *
- * @private
- * @param {jQueryEvent} event
- */
- _onBootstrapClose: function () {
- this.openItems = {};
- this._renderMenuItems();
- },
- /**
- * Reacts to click on bootstrap's dropdown-item-text
- * Protects against Bootstrap dropdown close from inside click
- *
- * @private
- */
- _onDropDownItemTextClick: function (ev) {
- ev.stopPropagation();
- },
- /**
- * @private
- * @param {MouseEvent} event
- */
- _onItemClick: function (event) {
- event.preventDefault();
- event.stopPropagation();
- var id = $(event.currentTarget).data('id');
- var item = this.items.find(function (item) {
- return item.id === id;
- });
- if (item.hasOptions) {
- this.openItems[id] = !this.openItems[id];
- this._renderMenuItems();
- } else {
- this.trigger_up('menu_item_clicked', {id: id});
- }
- },
- /**
- * @private
- * @param {MouseEvent} event
- */
- _onOptionClick: function (event) {
- event.preventDefault();
- event.stopPropagation();
- var optionId = $(event.currentTarget).data('option_id');
- var id = $(event.currentTarget).data('item_id');
- this.trigger_up('item_option_clicked', {id: id, optionId: optionId});
- },
- /**
- * @private
- * @param {MouseEvent} event
- *
- * To implement in child
- */
- _onTrashButtonClick: function (event) {
- },
-});
-
-return DropdownMenu;
-
-}); \ No newline at end of file