Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/init.ts
luoyifan 3 lat temu
rodzic
commit
0de04c7e75

+ 2 - 0
src/Defaults.ts

@@ -68,6 +68,8 @@ export const tbseparator = {}
 
 export const button = {}
 
+export const panel = {}
+
 export const splitter = {}
 
 export const maintab = {}

+ 3 - 3
src/controls/base.ts

@@ -1,6 +1,6 @@
 import _ from 'lodash'
 
-type DragType = 'row-container' | 'col-container' | 'col-item' | 'row-item'
+type DragType = 'rows-container' | 'cols-container' | 'col-item' | 'row-item'
 
 /**
  * 构建所有组件的公共属性
@@ -17,7 +17,7 @@ export function baseConfig(config, dragType?: DragType) {
 
         let cc = ''
         switch (dragType) {
-            case "col-container":
+            case "cols-container":
                 cc = 'design_cols_container'
                 break
 
@@ -25,7 +25,7 @@ export function baseConfig(config, dragType?: DragType) {
                 cc = 'design_col_item'
                 break
 
-            case "row-container":
+            case "rows-container":
                 cc = 'design_rows_container'
                 break
 

+ 1 - 1
src/controls/cols.js

@@ -15,7 +15,7 @@ export default function () {
                 layout: 'hbox',
                 minHeight: config.designMode ? 32 : 0
 
-            }, baseConfig(config, 'col-container'), config, cols)
+            }, baseConfig(config, 'cols-container'), config, cols)
 
             this.superclass.constructor.call(self, newConfig)
         },

+ 5 - 3
src/controls/grid.js

@@ -133,7 +133,7 @@ export default function () {
             //     this.store.reload({aaaa: 1, bbbb: 2})
             // }
             const {dataSource} = config
-            if (_.isPlainObject(dataSource) && dataSource.method === 'invoke') {
+            if (_.isPlainObject(dataSource) && dataSource.method === 'invoke' && !window["IS_DESIGN_MODE"]) {
                 const scope = lookupScope(me)
 
                 calcObject(scope.viewModel, dataSource.params).then(params => {
@@ -169,8 +169,10 @@ export default function () {
             const {config} = me
             const scope = lookupScope(this)
 
-            // 转换 dataSource 属性
-            convertDataSource(me, scope, config)
+            if (!window["IS_DESIGN_MODE"]) {
+                // 转换 dataSource 属性
+                convertDataSource(me, scope, config)
+            }
 
             this.on({
                 afterrender(sender) {

+ 16 - 0
src/controls/panel.js

@@ -0,0 +1,16 @@
+import _ from 'lodash'
+import {baseConfig} from "./base";
+import {panel} from "../Defaults";
+
+export default function () {
+    /**
+     *
+     */
+    const ct = Ext.panel.Panel.prototype.constructor
+    Ext.panel.Panel.override({
+        constructor: function (config) {
+            const newConfig = _.defaultsDeep({}, config, baseConfig(config, "rows-container"), panel)
+            ct.call(this, newConfig)
+        }
+    });
+}

+ 1 - 1
src/controls/rows.js

@@ -18,7 +18,7 @@ export default function () {
                     margin: '0 0 5 0',
                 },
 
-            }, baseConfig(config, 'row-container'), config, rows)
+            }, baseConfig(config, 'rows-container'), config, rows)
 
             this.superclass.constructor.call(self, newConfig)
         },

+ 1 - 1
src/controls/toolbar/toolbar.js

@@ -14,7 +14,7 @@ export default function () {
         constructor: function (config) {
             const newConfig = _.defaultsDeep({
                 // 强制性属性
-            }, baseConfig(config, 'row-item'), config, toolbar)
+            }, baseConfig(config, 'cols-container'), config, toolbar)
 
             ct.call(this, newConfig)
         }

+ 6 - 1
src/init.ts

@@ -1,5 +1,6 @@
 import _ from 'lodash'
 import initMainTab from './controls/MainTab'
+import initPanel from './controls/panel'
 import initGrid from './controls/grid'
 import initTextfield from './controls/input/textfield'
 import initToolbar from './controls/toolbar/toolbar'
@@ -64,7 +65,10 @@ export function init() {
      */
     const _doAddListener = Ext.mixin.Observable.prototype.doAddListener
     Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
-        if (typeof fn === 'string' &&
+        if (window["IS_DESIGN_MODE"]) {
+            fn = Ext.emptyFn
+
+        } else if (typeof fn === 'string' &&
             (_.startsWith(fn, 'scope.') ||
                 _.startsWith(fn, 'system.') ||
                 _.startsWith(fn, 'format.')
@@ -82,6 +86,7 @@ export function init() {
         _doAddListener.call(this, ename, fn, scope, options, order, caller, manager)
     }
 
+    initPanel()
     initGrid()
     initMainTab()
     initTextfield()

+ 3 - 0
src/lib/lib.ts

@@ -30,6 +30,9 @@ export function Lib(registe: FunctionRegiste) {
  *   'format.格式化名'
  */
 export function lookupFn(scope: Scope, event: string): Function {
+    if (window["IS_DESIGN_MODE"]) {
+        return Ext.emptyFn
+    }
     // 为 eval 准备环境
     const {system, format} = window['yvanLib']
     const func: Function = eval(event)