| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /**
- * This class is the controller for the main view for the application. It is specified as
- * the "controller" of the Main view class.
- */
- Ext.define('saas.view.main.MainController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.main',
- init: function() {
- this.setCompanyMenu();
- },
- setCompanyMenu: function() {
- var me = this, view = me.getView(), viewModel = me.getViewModel(),
- account = viewModel.get('account'), companies = account && account.companies,
- companyMenu = view.lookup('mainprofile').getMenu(), items = [];
- if (companies) {
- items = companies.map(function(c){
- return {
- text: c.name,
- value: c.id,
- handler: 'selectCompany',
- iconCls: c.id == account.companyId ? 'x-fa fa-check' : ''
- }
- });
- }
- companyMenu.insert(0, items);
- },
- onToggleNavigationSize: function () {
- var me = this,
- refs = me.getReferences(),
- navigationList = refs.navigationTreeList,
- navCollapsed = !navigationList.navCollapsed,
- new_width = navCollapsed ? 64 : 160,
- ope = navCollapsed ? 'addCls' : 'removeCls';
-
- refs.mainLogo.animate({dynamic: true, to: {width: new_width}});
- navigationList.body.animate({dynamic: true, to: {width: new_width}});
- navigationList.animate({dynamic: true, to: {width: new_width}});
- navigationList.el[ope]('nav-collapsed');
- navigationList.navCollapsed = navCollapsed;
- },
- selectCompany: function(item) {
- this.fireEvent('selectCompany', item.value);
- },
- onLogout: function() {
- this.fireEvent('logout');
- }
- });
|