|
|
@@ -7,110 +7,49 @@ Ext.define('saas.view.main.MainController', {
|
|
|
|
|
|
alias: 'controller.main',
|
|
|
|
|
|
- onNavigationTreeItemClick: function(tree, info) {
|
|
|
- var node = info.node;
|
|
|
-
|
|
|
- if (node && node.get('viewType')) {
|
|
|
- this.setActiveTab(node.getData());
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- setActiveTab: function(nodeData) {
|
|
|
+ setActiveTab: function(dataset) {
|
|
|
var me = this,
|
|
|
- refs = me.getReferences(),
|
|
|
- mainTab = refs.mainTabPanel,
|
|
|
- // existingItem = mainTab.child(type),
|
|
|
- newView,
|
|
|
- id = 'maintab-' + nodeData.id,
|
|
|
- title = nodeData.text;
|
|
|
- existingItem = mainTab.down('[id=' + id + ']'),
|
|
|
- lastView = mainTab.getActiveTab();
|
|
|
+ refs = me.getReferences(),
|
|
|
+ mainTab = refs.mainTabPanel,
|
|
|
+ // existingItem = mainTab.child(type),
|
|
|
+ newView,
|
|
|
+ type = dataset.type,
|
|
|
+ title = dataset.text,
|
|
|
+ tabTitle = title + (type == 'form' ? '' : '查询'),
|
|
|
+ id = dataset.id,
|
|
|
+ tabId = 'maintab-' + type + '-' + id,
|
|
|
+ existingItem = mainTab.down('[id=' + tabId + ']'),
|
|
|
+ lastView = mainTab.getActiveTab();
|
|
|
|
|
|
if (!existingItem) {
|
|
|
- newView = Ext.create('saas.view.core.tab.Panel', {
|
|
|
- id: id,
|
|
|
- title: title,
|
|
|
- tabConfig: nodeData
|
|
|
+ existingItem = Ext.create('saas.view.core.tab.Panel', {
|
|
|
+ id: tabId,
|
|
|
+ title: tabTitle,
|
|
|
+ tabViewConfig: dataset
|
|
|
});
|
|
|
+ Ext.suspendLayouts();
|
|
|
+ mainTab.setActiveTab(mainTab.add(existingItem));
|
|
|
+ Ext.resumeLayouts(true);
|
|
|
+ }else {
|
|
|
+ mainTab.setActiveTab(existingItem);
|
|
|
}
|
|
|
-
|
|
|
- if (!newView || !newView.isWindow) {
|
|
|
- // !newView means we have an existing view, but if the newView isWindow
|
|
|
- // we don't add it to the card layout.
|
|
|
- if (existingItem) {
|
|
|
- // We don't have a newView, so activate the existing view.
|
|
|
- if (existingItem !== lastView) {
|
|
|
- mainTab.setActiveTab(existingItem);
|
|
|
- }
|
|
|
- newView = existingItem;
|
|
|
- }
|
|
|
- else {
|
|
|
- // newView is set (did not exist already), so add it and make it the
|
|
|
- // activeItem.
|
|
|
- Ext.suspendLayouts();
|
|
|
- mainTab.setActiveTab(mainTab.add(newView));
|
|
|
- Ext.resumeLayouts(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (newView.isFocusable(true)) {
|
|
|
- newView.focus();
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
onToggleNavigationSize: function () {
|
|
|
var me = this,
|
|
|
- refs = me.getReferences(),
|
|
|
- navigationList = refs.navigationTreeList,
|
|
|
- wrapContainer = refs.mainContainerWrap,
|
|
|
- collapsing = !navigationList.getMicro(),
|
|
|
- new_width = collapsing ? 64 : 250;
|
|
|
-
|
|
|
- if (Ext.isIE9m || !Ext.os.is.Desktop) {
|
|
|
- Ext.suspendLayouts();
|
|
|
-
|
|
|
- refs.mainLogo.setWidth(new_width);
|
|
|
-
|
|
|
- navigationList.setWidth(new_width);
|
|
|
- navigationList.setMicro(collapsing);
|
|
|
-
|
|
|
- Ext.resumeLayouts(); // do not flush the layout here...
|
|
|
-
|
|
|
- // No animation for IE9 or lower...
|
|
|
- wrapContainer.layout.animatePolicy = wrapContainer.layout.animate = null;
|
|
|
- wrapContainer.updateLayout(); // ... since this will flush them
|
|
|
- }
|
|
|
- else {
|
|
|
- if (!collapsing) {
|
|
|
- // If we are leaving micro mode (expanding), we do that first so that the
|
|
|
- // text of the items in the navlist will be revealed by the animation.
|
|
|
- navigationList.setMicro(false);
|
|
|
- }
|
|
|
- navigationList.canMeasure = false;
|
|
|
-
|
|
|
- // Start this layout first since it does not require a layout
|
|
|
- refs.mainLogo.animate({dynamic: true, to: {width: new_width}});
|
|
|
-
|
|
|
- // Directly adjust the width config and then run the main wrap container layout
|
|
|
- // as the root layout (it and its chidren). This will cause the adjusted size to
|
|
|
- // be flushed to the element and animate to that new size.
|
|
|
- navigationList.width = new_width;
|
|
|
- wrapContainer.updateLayout({isRoot: true});
|
|
|
- navigationList.el.addCls('nav-tree-animating');
|
|
|
-
|
|
|
- // We need to switch to micro mode on the navlist *after* the animation (this
|
|
|
- // allows the "sweep" to leave the item text in place until it is no longer
|
|
|
- // visible.
|
|
|
- if (collapsing) {
|
|
|
- navigationList.on({
|
|
|
- afterlayoutanimation: function () {
|
|
|
- navigationList.setMicro(true);
|
|
|
- navigationList.el.removeCls('nav-tree-animating');
|
|
|
- navigationList.canMeasure = true;
|
|
|
- },
|
|
|
- single: true
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+ 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;
|
|
|
+ }
|
|
|
});
|