diff options
Diffstat (limited to 'code_backend_theme/static/src/js/chrome/sidebar.js')
| -rw-r--r-- | code_backend_theme/static/src/js/chrome/sidebar.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/code_backend_theme/static/src/js/chrome/sidebar.js b/code_backend_theme/static/src/js/chrome/sidebar.js new file mode 100644 index 0000000..6506f33 --- /dev/null +++ b/code_backend_theme/static/src/js/chrome/sidebar.js @@ -0,0 +1,44 @@ +odoo.define('code_backend_theme.SideBar', function (require) { + "use strict"; + + var Widget = require('web.Widget'); + var SideBar = Widget.extend({ + events: _.extend({}, Widget.prototype.events, { + 'click .nav-link': '_onAppsMenuItemClicked', + }), + template: "code_backend_theme.Sidebar", + + init: function (parent, menuData) { + this._super.apply(this, arguments); + this._apps = _.map(menuData.children, function (appMenuData) { + return { + actionID: parseInt(appMenuData.action.split(',')[1]), + menuID: appMenuData.id, + name: appMenuData.name, + xmlID: appMenuData.xmlid, + web_icon_data: appMenuData.web_icon_data, + }; + }); + }, + + getApps: function () { + return this._apps; + }, + + _openApp: function (app) { + this.trigger_up('app_clicked', { + action_id: app.actionID, + menu_id: app.menuID, + }); + }, + + _onAppsMenuItemClicked: function (ev) { + var $target = $(ev.currentTarget); + var actionID = $target.data('action-id'); + var menuID = $target.data('menu-id'); + var app = _.findWhere(this._apps, { actionID: actionID, menuID: menuID }); + this._openApp(app); + }, + }); + return SideBar; +});
\ No newline at end of file |
