zhuth 6 gadi atpakaļ
vecāks
revīzija
d1f1ddf93b

+ 2 - 1
app/Application.js

@@ -9,7 +9,8 @@ Ext.define('uas.Application', {
 
     requires: [
         'uas.view.main.*',
-        'uas.controller.Global'
+        'uas.controller.Global',
+        'uas.model.Base'
     ],
 
     name: 'uas',

+ 5 - 6
app/controller/Global.js

@@ -36,8 +36,7 @@ Ext.define('uas.controller.Global', {
             store = Ext.StoreMgr.get('Navigation'),
             node = store.findNode('target', target),
             path = node.get('path');
-        className = Ext.ClassManager.getNameByAlias('widget.' + target),
-        ViewClass = Ext.ClassManager.get(className);
+        ViewClass = Ext.ClassManager.get(path);
 
         if(!!ViewClass) {
             //resume action
@@ -47,8 +46,8 @@ Ext.define('uas.controller.Global', {
                 Ext.require(path,function(){
                     resolve();
                 });
-            }).then(function(){ 
-                if(!!Ext.ClassManager.get(className)) {
+            }).then(function(){
+                if(!!Ext.ClassManager.get(path)) {
                     action.resume();
                 }else{
                     Ext.Msg.alert(
@@ -71,6 +70,7 @@ Ext.define('uas.controller.Global', {
             store = Ext.StoreMgr.get('Navigation'),
             node = store.findNode('target', target),
             title = node.get('text'),
+            path = node.get('path'),
             contentPanel = me.getContentPanel();
         
         this.getViewport().getViewModel().set('selectedNode', node);        
@@ -78,8 +78,7 @@ Ext.define('uas.controller.Global', {
 
         contentPanel.removeAll(true);
 
-        className = Ext.ClassManager.getNameByAlias('widget.' + target);
-        ViewClass = Ext.ClassManager.get(className);
+        ViewClass = Ext.ClassManager.get(path);
 
         cmp = new ViewClass();
 

+ 7 - 0
app/view/grid/basic/Panel.js

@@ -3,6 +3,13 @@ Ext.define('uas.view.grid.basic.Panel', {
     xtype: 'basic-grid',
     controller: 'basicgrid',
 
+    requires: [
+        'uas.view.grid.basic.PanelController',
+        'uas.data.Company',
+        'uas.model.Company',
+        'uas.store.Companies'
+    ],
+
     stateful: true,
     multiSelect: true,
     stateId: 'stateGrid',

+ 6 - 0
app/view/grid/expander/Panel.js

@@ -10,6 +10,12 @@ Ext.define('uas.view.grid.expander.Panel', {
 
     xtype: 'grid-expander-panel',
 
+    requires: [
+        'uas.data.Company',
+        'uas.model.Company',
+        'uas.store.Companies'
+    ],
+
     bind: '{companies}',
     viewModel: {
         stores: {

+ 7 - 2
app/view/grid/grouped/Panel.js

@@ -6,6 +6,11 @@ Ext.define('uas.view.grid.grouped.Panel', {
     xtype: 'grouped-grid',
     controller: 'grouped-grid',
 
+    requires: [
+        'uas.model.Restaurant',
+        'uas.store.Restaurants'
+    ],
+
     bind: '{restaurants}',
 
     columns: [{
@@ -32,8 +37,8 @@ Ext.define('uas.view.grid.grouped.Panel', {
         startCollapsed: true,
         groupHeaderTpl: '{columnName}: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
     }, {
-        ftype: 'infoSummary',
-        dock: 'bottom'
+        ftype: 'summary',
+        fixed: true
     }],
 
     viewModel: {

+ 7 - 0
app/view/grid/summary/Summary1.js

@@ -6,6 +6,13 @@ Ext.define('uas.view.grid.summary.Summary1', {
     extend: 'uas.view.grid.basic.Panel',
     xtype: 'summary1',
 
+    requires: [
+        'Ext.grid.feature.Summary',
+        'uas.data.Company',
+        'uas.model.Company',
+        'uas.store.Companies'
+    ],
+
     features: [{
         ftype: 'summary',
         dock: 'bottom'

+ 7 - 0
app/view/grid/summary/Summary2.js

@@ -6,6 +6,13 @@ Ext.define('uas.view.grid.summary.Summary2', {
     extend: 'uas.view.grid.basic.Panel',
     xtype: 'summary2',
 
+    requires: [
+        'Ext.grid.feature.Summary',
+        'uas.data.Company',
+        'uas.model.Company',
+        'uas.store.Companies'
+    ],
+
     features: [{
         ftype: 'summary',
         fixed: true

+ 2 - 302
overrides/grid/feature/Summary.js

@@ -1,152 +1,5 @@
-/**
- * This feature is used to place a summary row at the bottom of the grid. If using a grouping,
- * see {@link Ext.grid.feature.GroupingSummary}. There are 2 aspects to calculating the summaries,
- * calculation and rendering.
- *
- * ## Calculation
- * The summary value needs to be calculated for each column in the grid. This is controlled
- * by the summaryType option specified on the column. There are several built in summary types,
- * which can be specified as a string on the column configuration. These call underlying methods
- * on the store:
- *
- *  - {@link Ext.data.Store#count count}
- *  - {@link Ext.data.Store#sum sum}
- *  - {@link Ext.data.Store#min min}
- *  - {@link Ext.data.Store#max max}
- *  - {@link Ext.data.Store#average average}
- *
- * Alternatively, the summaryType can be a function definition. If this is the case,
- * the function is called with an array of records to calculate the summary value.
- *
- * ## Rendering
- * Similar to a column, the summary also supports a summaryRenderer function. This
- * summaryRenderer is called before displaying a value. The function is optional, if
- * not specified the default calculated value is shown. The summaryRenderer is called with:
- *
- *  - value {Object} - The calculated value.
- *  - summaryData {Object} - Contains all raw summary values for the row.
- *  - field {String} - The name of the field we are calculating
- *  - metaData {Object} - A collection of metadata about the current cell; can be used or modified by the renderer.
- *
- * ## Example Usage
- *
- *     @example
- *     Ext.define('TestResult', {
- *         extend: 'Ext.data.Model',
- *         fields: ['student', {
- *             name: 'mark',
- *             type: 'int'
- *         }]
- *     });
- *
- *     Ext.create('Ext.grid.Panel', {
- *         width: 400,
- *         height: 200,
- *         title: 'Summary Test',
- *         style: 'padding: 20px',
- *         renderTo: document.body,
- *         features: [{
- *             ftype: 'summary'
- *         }],
- *         store: {
- *             model: 'TestResult',
- *             data: [{
- *                 student: 'Student 1',
- *                 mark: 84
- *             },{
- *                 student: 'Student 2',
- *                 mark: 72
- *             },{
- *                 student: 'Student 3',
- *                 mark: 96
- *             },{
- *                 student: 'Student 4',
- *                 mark: 68
- *             }]
- *         },
- *         columns: [{
- *             dataIndex: 'student',
- *             text: 'Name',
- *             summaryType: 'count',
- *             summaryRenderer: function(value, summaryData, dataIndex) {
- *                 return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : '');
- *             }
- *         }, {
- *             dataIndex: 'mark',
- *             text: 'Mark',
- *             summaryType: 'average'
- *         }]
- *     });
- */
-Ext.define('Ext.grid.feature.Summary', {
-
-    /* Begin Definitions */
-
-    extend: 'Ext.grid.feature.AbstractSummary',
-
-    alias: 'feature.summary',
-
-    /**
-     * @cfg {String} dock 
-     * Configure `'top'` or `'bottom'` top create a fixed summary row either above or below the scrollable table.
-     *
-     */
-    dock: undefined,
-
-    summaryItemCls: Ext.baseCSSPrefix + 'grid-row-summary-item',
-    dockedSummaryCls: Ext.baseCSSPrefix + 'docked-summary',
-
-    summaryRowCls: Ext.baseCSSPrefix + 'grid-row-summary ' + Ext.baseCSSPrefix + 'grid-row-total',
-    summaryRowSelector: '.' + Ext.baseCSSPrefix + 'grid-row-summary.' + Ext.baseCSSPrefix + 'grid-row-total',
-
-    panelBodyCls: Ext.baseCSSPrefix + 'summary-',
-
-    // turn off feature events. 
-    hasFeatureEvent: false,
-
-    fullSummaryTpl: {
-        fn: function (out, values, parent) {
-            var me = this.summaryFeature,
-                record = me.summaryRecord,
-                view = values.view,
-                bufferedRenderer = view.bufferedRenderer;
-
-            this.nextTpl.applyOut(values, out, parent);
-
-            if (!me.disabled && me.showSummaryRow && !view.addingRows && view.store.isLast(values.record)) {
-                if (bufferedRenderer && !me.dock) {
-                    bufferedRenderer.variableRowHeight = true;
-                }
-                me.outputSummaryRecord((record && record.isModel) ? record : me.createSummaryRecord(view), values, out, parent);
-            }
-        },
-
-        priority: 300,
-
-        beginRowSync: function (rowSync) {
-            rowSync.add('fullSummary', this.summaryFeature.summaryRowSelector);
-        },
-
-        syncContent: function (destRow, sourceRow, columnsToUpdate) {
-            destRow = Ext.fly(destRow, 'syncDest');
-            sourceRow = Ext.fly(sourceRow, 'sycSrc');
-            var summaryFeature = this.summaryFeature,
-                selector = summaryFeature.summaryRowSelector,
-                destSummaryRow = destRow.down(selector, true),
-                sourceSummaryRow = sourceRow.down(selector, true);
-
-            // Sync just the updated columns in the summary row. 
-            if (destSummaryRow && sourceSummaryRow) {
-
-                // If we were passed a column set, only update those, otherwise do the entire row 
-                if (columnsToUpdate) {
-                    this.summaryFeature.view.updateColumns(destSummaryRow, sourceSummaryRow, columnsToUpdate);
-                } else {
-                    Ext.fly(destSummaryRow).syncContent(sourceSummaryRow);
-                }
-            }
-        }
-    },
+Ext.define('Ext.overrides.grid.feature.Summary', {
+    override: 'Ext.grid.feature.Summary',
 
     // override
     fixed: undefined,
@@ -232,153 +85,6 @@ Ext.define('Ext.grid.feature.Summary', {
         me.bindStore(grid, grid.getStore());
     },
 
-    onBeforeReconfigure: function (grid, store) {
-        this.summaryRecord = null;
-
-        if (store) {
-            this.bindStore(grid, store);
-        }
-    },
-
-    bindStore: function (grid, store) {
-        var me = this;
-
-        Ext.destroy(me.storeListeners);
-        me.storeListeners = store.on({
-            scope: me,
-            destroyable: true,
-            update: me.onStoreUpdate,
-            datachanged: me.onStoreUpdate
-        });
-
-        me.callParent([grid, store]);
-    },
-
-    renderSummaryRow: function (values, out, parent) {
-        var view = values.view,
-            me = view.findFeature('summary'),
-            record;
-
-        // If we get to here we won't be buffered 
-        if (!me.disabled && me.showSummaryRow && !view.addingRows && !view.updatingRows) {
-            record = me.summaryRecord;
-
-            out.push('<table cellpadding="0" cellspacing="0" class="' + me.summaryItemCls + '" style="table-layout: fixed; width: 100%;">');
-            me.outputSummaryRecord((record && record.isModel) ? record : me.createSummaryRecord(view), values, out, parent);
-            out.push('</table>');
-        }
-    },
-
-    toggleSummaryRow: function (visible, fromLockingPartner) {
-        var me = this,
-            bar = me.summaryBar;
-
-        me.callParent([visible, fromLockingPartner]);
-        if (bar) {
-            bar.setVisible(me.showSummaryRow);
-            me.onViewScroll();
-        }
-    },
-
-    getSummaryBar: function () {
-        return this.summaryBar;
-    },
-
-    getSummaryRowPlaceholder: function (view) {
-        var placeholderCls = this.summaryItemCls,
-            nodeContainer, row;
-
-        nodeContainer = Ext.fly(view.getNodeContainer());
-
-        if (!nodeContainer) {
-            return null;
-        }
-
-        row = nodeContainer.down('.' + placeholderCls, true);
-
-        if (!row) {
-            row = nodeContainer.createChild({
-                tag: 'table',
-                cellpadding: 0,
-                cellspacing: 0,
-                cls: placeholderCls,
-                style: 'table-layout: fixed; width: 100%',
-                children: [{
-                    tag: 'tbody' // Ensure tBodies property is present on the row 
-                }]
-            }, false, true);
-        }
-
-        return row;
-    },
-
-    vetoEvent: function (record, row, rowIndex, e) {
-        return !e.getTarget(this.summaryRowSelector);
-    },
-
-    onViewScroll: function () {
-        this.summaryBar.setScrollX(this.view.getScrollX());
-    },
-
-    onViewRefresh: function (view) {
-        var me = this,
-            record, row;
-
-        // Only add this listener if in buffered mode, if there are no rows then 
-        // we won't have anything rendered, so we need to push the row in here 
-        if (!me.disabled && me.showSummaryRow && !view.all.getCount()) {
-            record = me.createSummaryRecord(view);
-            row = me.getSummaryRowPlaceholder(view);
-            row.tBodies[0].appendChild(view.createRowElement(record, -1).querySelector(me.summaryRowSelector));
-        }
-    },
-
-    createSummaryRecord: function (view) {
-        var me = this,
-            columns = view.headerCt.getGridColumns(),
-            remoteRoot = me.remoteRoot,
-            summaryRecord = me.summaryRecord || (me.summaryRecord = new Ext.data.Model({
-                id: view.id + '-summary-record'
-            })),
-            colCount = columns.length,
-            i, column,
-            dataIndex, summaryValue;
-
-        // Set the summary field values 
-        summaryRecord.beginEdit();
-
-        if (remoteRoot) {
-            summaryValue = me.generateSummaryData();
-
-            if (summaryValue) {
-                summaryRecord.set(summaryValue);
-            }
-        } else {
-            for (i = 0; i < colCount; i++) {
-                column = columns[i];
-
-                // In summary records, if there's no dataIndex, then the value in regular rows must come from a renderer. 
-                // We set the data value in using the column ID. 
-                dataIndex = column.dataIndex || column.getItemId();
-
-                // We need to capture this value because it could get overwritten when setting on the model if there 
-                // is a convert() method on the model. 
-                summaryValue = me.getSummary(view.store, column.summaryType, dataIndex);
-                summaryRecord.set(dataIndex, summaryValue);
-
-                // Capture the columnId:value for the summaryRenderer in the summaryData object. 
-                me.setSummaryData(summaryRecord, column.getItemId(), summaryValue);
-            }
-        }
-
-        summaryRecord.endEdit(true);
-        // It's not dirty 
-        summaryRecord.commit(true);
-        summaryRecord.isSummary = true;
-
-        return summaryRecord;
-    },
-
     onStoreUpdate: function () {
         var me = this,
             view = me.view,
@@ -494,10 +200,4 @@ Ext.define('Ext.grid.feature.Summary', {
             }
         }
     },
-
-    destroy: function () {
-        var me = this;
-        me.summaryRecord = me.storeListeners = Ext.destroy(me.storeListeners);
-        me.callParent();
-    }
 });

+ 6 - 2
resources/json/navigation.json

@@ -13,6 +13,7 @@
             {
                 "text": "基本列表",
                 "target": "basic-grid",
+                "path": "uas.view.grid.basic.Panel",
                 "leaf": true,
                 "iconCls": "x-fa fa-smile-o"
             },
@@ -26,19 +27,22 @@
             {
                 "text": "合计栏",
                 "target": "grid-summary-panel",
+                "path": "uas.view.grid.summary.Panel",
                 "leaf": true,
                 "iconCls": "x-fa fa-smile-o"
             },
             {
-                "text": "分组",
+                "text": "分组",
                 "target": "grouped-grid",
+                "path": "uas.view.grid.grouped.Panel",
                 "leaf": true,
                 "iconCls": "x-fa fa-smile-o"
             },
             {
-                "text": "展开",
+                "text": "展开",
                 "leaf": true,
                 "target": "grid-expander-panel",
+                "path": "uas.view.grid.expander.Panel",
                 "iconCls": "x-fa fa-smile-o"
             },
             {