Răsfoiți Sursa

Merge branch 'fix/form_return_resolve' into 'feature/async_form'

Fix/form return resolve

See merge request o2oa/o2oa!1833
胡起 5 ani în urmă
părinte
comite
da3e89b1d7
26 a modificat fișierele cu 2617 adăugiri și 1102 ștergeri
  1. 400 56
      o2web/source/o2_core/o2.js
  2. 90 0
      o2web/source/o2_core/o2/actionWorker.js
  3. 19 1
      o2web/source/o2_core/o2/widget/chart/Line.js
  4. 39 4
      o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js
  5. 9 3
      o2web/source/o2_core/o2/xDesktop/Common.js
  6. 48 221
      o2web/source/o2_core/o2/xScript/CMSEnvironment.js
  7. 545 173
      o2web/source/o2_core/o2/xScript/Environment.js
  8. 535 252
      o2web/source/o2_core/o2/xScript/PageEnvironment.js
  9. 47 29
      o2web/source/o2_core/o2/xScript/ViewEnvironment.js
  10. 9 8
      o2web/source/x_component_process_FormDesigner/Module/Checkbox/checkbox.html
  11. 9 13
      o2web/source/x_component_process_FormDesigner/Module/Org/org.html
  12. 9 8
      o2web/source/x_component_process_FormDesigner/Module/Radio/radio.html
  13. 38 38
      o2web/source/x_component_process_FormDesigner/Module/Select/select.html
  14. 1 2
      o2web/source/x_component_process_ProcessDesigner/$Process/flat/css.wcss
  15. 32 4
      o2web/source/x_component_process_Xform/$Input.js
  16. 30 2
      o2web/source/x_component_process_Xform/Calendar.js
  17. 89 45
      o2web/source/x_component_process_Xform/Checkbox.js
  18. 86 25
      o2web/source/x_component_process_Xform/DatagridMobile.js
  19. 67 44
      o2web/source/x_component_process_Xform/DatagridPC.js
  20. 12 0
      o2web/source/x_component_process_Xform/Documenteditor.js
  21. 13 2
      o2web/source/x_component_process_Xform/Label.js
  22. 9 1
      o2web/source/x_component_process_Xform/Number.js
  23. 215 95
      o2web/source/x_component_process_Xform/Org.js
  24. 96 44
      o2web/source/x_component_process_Xform/Radio.js
  25. 122 26
      o2web/source/x_component_process_Xform/Select.js
  26. 48 6
      o2web/source/x_component_process_Xform/Textarea.js

+ 400 - 56
o2web/source/o2_core/o2.js

@@ -207,15 +207,46 @@
     this.o2.uuid = _uuid;
 
 
-    var _runCallback = function(callback, key, par){
-        if (typeOf(callback).toLowerCase() === 'function'){
-            if (key.toLowerCase()==="success") callback.apply(callback, par);
+    var _runCallback = function(callback, key, par, bind){
+        var b = bind || callback;
+        var type = o2.typeOf(callback).toLowerCase();
+        if (!key) key = "success";
+
+        if (key.toLowerCase()==="success" && (type==="function" || type==="o2_async_function")){
+            callback.apply(b, par);
         }else{
-            if (typeOf(callback).toLowerCase()==='object'){
+            if (type==="function" || type==="object" || type==="o2_async_function"){
                 var name = ("on-"+key).camelCase();
-                if (callback[name]) callback[name].apply(callback, par);
+                if (callback[name]){
+                    callback[name].apply(b, par);
+                }else{
+                    if (callback[key]) callback[key].apply(b, par);
+                }
             }
         }
+
+
+        // if (typeOf(callback).toLowerCase() === 'function'){
+        //     if (key.toLowerCase()==="success"){
+        //         callback.apply(b, par);
+        //     }else{
+        //         if (callback[key]){
+        //             callback[key].apply(b, par);
+        //         }else{
+        //             var name = ("on-"+key).camelCase();
+        //             if (callback[name]) callback[name].apply(b, par);
+        //         }
+        //     }
+        // }else{
+        //     if (typeOf(callback).toLowerCase()==='object'){
+        //         if (callback[key]){
+        //             callback[key].apply(b, par);
+        //         }else{
+        //             var name = ("on-"+key).camelCase();
+        //             if (callback[name]) callback[name].apply(b, par);
+        //         }
+        //     }
+        // }
     };
     this.o2.runCallback = _runCallback;
 
@@ -967,11 +998,13 @@
 (function (){
     var _Class = {
         create: function(options) {
-            var newClass = function() {
-                this.initialize.apply(this, arguments);
-            };
-            _copyPrototype(newClass, options);
-            return newClass;
+            // var newClass = function() {
+            //     this.initialize.apply(this, arguments);
+            // };
+            return _copyPrototype(function() {
+                return this.initialize.apply(this, arguments) || this;
+            }, options);
+            //return newClass;
         }
     };
     var _copyPrototype = function (currentNS, props){
@@ -1260,6 +1293,71 @@
         // /jaxrs\/authentication/ig
         // /jaxrs\/statement\/.*\/execute\/page\/.*\/size\/.*/ig
     ];
+    // _restful_bak = function(method, address, data, callback, async, withCredentials, cache){
+    //     var loadAsync = (async !== false);
+    //     var credentials = (withCredentials !== false);
+    //     address = (address.indexOf("?")!==-1) ? address+"&v="+o2.version.v : address+"?v="+o2.version.v;
+    //     //var noCache = cache===false;
+    //     var noCache = !cache;
+    //
+    //
+    //     //if (Browser.name == "ie")
+    //     if (_cacheUrls.length){
+    //         for (var i=0; i<_cacheUrls.length; i++){
+    //             _cacheUrls[i].lastIndex = 0;
+    //             if (_cacheUrls[i].test(address)){
+    //                 noCache = false;
+    //                 break;
+    //             }
+    //         }
+    //     }
+    //     //var noCache = false;
+    //     var res = new Request.JSON({
+    //         url: o2.filterUrl(address),
+    //         secure: false,
+    //         method: method,
+    //         emulation: false,
+    //         noCache: noCache,
+    //         async: loadAsync,
+    //         withCredentials: credentials,
+    //         onSuccess: function(responseJSON, responseText){
+    //             // var xToken = this.getHeader("authorization");
+    //             // if (!xToken) xToken = this.getHeader("x-token");
+    //             var xToken = this.getHeader("x-token");
+    //             if (xToken){
+    //                 if (window.layout){
+    //                     if (!layout.session) layout.session = {};
+    //                     layout.session.token = xToken;
+    //                 }
+    //             }
+    //             o2.runCallback(callback, "success", [responseJSON]);
+    //         },
+    //         onFailure: function(xhr){
+    //             o2.runCallback(callback, "requestFailure", [xhr]);
+    //         }.bind(this),
+    //         onError: function(text, error){
+    //             o2.runCallback(callback, "error", [text, error]);
+    //         }.bind(this)
+    //     });
+    //
+    //     res.setHeader("Content-Type", "application/json; charset=utf-8");
+    //     res.setHeader("Accept", "text/html,application/json,*/*");
+    //     if (window.layout) {
+    //         if (layout["debugger"]){
+    //             res.setHeader("x-debugger", "true");
+    //         }
+    //         if (layout.session && layout.session.user){
+    //             if (layout.session.user.token) {
+    //                 res.setHeader("x-token", layout.session.user.token);
+    //                 res.setHeader("authorization", layout.session.user.token);
+    //             }
+    //         }
+    //     }
+    //     //Content-Type	application/x-www-form-urlencoded; charset=utf-8
+    //     res.send(data);
+    //     return res;
+    // };
+
     _restful = function(method, address, data, callback, async, withCredentials, cache){
         var loadAsync = (async !== false);
         var credentials = (withCredentials !== false);
@@ -1267,7 +1365,6 @@
         //var noCache = cache===false;
         var noCache = !cache;
 
-
         //if (Browser.name == "ie")
         if (_cacheUrls.length){
             for (var i=0; i<_cacheUrls.length; i++){
@@ -1278,51 +1375,91 @@
                 }
             }
         }
+
+        var useWebWorker = (window.layout && layout.config && layout.config.useWebWorker);
         //var noCache = false;
-        var res = new Request.JSON({
-            url: o2.filterUrl(address),
-            secure: false,
-            method: method,
-            emulation: false,
-            noCache: noCache,
-            async: loadAsync,
-            withCredentials: credentials,
-            onSuccess: function(responseJSON, responseText){
-                // var xToken = this.getHeader("authorization");
-                // if (!xToken) xToken = this.getHeader("x-token");
-                var xToken = this.getHeader("x-token");
-                if (xToken){
-                    if (window.layout){
-                        if (!layout.session) layout.session = {};
-                        layout.session.token = xToken;
+        if (!loadAsync || !useWebWorker){
+            var res = new Request.JSON({
+                url: o2.filterUrl(address),
+                secure: false,
+                method: method,
+                emulation: false,
+                noCache: noCache,
+                async: loadAsync,
+                withCredentials: credentials,
+                onSuccess: function(responseJSON, responseText){
+                    // var xToken = this.getHeader("authorization");
+                    // if (!xToken) xToken = this.getHeader("x-token");
+                    var xToken = this.getHeader("x-token");
+                    if (xToken){
+                        if (window.layout){
+                            if (!layout.session) layout.session = {};
+                            layout.session.token = xToken;
+                        }
                     }
-                }
-                o2.runCallback(callback, "success", [responseJSON]);
-            },
-            onFailure: function(xhr){
-                o2.runCallback(callback, "requestFailure", [xhr]);
-            }.bind(this),
-            onError: function(text, error){
-                o2.runCallback(callback, "error", [text, error]);
-            }.bind(this)
-        });
+                    o2.runCallback(callback, "success", [responseJSON]);
+                },
+                onFailure: function(xhr){
+                    o2.runCallback(callback, "requestFailure", [xhr]);
+                }.bind(this),
+                onError: function(text, error){
+                    o2.runCallback(callback, "error", [text, error]);
+                }.bind(this)
+            });
 
-        res.setHeader("Content-Type", "application/json; charset=utf-8");
-        res.setHeader("Accept", "text/html,application/json,*/*");
-        if (window.layout) {
-            if (layout["debugger"]){
-                res.setHeader("x-debugger", "true");
+            res.setHeader("Content-Type", "application/json; charset=utf-8");
+            res.setHeader("Accept", "text/html,application/json,*/*");
+            if (window.layout) {
+                if (layout["debugger"]){
+                    res.setHeader("x-debugger", "true");
+                }
+                if (layout.session && layout.session.user){
+                    if (layout.session.user.token) {
+                        res.setHeader("x-token", layout.session.user.token);
+                        res.setHeader("authorization", layout.session.user.token);
+                    }
+                }
             }
-            if (layout.session && layout.session.user){
-                if (layout.session.user.token) {
-                    res.setHeader("x-token", layout.session.user.token);
-                    res.setHeader("authorization", layout.session.user.token);
+            //Content-Type	application/x-www-form-urlencoded; charset=utf-8
+            res.send(data);
+            var oReturn = (callback.success && callback.success.isAG) ? callback.success : callback;
+            oReturn.res = res;
+            return oReturn;
+        }else{
+            var workerMessage = {
+                method: method,
+                noCache: noCache,
+                loadAsync: loadAsync,
+                credentials: credentials,
+                address: o2.filterUrl(address),
+                body: data,
+                debug: (window.layout && layout["debugger"]),
+                token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : ""
+            }
+            var actionWorker = new Worker("../o2_core/o2/actionWorker.js");
+            actionWorker.onmessage = function(e) {
+                result = e.data;
+                if (result.type==="done"){
+                    var xToken = result.data.xToken;
+                    if (xToken){
+                        if (window.layout){
+                            if (!layout.session) layout.session = {};
+                            layout.session.token = xToken;
+                        }
+                    }
+                    o2.runCallback(callback, "success", [result.data]);
+                }else{
+                    o2.runCallback(callback, "failure", [result.data]);
                 }
+                actionWorker.terminate();
             }
+            actionWorker.postMessage(workerMessage);
+            var oReturn = (callback.success && callback.success.addResolve) ? callback.success : callback;
+            oReturn.actionWorker = actionWorker;
+            return oReturn;
+            //return callback;
         }
-        //Content-Type	application/x-www-form-urlencoded; charset=utf-8
-        res.send(data);
-        return res;
+        //return res;
     };
 
     var _release = function(o){
@@ -1469,15 +1606,222 @@
         }
         return arr;
     }
-    Date.implement({
-        "getFromServer": function(){
-            var d;
-            o2.Actions.get("x_program_center").echo(function(json){
-                d = Date.parse(json.data.serverTime);
-            }, null, false);
+    // Date.implement({
+    //     "getFromServer": function(callback){
+    //         if (callback){
+    //             o2.Actions.get("x_program_center").echo(function(json){
+    //                 d = Date.parse(json.data.serverTime);
+    //                 callback(d);
+    //             });
+    //         }else{
+    //             var d;
+    //             o2.Actions.get("x_program_center").echo(function(json){
+    //                 d = Date.parse(json.data.serverTime);
+    //             }, null, false);
+    //             return d;
+    //         }
+    //     }
+    // });
+    Date.getFromServer = function(async){
+        var d;
+        var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
+        //var cb = function(json){
+            d = Date.parse(json.data.serverTime);
             return d;
+        }.ag().catch(function(json){ return d; });
+
+        o2.Actions.get("x_program_center").echo(cb, null, !!async);
+
+        return (!!async) ? cb : d;
+
+            // if (callback){
+            //     o2.Actions.get("x_program_center").echo(function(json){
+            //         d = Date.parse(json.data.serverTime);
+            //         o2.runCallback(callback, "success", [d]);
+            //     });
+            // }else{
+            //     var d;
+            //     o2.Actions.get("x_program_center").echo(function(json){
+            //         d = Date.parse(json.data.serverTime);
+            //     }, null, false);
+            //     return d;
+            // }
+    };
+
+    Object.appendChain = function(oChain, oProto) {
+        if (arguments.length < 2) {
+            throw new TypeError('Object.appendChain - Not enough arguments');
+        }
+        if (typeof oProto === 'number' || typeof oProto === 'boolean') {
+            throw new TypeError('second argument to Object.appendChain must be an object or a string');
+        }
+
+        var oNewProto = oProto,
+            oReturn,
+            o2nd,
+            oLast;
+
+        oReturn = o2nd = oLast = oChain instanceof this ? oChain : new oChain.constructor(oChain);
+
+        for (var o1st = this.getPrototypeOf(o2nd);
+             o1st !== Object.prototype && o1st !== Function.prototype;
+             o1st = this.getPrototypeOf(o2nd)
+        ) {
+            o2nd = o1st;
+        }
+
+        if (oProto.constructor === String) {
+            oNewProto = Function.prototype;
+            oReturn = Function.apply(null, Array.prototype.slice.call(arguments, 1));
+            oReturn = oReturn.bind(oLast);
+            this.setPrototypeOf(oReturn, oLast);
         }
+
+        this.setPrototypeOf(o2nd, oNewProto);
+        return oReturn;
+    }
+
+    var _AsyncGeneratorPrototype = _Class.create({
+        initialize: function(resolve, reject, name){
+            this.isAG = true;
+            this.name = name || "";
+            this._createSuccess();
+            this._createFailure();
+            if (resolve) this.success.resolve = resolve;
+            if (reject) this.failure.reject = reject;
+        },
+        //$family: function(){ return "o2_async_function"; },
+        _createSuccess: function(){
+            var _self = this;
+            this.success = function(){
+                var result;
+                if (_self.success.resolve) result = _self.success.resolve.apply(this, arguments);
+                if (_self.success.resolveList){
+                    _self.success.resolveList.each(function(r){
+                        result = r(result, arguments) || result;
+                    });
+                }
+                _self.isSuccess = true;
+                _self.result = result;
+                _self.arg = arguments;
+                return result;
+            }
+        },
+        _createFailure: function(){
+            var _self = this;
+            this.failure = function(){
+                var result;
+                if (_self.failure.reject) result = _self.failure.reject.apply(this, arguments);
+                if (_self.failure.rejectList){
+                    _self.failure.rejectList.each(function(r){
+                        result = r(result, arguments) || result;
+                    });
+                }
+                _self.isFailure = true;
+                _self.result = result;
+                _self.arg = arguments;
+                return result;
+            }
+        },
+        setResolve: function(resolve){
+            if (!this.success) this._createSuccess();
+            this.success.resolve = resolve;
+            return this;
+        },
+        setReject: function(reject){
+            if (!this.failure) this._createFailure();
+            this.failure.reject = reject;
+            return this;
+        },
+        addResolve: function(resolve){
+            if (!this.success) this._createSuccess();
+            if (resolve){
+                if (this.isSuccess){
+                    this.result = resolve(this.result, this.arg);
+                }else{
+                    if (!this.success.resolve){
+                        this.success.resolve = resolve;
+                    }else{
+                        if (!this.success.resolveList) this.success.resolveList = [];
+                        this.success.resolveList.push(resolve);
+                    }
+                }
+            }
+            return this;
+        },
+        addReject: function(reject){
+            if (!this.failure) this._createFailure();
+            if (reject){
+                if (this.isFailure){
+                    this.result = reject(this.result, this.arg);
+                }else{
+                    if (!this.failure.reject){
+                        this.failure.reject = reject;
+                    }else{
+                        if (!this.failure.rejectList) this.failure.rejectList = [];
+                        this.failure.rejectList.push(reject);
+                    }
+                }
+            }
+            return this;
+        },
+        then: function(resolve){
+            return this.addResolve(resolve);
+        },
+        "catch": function(reject){
+            return this.addReject(reject);
+        },
     });
+    var _AsyncGenerator = function(resolve, reject, name){
+        var asyncGeneratorPrototype = new _AsyncGeneratorPrototype(resolve, reject, name);
+        return Object.appendChain(asyncGeneratorPrototype, "if (this.success) this.success.apply(this, arguments);");
+    }
+
+    //@todo
+    _AsyncGenerator.all = function(arr){
+        var result = [];
+        var ag = function (){
+            return result;
+        }.ag();
+
+        if (o2.typeOf(arr) !== "array") arr = [arr];
+
+        var count  = arr.length;
+        var check = function(){
+            count--;
+            if (count<=0)ag();
+        }
+
+        //window.setTimeout(function(){
+            arr.forEach(function(a){
+                if (typeOf(a)=="array"){
+                    o2.AG.all(a).then(function(v){
+                        result = result.concat(v);
+                        check();
+                    });
+                }else{
+                    if (a && a.isAG){
+                        a.then(function(v){
+                            o2.AG.all(v).then(function(r){
+                                result = result.concat(r);
+                                check();
+                            });
+                        });
+                    }else{
+                        result.push(a);
+                        check();
+                    }
+                }
+            });
+        //}, 0);
+        return ag;
+    }
+
+    o2.AsyncGenerator = o2.AG = _AsyncGenerator;
+
+    Function.prototype.ag = function(){
+        return o2.AG(this);
+    }
 
 })();
 o2.core = true;
@@ -1485,7 +1829,7 @@ o2.core = true;
 
 /** ***** BEGIN LICENSE BLOCK *****
  * |------------------------------------------------------------------------------|
- * | O2OA 活力办公 创意无限    o2.more.js                                            |
+ * | O2OA 活力办公 创意无限    o2.more.js                                          |
  * |------------------------------------------------------------------------------|
  * | Distributed under the AGPL license:                                          |
  * |------------------------------------------------------------------------------|

+ 90 - 0
o2web/source/o2_core/o2/actionWorker.js

@@ -0,0 +1,90 @@
+function V(httpRequest) {
+    if (httpRequest.readyState === XMLHttpRequest.DONE) {
+        if (httpRequest.status === 200) {
+            alert(httpRequest.responseText);
+        } else {
+            alert('There was a problem with the request.');
+        }
+    }
+}
+
+(function(){
+    var _worker = this;
+    var _action = {
+        _checkRequest: function(){
+            if (this.request.readyState === XMLHttpRequest.DONE) {
+                if (this.request.status === 200) {
+                    this._doneRequest();
+                } else {
+                    this._errorRequest();
+                }
+            }
+        },
+        _createRequest: function(){
+            this.request = new XMLHttpRequest();
+            this.request.addEventListener("readystatechange", this._checkRequest.bind(this));
+        },
+        sendRequest: function(data){
+            if (!this.request) this._createRequest();
+            var method = data.method;
+            var noCache = !!data.noCache;
+            var async = !!data.loadAsync;
+            var withCredentials = !!data.credentials;
+            var url = data.address;
+            var body = data.body;
+            var debug = data.debug;
+            var token = data.token;
+
+            if (noCache) url = url+(((url.indexOf("?")!==-1) ? "&" : "?")+(new Date()).getTime());
+
+            this.request.open(method, url, async);
+
+            this.request.withCredentials = withCredentials;
+            this.request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
+            this.request.setRequestHeader("Accept", "text/html,application/json,*/*");
+            if (debug) this.request.setRequestHeader("x-debugger", "true");
+            if (token){
+                this.request.setRequestHeader("x-token", token);
+                this.request.setRequestHeader("authorization", token);
+            }
+
+            this.request.send(body);
+        },
+
+        _doneRequest: function(){
+            var json = JSON.parse(this.request.responseText);
+            var xToken = this.request.getResponseHeader("x-token");
+            if (xToken){
+                json.xToken = xToken;
+            }
+            _worker.postMessage({"type": "done", "data": json});
+            _worker.close();
+        },
+        _errorRequest: function(){
+            _worker.postMessage({"type":"error", "data": {"status":  this.request.status, "statusText":  this.request.statusText, "responseText":this.request.responseText}});
+            _worker.close();
+        }
+    };
+
+    this.action = _action;
+})();
+
+onmessage = function(e) {
+    debugger;
+    this.action.sendRequest(e.data);
+    //
+    //
+    // console.log('Worker: Message received from main script');
+    // var options = e.data;
+    //
+    // httpRequest = new XMLHttpRequest();
+    //
+    //
+    // if (isNaN(result)) {
+    //     postMessage('Please write two numbers');
+    // } else {
+    //     const workerResult = 'Result: ' + result;
+    //     console.log('Worker: Posting message back to main script');
+    //     postMessage(workerResult);
+    // }
+}

+ 19 - 1
o2web/source/o2_core/o2/widget/chart/Line.js

@@ -57,6 +57,24 @@ o2.widget.chart.Line = new Class({
         }.bind(this));
         //this.transition();
     },
+    loadScales: function(){
+        this.xScale = d3.scaleBand().domain(this.data.map(function(d){ return d[this.item];}.bind(this)))
+            .rangeRound(this.getXScaleRange()).paddingOuter(0.3).paddingInner(0.3);
+
+        this.barsData = [];
+        this.bars.each(function(bar, i){
+            this.barsData.push(
+                this.data.map(function(d, idx) {
+                    return {"name": d[this.item], "data": ((typeOf(bar.data)==="function") ? bar.data(d, i) : d[bar.data]), "text": ((typeOf(bar.text)==="function") ? bar.text(d, i) : d[bar.text])}
+                }.bind(this))
+            );
+        }.bind(this));
+        var max = d3.max(this.barsData, function(d){ return d3.max(d, function(d){return d.data}); });
+        var min = d3.min(this.barsData, function(d){ return d3.min(d, function(d){return d.data}); });
+
+        this.yScale = d3.scaleLinear().domain([min*0.9, max*1.1])
+            .range(this.getYScaleRange());
+    },
     setEvents: function(){
         var rects = this.group.selectAll("circle");
         var texts = this.group.selectAll("text");
@@ -129,4 +147,4 @@ o2.widget.chart.Line = new Class({
             // .attr("y", function(d) { return this.yScale(d.data); }.bind(this));
             .attr("d", function(d) { return lines(d) }.bind(this));
     }
-});
+});

+ 39 - 4
o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js

@@ -91,6 +91,34 @@ MWF.xDesktop.Actions.RestActions = new Class({
 
             var async = (option.async===false) ? false : true;
 
+            if (!option.success) option.success = function(v){return v;}.ag();
+            if (option.success && !option.success.isAG) option.success = option.success.ag();
+
+            console.log(option.success)
+
+            if (option.failure && option.failure.failure) option.failure = option.failure.failure;
+            if (option.failure) {
+                option.success.catch(option.failure);
+                option.failure.owner = option.success;
+            }
+            if (!option.failure && option.success && option.success.failure){
+                option.failure = option.success.failure;
+                option.failure.owner = option.success;
+            }
+
+            // if (option.failure && option.failure.failure) option.failure = option.failure.failure;
+            // if (!option.failure && option.success && option.success.failure){
+            //     option.failure = option.success.failure;
+            //     option.failure.owner = option.success;
+            // }
+            // if (!option.success){
+            //     option.success = function(v){return v;}.ag();
+            //     if (option.failure) {
+            //         option.success.catch(option.failure);
+            //         option.failure.owner = option.success;
+            //     }
+            // }
+
             var callback = new MWF.xDesktop.Actions.RestActions.Callback(option.success, option.failure);
             if (action.enctype && (action.enctype.toLowerCase()=="formdata")){
                 res = this.invokeFormData(method, uri, option.data, option.file, callback, async, progress);
@@ -553,16 +581,16 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({
 			switch(responseJSON.type) {
 			   case "success":
 				   if (this.appendSuccess) this.appendSuccess(responseJSON);
-				   if (this.success) this.success(responseJSON, responseText);
+				   if (this.success) return this.success(responseJSON, responseText);
 			       break;
 			   case "warn":
 				   MWF.xDesktop.notice("info", {x: "right", y:"top"}, responseJSON.errorMessage.join("\n"));
 				   
 				   if (this.appendSuccess) this.appendSuccess(responseJSON);
-				   if (this.success) this.success(responseJSON);
+				   if (this.success) return this.success(responseJSON);
 			       break;
 			   case "error":
-				   this.doError(null, responseText, responseJSON.message);
+				   return this.doError(null, responseText, responseJSON.message);
 				   break;
 			}
 		}else{
@@ -580,7 +608,14 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({
 	},
 	doError: function(xhr, text, error){
 		if (this.appendFailure) this.appendFailure(xhr, text, error);
-		if (this.failure) this.failure(xhr, text, error);
+		if (this.failure && this.failure.owner){
+            if (this.failure.reject || (this.failure.rejectList && this.failure.rejectList.length)){
+                return this.failure(xhr, text, error);
+            }
+            this.failure = null;
+        }else{
+            if (this.failure) return this.failure(xhr, text, error);
+        }
 		if (!this.failure && !this.appendFailure){
             if (xhr.status!=0){
                 var errorText = error;

+ 9 - 3
o2web/source/o2_core/o2/xDesktop/Common.js

@@ -492,14 +492,18 @@ MWF.xDesktop.getServiceAddressConfigArray = function(config, callback, error) {
     config.center.each(function(center){
         requests.push(
             MWF.xDesktop.getServiceAddressConfigObject(center, function(serviceAddressList, center){
+                debugger;
                 requests.each(function(res){
-                    if (res) if (res.isRunning()){res.cancel();}
+                    if (res && res.res) if (res.res.isRunning()){res.res.cancel();}
+                    if (res && res.actionWorker) res.actionWorker.terminate();
                 });
                 if (callback) callback(serviceAddressList, center);
             }.bind(this), function(){
+                debugger;
                 if (requests.length){
                     for (var i=0; i<requests.length; i++){
-                        if (requests[i].isRunning()) return "";
+                        if (requests[i].res) if (requests[i].res.isRunning()) return "";
+                        if (requests[i].actionWorker && requests[i].actionWorker.terminate) return "";
                     }
                 }
                 if (error) error();
@@ -610,7 +614,9 @@ MWF.org = {
                 "name": data.name,
                 "distinguishedName": data.distinguishedName,
                 "unitLevelName" : data.unitLevelName,
-                "person": data.person
+                "person": data.person,
+                "unit": data.unit,
+                "unitName": data.unitName,
             };
             if( data.ignoreEmpower )rData.ignoreEmpower = true;
             if( data.ignoredEmpower )rData.ignoredEmpower = true;

+ 48 - 221
o2web/source/o2_core/o2/xScript/CMSEnvironment.js

@@ -1734,7 +1734,7 @@ MWF.xScript.createCMSDict = function(application){
             options = { name : options };
         }
         var name = this.name = options.name;
-        var type = ( options.type && options.application ) ?  options.type : "cms";
+        var type = ( options.type && options.application ) ?  options.type : "process";
         var applicationId = options.application || application;
         var enableAnonymous = options.enableAnonymous || false;
 
@@ -1769,258 +1769,85 @@ MWF.xScript.createCMSDict = function(application){
             if (!refresh ){
                 var data = MWF.xScript.getDictFromCache( key, path );
                 if( data ){
-                    if (success) success( data );
+                    if (success && o2.typeOf(success)=="function") success( data );
                     return data;
                 }
             }
 
-            if (path){
+            if (success===true) async=true;
+            if (failure===true) async=true;
+
+            var cb = function(json){
+                value = json.data;
+                MWF.xScript.addDictToCache(opt, path, value);
+                if (success && o2.typeOf(success)=="function") value = success(json.data);
+                return value;
+            }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
 
+            if (path){
                 var p = encodePath( path );
                 //var p = path.replace(/\./g, "/");
-                action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
-                    value = json.data;
-                    // this.dictData[path] = value;
-                    MWF.xScript.addDictToCache(opt, path, value);
-                    if (success) success(json.data);
-                }.bind(this), function(xhr, text, error){
-                    if (failure) failure(xhr, text, error);
-                }, !!async, false);
+                action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async);
             }else{
-                action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
-                    value = json.data;
-                    // this.dictData["root"] = value;
-                    MWF.xScript.addDictToCache(opt, path, value);
-                    if (success) success(json.data);
-                }.bind(this), function(xhr, text, error){
-                    if (failure) failure(xhr, text, error);
-                }, !!async);
+                action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async);
             }
-
-            return value;
+            return (!!async) ? cb : value;
+
+            // if (path){
+            //     var p = encodePath( path );
+            //     //var p = path.replace(/\./g, "/");
+            //     action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
+            //         value = json.data;
+            //         // this.dictData[path] = value;
+            //         MWF.xScript.addDictToCache(opt, path, value);
+            //         if (success) success(json.data);
+            //     }.bind(this), function(xhr, text, error){
+            //         if (failure) failure(xhr, text, error);
+            //     }, !!async);
+            // }else{
+            //     action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
+            //         value = json.data;
+            //         // this.dictData["root"] = value;
+            //         MWF.xScript.addDictToCache(opt, path, value);
+            //         if (success) success(json.data);
+            //     }.bind(this), function(xhr, text, error){
+            //         if (failure) failure(xhr, text, error);
+            //     }, !!async);
+            // }
+
+            //return value;
         };
 
         this.set = function(path, value, success, failure){
             var p = encodePath( path );
             //var p = path.replace(/\./g, "/");
-            action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
+            return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
                 MWF.xScript.setDictToCache(key, path, value);
-                if (success) success(json.data);
+                if (success) return success(json.data);
             }, function(xhr, text, error){
-                if (failure) failure(xhr, text, error);
+                if (failure) return failure(xhr, text, error);
             }, false, false);
         };
         this.add = function(path, value, success, failure){
             var p = encodePath( path );
             //var p = path.replace(/\./g, "/");
-            action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
+            return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
                 MWF.xScript.insertDictToCache(key, path, value);
-                if (success) success(json.data);
+                if (success) return success(json.data);
             }, function(xhr, text, error){
-                if (failure) failure(xhr, text, error);
+                if (failure) return failure(xhr, text, error);
             }, false, false);
         };
         this["delete"] = function(path, success, failure){
             var p = encodePath( path );
             //var p = path.replace(/\./g, "/");
-            action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
+            return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
                 MWF.xScript.deleteDictToCache(key, path);
-                if (success) success(json.data);
+                if (success) return success(json.data);
             }, function(xhr, text, error){
-                if (failure) failure(xhr, text, error);
+                if (failure) return failure(xhr, text, error);
             }, false, false);
         };
         this.destory = this["delete"];
     }
 };
-
-// var dictLoaded = {};
-// MWF.xScript.createCMSDict = function(application){
-//     //optionsOrName : {
-//     //  type : "", //默认为process, 可以为  process  cms
-//     //  application : "", //流程/CMS的名称/别名/id, 默认为当前应用
-//     //  name : "", // 数据字典名称/别名/id
-//     //  enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
-//     //}
-//     //或者name: "" // 数据字典名称/别名/id
-//     return function(optionsOrName){
-//         var options = optionsOrName;
-//         if( typeOf( options ) == "string" ){
-//             options = { name : options };
-//         }
-//         var name = this.name = options.name;
-//         var type = ( options.type && options.application ) ?  options.type : "cms";
-//         var applicationId = options.application || application;
-//         var enableAnonymous = options.enableAnonymous || false;
-//
-//         var key = name+type+applicationId+enableAnonymous
-//         if (!dictLoaded[key]) dictLoaded[key] = {};
-//         this.dictData = dictLoaded[key];
-//
-//         //MWF.require("MWF.xScript.Actions.DictActions", null, false);
-//         if( type == "cms" ){
-//             var action = MWF.Actions.get("x_cms_assemble_control");
-//         }else{
-//             var action = MWF.Actions.get("x_processplatform_assemble_surface");
-//         }
-//
-//         var encodePath = function( path ){
-//             var arr = path.split(/\./g);
-//             var ar = arr.map(function(v){
-//                 return encodeURIComponent(v);
-//             });
-//             return ar.join("/");
-//         };
-//
-//         this.get = function(path, success, failure, async, refresh){
-//             var value = null;
-//             if (path){
-//                 if ( !refresh && this.dictData[path] ){
-//                     if (success) success(this.dictData[path]);
-//                     return this.dictData[path];
-//                 }
-//
-//                 var p = encodePath( path );
-//                 //var p = path.replace(/\./g, "/");
-//                 action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
-//                     value = json.data;
-//                     this.dictData[path] = value;
-//                     if (success) success(json.data);
-//                 }.bind(this), function(xhr, text, error){
-//                     if (failure) failure(xhr, text, error);
-//                 }, !!async, false);
-//             }else{
-//                 if (this.dictData["root"]){
-//                     if (success) success(this.dictData["root"]);
-//                     return this.dictData["root"];
-//                 }
-//                 action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
-//                     value = json.data;
-//                     this.dictData["root"] = value;
-//                     if (success) success(json.data);
-//                 }.bind(this), function(xhr, text, error){
-//                     if (failure) failure(xhr, text, error);
-//                 }, !!async);
-//             }
-//
-//             return value;
-//         };
-//
-//         this.set = function(path, value, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this.add = function(path, value, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this["delete"] = function(path, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this.destory = this["delete"];
-//     }
-// };
-
-// MWF.xScript.createCMSDict = function(application){
-//     //optionsOrName : {
-//     //  type : "", //默认为cms, 可以为  process  cms
-//     //  application : "", //流程/CMS的名称/别名/id, 默认为当前应用
-//     //  name : "", // 数据字典名称/别名/id
-//     //  enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
-//     //}
-//     //或者name: "" // 数据字典名称/别名/id
-//     return function(optionsOrName){
-//         var options = optionsOrName;
-//         if( typeOf( options ) == "string" ){
-//             options = { name : options };
-//         }
-//         var name = this.name = options.name;
-//         var type = ( options.type && options.application ) ?  options.type : "cms";
-//         var applicationId = options.application || application;
-//         var enableAnonymous = options.enableAnonymous || false;
-//
-//         //MWF.require("MWF.xScript.Actions.DictActions", null, false);
-//         if( type == "cms" ){
-//             var action = MWF.Actions.get("x_cms_assemble_control");
-//         }else{
-//             var action = MWF.Actions.get("x_processplatform_assemble_surface");
-//         }
-//
-//         var encodePath = function( path ){
-//             var arr = path.split(/\./g);
-//             var ar = arr.map(function(v){
-//                 return encodeURIComponent(v);
-//             });
-//             return ar.join("/");
-//         };
-//
-//         this.get = function(path, success, failure){
-//             var value = null;
-//             if (path){
-//                 var p = encodePath( path );
-//                 //var p = path.replace(/\./g, "/");
-//                 action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
-//                     value = json.data;
-//                     if (success) success(json.data);
-//                 }, function(xhr, text, error){
-//                     if (failure) failure(xhr, text, error);
-//                 }, false, false);
-//             }else{
-//                 action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](encodeURIComponent(this.name), applicationId, function(json){
-//                     value = json.data;
-//                     if (success) success(json.data);
-//                 }, function(xhr, text, error){
-//                     if (failure) failure(xhr, text, error);
-//                 }, false);
-//             }
-//
-//             return value;
-//         };
-//
-//         this.set = function(path, value, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this.add = function(path, value, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this["delete"] = function(path, success, failure){
-//             var p = encodePath( path );
-//             //var p = path.replace(/\./g, "/");
-//             action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
-//                 if (success) success(json.data);
-//             }, function(xhr, text, error){
-//                 if (failure) failure(xhr, text, error);
-//             }, false, false);
-//         };
-//         this.destory = this["delete"];
-//     }
-// };
-

Fișier diff suprimat deoarece este prea mare
+ 545 - 173
o2web/source/o2_core/o2/xScript/Environment.js


Fișier diff suprimat deoarece este prea mare
+ 535 - 252
o2web/source/o2_core/o2/xScript/PageEnvironment.js


+ 47 - 29
o2web/source/o2_core/o2/xScript/ViewEnvironment.js

@@ -1339,65 +1339,83 @@ if( !MWF.xScript.createDict ){
                 if (!refresh ){
                     var data = MWF.xScript.getDictFromCache( key, path );
                     if( data ){
-                        if (success) success( data );
+                        if (success && o2.typeOf(success)=="function") success( data );
                         return data;
                     }
                 }
 
-                if (path){
+                if (success===true) async=true;
+                if (failure===true) async=true;
+
+                var cb = function(json){
+                    value = json.data;
+                    MWF.xScript.addDictToCache(opt, path, value);
+                    if (success && o2.typeOf(success)=="function") value = success(json.data);
+                    return value;
+                }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
 
+                if (path){
                     var p = encodePath( path );
                     //var p = path.replace(/\./g, "/");
-                    action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
-                        value = json.data;
-                        // this.dictData[path] = value;
-                        MWF.xScript.addDictToCache(opt, path, value);
-                        if (success) success(json.data);
-                    }.bind(this), function(xhr, text, error){
-                        if (failure) failure(xhr, text, error);
-                    }, !!async, false);
+                    action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async);
                 }else{
-                    action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
-                        value = json.data;
-                        // this.dictData["root"] = value;
-                        MWF.xScript.addDictToCache(opt, path, value);
-                        if (success) success(json.data);
-                    }.bind(this), function(xhr, text, error){
-                        if (failure) failure(xhr, text, error);
-                    }, !!async);
+                    action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async);
                 }
-
-                return value;
+                return (!!async) ? cb : value;
+
+                // if (path){
+                //     var p = encodePath( path );
+                //     //var p = path.replace(/\./g, "/");
+                //     action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
+                //         value = json.data;
+                //         // this.dictData[path] = value;
+                //         MWF.xScript.addDictToCache(opt, path, value);
+                //         if (success) success(json.data);
+                //     }.bind(this), function(xhr, text, error){
+                //         if (failure) failure(xhr, text, error);
+                //     }, !!async);
+                // }else{
+                //     action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
+                //         value = json.data;
+                //         // this.dictData["root"] = value;
+                //         MWF.xScript.addDictToCache(opt, path, value);
+                //         if (success) success(json.data);
+                //     }.bind(this), function(xhr, text, error){
+                //         if (failure) failure(xhr, text, error);
+                //     }, !!async);
+                // }
+
+                //return value;
             };
 
             this.set = function(path, value, success, failure){
                 var p = encodePath( path );
                 //var p = path.replace(/\./g, "/");
-                action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
+                return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
                     MWF.xScript.setDictToCache(key, path, value);
-                    if (success) success(json.data);
+                    if (success) return success(json.data);
                 }, function(xhr, text, error){
-                    if (failure) failure(xhr, text, error);
+                    if (failure) return failure(xhr, text, error);
                 }, false, false);
             };
             this.add = function(path, value, success, failure){
                 var p = encodePath( path );
                 //var p = path.replace(/\./g, "/");
-                action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
+                return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
                     MWF.xScript.insertDictToCache(key, path, value);
-                    if (success) success(json.data);
+                    if (success) return success(json.data);
                 }, function(xhr, text, error){
-                    if (failure) failure(xhr, text, error);
+                    if (failure) return failure(xhr, text, error);
                 }, false, false);
             };
             this["delete"] = function(path, success, failure){
                 var p = encodePath( path );
                 //var p = path.replace(/\./g, "/");
-                action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
+                return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
                     MWF.xScript.deleteDictToCache(key, path);
-                    if (success) success(json.data);
+                    if (success) return success(json.data);
                 }, function(xhr, text, error){
-                    if (failure) failure(xhr, text, error);
+                    if (failure) return failure(xhr, text, error);
                 }, false, false);
             };
             this.destory = this["delete"];

+ 9 - 8
o2web/source/x_component_process_FormDesigner/Module/Checkbox/checkbox.html

@@ -13,13 +13,6 @@
 		    <td class="editTableTitle">描述:</td>
 		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
 		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,6 +20,14 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
+		  <tr>
+		    <td class="editTableTitle">可选值:</td>
+		    <td class="editTableValue">
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+		    </td>
+		  </tr>
+
 		</table>
 		
 		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
@@ -90,4 +91,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 9 - 13
o2web/source/x_component_process_FormDesigner/Module/Org/org.html

@@ -41,6 +41,13 @@
                     <input type="radio" name="isInput" value="false" text{(!$.isInput)?'checked':''}/>否
                 </td>
             </tr>
+            <tr>
+                <td class="editTableTitle">数据保存:</td>
+                <td class="editTableValue">
+                    <input type="radio" name="storeRange" value="full" text{($.section=='full')?'checked':''}/>完整
+                    <input type="radio" name="storeRange" value="simple" text{($.section!=='full')?'checked':''}/>精简
+                </td>
+            </tr>
             <tr>
                 <td class="editTableTitle">分隔符:</td>
                 <td class="editTableValue">
@@ -448,18 +455,7 @@
             <div style="height: 24px; line-height:24px; background-color: #EEE; padding: 0px 6px; border-top: 1px solid #999">通过编写脚本排除组织、身份、个人和群组的选择范围</div>
             <div class="MWFFormulaArea" name="exclude" title="脚本 (S)"></div>
         </div>
-        <div>
-            <div style="text-align: center; height: 24px; background-color: #F1F1F1; line-height: 24px; border-bottom: 1px solid #cccccc; border-top: 1px solid #cccccc;font-weight: bold;">数据保存</div>
-            <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
-                <tr>
-                    <td class="editTableTitle">数据保存:</td>
-                    <td class="editTableValue">
-                        <input type="radio" name="storeRange" value="full" text{($.section!='simple')?'checked':''}/>完整
-                        <input type="radio" name="storeRange" value="simple" text{($.section=='simple')?'checked':''}/>精简
-                    </td>
-                </tr>
-            </table>
-        </div>
+
     </div>
     <div title="事件"  class="MWFTab">
         <div class="MWFEventsArea" name="events"></div>
@@ -499,4 +495,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 9 - 8
o2web/source/x_component_process_FormDesigner/Module/Radio/radio.html

@@ -13,13 +13,6 @@
 		    <td class="editTableTitle">描述:</td>
 		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
 		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,6 +20,14 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
+		  <tr>
+		    <td class="editTableTitle">可选值:</td>
+		    <td class="editTableValue">
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+		    </td>
+		  </tr>
+
 		</table>
 		
 		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
@@ -90,4 +91,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 38 - 38
o2web/source/x_component_process_FormDesigner/Module/Select/select.html

@@ -1,25 +1,18 @@
 <div style="background-color: #FFF; overflow: hidden">
-	<div title="基本" class="MWFTab">
-		<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
-		  <tr>
-		    <td class="editTableTitle">标识:</td>
-		    <td class="editTableValue"><input type="text" name="id" value="text{$.id}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">名称:</td>
-		    <td class="editTableValue"><input type="text" name="name" value="text{$.name}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">描述:</td>
-		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
+    <div title="基本" class="MWFTab">
+        <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+            <tr>
+                <td class="editTableTitle">标识:</td>
+                <td class="editTableValue"><input type="text" name="id" value="text{$.id}" class="editTableInput"/></td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">名称:</td>
+                <td class="editTableValue"><input type="text" name="name" value="text{$.name}" class="editTableInput"/></td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">描述:</td>
+                <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
+            </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,14 +20,21 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
-		</table>
-		
-		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
-		<div id="text{$.pid}selectEditItemScript" style="display: text{($.itemType=='script')?'block':'none'}" class="MWFScriptArea" name="itemScript" title="可选值脚本 (S)"></div>
-		
-		<div class="MWFMaplist" name="styles" title="样式"></div>
+            <tr>
+                <td class="editTableTitle">可选值:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+                    <input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+                </td>
+            </tr>
+        </table>
+
+        <div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
+        <div id="text{$.pid}selectEditItemScript" style="display: text{($.itemType=='script')?'block':'none'}" class="MWFScriptArea" name="itemScript" title="可选值脚本 (S)"></div>
+
+        <div class="MWFMaplist" name="styles" title="样式"></div>
         <div class="MWFMaplist" name="inputStyles" title="Select样式"></div>
-		<div class="MWFMaplist" name="properties" title="属性"></div>
+        <div class="MWFMaplist" name="properties" title="属性"></div>
 
         <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
             <tr>
@@ -46,12 +46,12 @@
                 </td>
             </tr>
         </table>
-		<div class="MWFScriptArea" name="defaultValue" title="默认值 (S)"></div>
+        <div class="MWFScriptArea" name="defaultValue" title="默认值 (S)"></div>
 
         <div class="MWFValidation" name="validationConfig"></div>
         <div class="MWFScriptArea" name="validation" title="校验脚本 (S)"></div>
-		
-	</div>
+
+    </div>
     <div title="区段" class="MWFTab">
         <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
             <tr>
@@ -81,13 +81,13 @@
             </div>
         </div>
     </div>
-	<div title="事件"  class="MWFTab">
-		<div class="MWFEventsArea" name="events"></div>
-	</div>
-	<div title="HTML"  class="MWFTab">
-		<div class="MWFHTMLArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
-	</div>
+    <div title="事件"  class="MWFTab">
+        <div class="MWFEventsArea" name="events"></div>
+    </div>
+    <div title="HTML"  class="MWFTab">
+        <div class="MWFHTMLArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
+    </div>
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 1 - 2
o2web/source/x_component_process_ProcessDesigner/$Process/flat/css.wcss

@@ -838,8 +838,7 @@
 		"font-size": "12px",
 		"height": "24px",
 		"line-height": "24px",
-		"border-bottom": "1px dashed #CCC",
-		"word-break":"keep-all"
+		"border-bottom": "1px dashed #CCC"
 	},
 	"editTableHeadTitle": {
         "color": "#bf6364",

+ 32 - 4
o2web/source/x_component_process_Xform/$Input.js

@@ -183,15 +183,31 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         return (this.json.defaultValue && this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
     },
 	getValue: function(){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
 		return value || "";
 	},
     _setValue: function(value){
+	    debugger;
+	    if (value && value.isAG){
+	        this.moduleValueAG = o2.AG.all(value).then(function(v){
+	            if (o2.typeOf(v)=="array") v = v[0];
+                this.__setValue(v);
+            }.bind(this));
+        }else {
+            this.__setValue(value);
+        }
+
+    },
+    __setValue: function(value){
         this._setBusinessData(value);
         if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
         if (this.readonly || this.json.isReadonly) this.node.set("text", value);
+        this.moduleValueAG = null;
+        return value;
     },
+
 	_loadValue: function(){
         this._setValue(this.getValue());
 	},
@@ -228,7 +244,7 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
     },
 	getData: function(when){
         if (this.json.compute == "save") this._setValue(this._computeValue());
-		return this.getInputData();
+        return this.getInputData();
 	},
     getInputData: function(){
         if (this.node.getFirst()){
@@ -241,15 +257,27 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         this.setData(this.getValue());
     },
 	setData: function(data){
+        if (data && data.isAG){
+            this.moduleValueAG = o2.AG.all(data).then(function(v){
+                if (o2.typeOf(v)=="array") v = v[0];
+                this.__setData(v);
+            }.bind(this));
+        }else{
+            this.__setData(data);
+        }
+	},
+    __setData: function(data){
         this._setBusinessData(data);
-		if (this.node.getFirst()){
+        if (this.node.getFirst()){
             this.node.getFirst().set("value", data);
             this.checkDescription();
             this.validationMode();
         }else{
             this.node.set("text", data);
         }
-	},
+        this.moduleValueAG = null;
+    },
+
 
     createErrorNode: function(text){
 
@@ -453,4 +481,4 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         return true;
     }
 	
-}); 
+}); 

+ 30 - 2
o2web/source/x_component_process_Xform/Calendar.js

@@ -23,11 +23,27 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
             });
         }
     },
+    _getValueAg: function(value,isDate){
+        if (value && value.isAG){
+            return value.then(function(v){
+                this._getValueAg(v, isDate);
+            }.bind(this));
+        }else{
+            var d = (!!value) ? Date.parse(value) : "";
+            if (isDate){
+                return d || null;
+            }else{
+                return (d) ? d.format(this.json.format) : "";
+            }
+        }
+    },
     getValue: function(isDate){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if( value && !isDate)return value;
-
         if (!value) value = this._computeValue();
+        if (value.isAG) return value;
+
         var d = (!!value) ? Date.parse(value) : "";
         if (isDate){
             return d || null;
@@ -35,12 +51,24 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
             //if (d) value = Date.parse(value).format(this.json.format);
             return (d) ? d.format(this.json.format) : "";
         }
+
+        return value || "";
     },
     getValueStr : function(){
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
         return value;
     },
+
+    __setValue: function(value){
+        var v = (value) ? ( Date.parse(value)).format(this.json.format) : "";
+        this._setBusinessData(value);
+        if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+        if (this.readonly || this.json.isReadonly) this.node.set("text", v);
+        this.moduleValueAG = null;
+        return value;
+    },
+
 	clickSelect: function(){
 	    debugger;
         var _self = this;
@@ -184,4 +212,4 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
         }
         return resultArr[0] + "-" + resultArr[1] + "-" + resultArr[2] + " " + resultArr[3]+":"+resultArr[4]+":"+resultArr[5];
     }
-}); 
+}); 

+ 89 - 45
o2web/source/x_component_process_Xform/Checkbox.js

@@ -93,57 +93,88 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
 		}
 		//return [];
 	},
-	
-	setOptions: function(){
-		var radioValues = this.getOptions();
-        if (!radioValues) radioValues = [];
-        if (o2.typeOf(radioValues)==="array"){
-            var flag = (new MWF.widget.UUID).toString();
-            radioValues.each(function(item){
-                var tmps = item.split("|");
-                var text = tmps[0];
-                var value = tmps[1] || text;
 
-                var radio = new Element("input", {
-                    "type": "checkbox",
-                    "name": ((this.json.properties) ? this.json.properties.name : null) || flag+this.json.id,
-                    "value": value,
-                    "showText": text,
-                    "styles": this.json.buttonStyles
-                }).inject(this.node);
-                //radio.appendText(text, "after");
+    setOptions: function(){
+        var optionItems = this.getOptions();
+        this._setOptions(optionItems);
+    },
+
+    _setOptions: function(optionItems){
+        this.moduleSelectAG = o2.AG.all(optionItems).then(function(radioValues){
+            this.moduleSelectAG = null;
+            if (!radioValues) radioValues = [];
+            if (o2.typeOf(radioValues)==="array"){
+                var flag = (new MWF.widget.UUID).toString();
+                radioValues.each(function(item){
+                    var tmps = item.split("|");
+                    var text = tmps[0];
+                    var value = tmps[1] || text;
 
-                var textNode = new Element( "span", {
-                    "text" : text,
-                    "styles" : { "cursor" : "default" }
-                }).inject(this.node);
-                textNode.addEvent("click", function( ev ){
-                    if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
-                    this.radio.checked = ! this.radio.checked;
-                    this.radio.fireEvent("change");
-                    this.radio.fireEvent("click");
-                }.bind( {radio : radio} ) );
+                    var radio = new Element("input", {
+                        "type": "checkbox",
+                        "name": ((this.json.properties) ? this.json.properties.name : null) || flag+this.json.id,
+                        "value": value,
+                        "showText": text,
+                        "styles": this.json.buttonStyles
+                    }).inject(this.node);
+                    //radio.appendText(text, "after");
 
-                radio.addEvent("click", function(){
-                    this.validationMode();
-                    if (this.validation()) this._setBusinessData(this.getInputData("change") || []);
-                }.bind(this));
+                    var textNode = new Element( "span", {
+                        "text" : text,
+                        "styles" : { "cursor" : "default" }
+                    }).inject(this.node);
+                    textNode.addEvent("click", function( ev ){
+                        if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
+                        this.radio.checked = ! this.radio.checked;
+                        this.radio.fireEvent("change");
+                        this.radio.fireEvent("click");
+                    }.bind( {radio : radio} ) );
+
+                    radio.addEvent("click", function(){
+                        this.validationMode();
+                        if (this.validation()) this._setBusinessData(this.getInputData("change") || []);
+                    }.bind(this));
 
-                Object.each(this.json.events, function(e, key){
-                    if (e.code){
-                        if (this.options.moduleEvents.indexOf(key)!=-1){
-                        }else{
-                            radio.addEvent(key, function(event){
-                                return this.form.Macro.fire(e.code, this, event);
-                            }.bind(this));
+                    Object.each(this.json.events, function(e, key){
+                        if (e.code){
+                            if (this.options.moduleEvents.indexOf(key)!=-1){
+                            }else{
+                                radio.addEvent(key, function(event){
+                                    return this.form.Macro.fire(e.code, this, event);
+                                }.bind(this));
+                            }
                         }
-                    }
-                }.bind(this));
+                    }.bind(this));
 
-            }.bind(this));
-        }
+                }.bind(this));
+            }
+        }.bind(this));
+        if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
 	},
+
     _setValue: function(value){
+        this.moduleValueAG = o2.AG.all(value).then(function(v){
+            if (this.moduleSelectAG){
+                this.moduleValueAG = this.moduleSelectAG;
+                this.moduleSelectAG.then(function(){
+                    this.moduleValueAG = null;
+                    this.__setValue(v);
+                }.bind(this));
+            }else{
+                this.moduleValueAG = null;
+                this.__setValue(v);
+            }
+            return v;
+        }.bind(this));
+
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = "";
+        }.bind(this));
+    },
+
+    __setValue: function(value){
         this._setBusinessData(value);
         var radios = this.node.getElements("input");
         for (var i=0; i<radios.length; i++){
@@ -208,7 +239,20 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
     resetData: function(){
         this.setData(this.getValue());
     },
-	setData: function(data){
+
+    setData: function(data){
+        if (data && data.isAG){
+            this.moduleValueAG = data;
+            data.addResolve(function(v){
+                this.setData(v);
+            }.bind(this));
+        }else{
+            this.__setData(data);
+            this.moduleValueAG = null;
+        }
+    },
+
+    __setData: function(data){
         this._setBusinessData(data);
 
 		var inputs = this.node.getElements("input");
@@ -319,4 +363,4 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
         return true;
     }
 	
-}); 
+}); 

+ 86 - 25
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -40,15 +40,24 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         if (this.editable!=false){
             this._loadDatagridDataModules();
             //this._addTitleActionColumn();
-            this._loadEditDatagrid();
-            //this._loadReadDatagrid();
-            this.fireEvent("postLoad");
-            this.fireEvent("load");
+            // this._loadEditDatagrid();
+            // //this._loadReadDatagrid();
+            // this.fireEvent("postLoad");
+            // this.fireEvent("load");
+            this._loadEditDatagrid(function(){
+                this.fireEvent("postLoad");
+                this.fireEvent("load");
+            }.bind(this));
         }else{
             this._loadDatagridDataModules();
-            this._loadReadDatagrid();
-            this.fireEvent("postLoad");
-            this.fireEvent("load");
+            this._loadReadDatagrid(function(){
+                this.fireEvent("postLoad");
+                this.fireEvent("load");
+            }.bind(this));
+
+            // this._loadReadDatagrid();
+            // this.fireEvent("postLoad");
+            // this.fireEvent("load");
         }
     },
     createMobileTable: function(){
@@ -90,14 +99,18 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
     },
     _getValue: function(){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = [];
         value = this._getBusinessData();
         if (!value){
             if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
-            value = {"data": value || []};
+            if (!value.isAG) if (o2.typeOf(value)=="array") value = {"data": value || []};
         }
         return value || [];
     },
+    getValue: function(){
+        return this._getValue();
+    },
 
     _getValueText: function(idx, value){
         var module = this.editModules[idx];
@@ -179,8 +192,22 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         return flag;
     },
 
-    _loadReadDatagrid: function(){
-        this.gridData = this._getValue();
+    _loadReadDatagrid: function(callback){
+        if (this.gridData && this.gridData.isAG){
+            this.moduleValueAG = this.gridData;
+            this.gridData.addResolve(function(v){
+                this.gridData = v;
+                this._loadReadDatagrid(callback);
+            }.bind(this));
+        }else{
+            if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+            this.__loadReadDatagrid(callback);
+            this.moduleValueAG = null;
+        }
+    },
+
+    __loadReadDatagrid: function(callback){
+        //this.gridData = this._getValue();
 
         var titleHeaders = this.table.getElements("th");
         var tds = this.table.getElements("td");
@@ -258,13 +285,28 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                 }.bind(this));
             }.bind(this));
         }
-
+        if (callback) callback();
         //this._loadTotal();
     },
-    _loadEditDatagrid: function(){
+
+    _loadEditDatagrid: function(callback){
+        debugger;
+        if (this.gridData && this.gridData.isAG){
+            this.moduleValueAG = this.gridData;
+            this.gridData.addResolve(function(v){
+                this.gridData = v;
+                this._loadEditDatagrid(callback);
+            }.bind(this));
+        }else{
+            if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+            this.__loadEditDatagrid(callback);
+            this.moduleValueAG = null;
+        }
+    },
+    __loadEditDatagrid: function(callback){
         //this._createHelpNode();
 
-        this.gridData = this._getValue();
+        //this.gridData = this._getValue();
 
         var titleHeaders = this.table.getElements("th");
         var tds = this.table.getElements("td");
@@ -354,6 +396,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             }
             // this._loadAddAction();
         }
+        if (callback) callback();
         //this._loadTotal();
     },
     _loadActions: function(titleDiv){
@@ -692,19 +735,18 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                 }
 
                 var cell;
+                var text = this._getValueText(idx, data.text.join(", "));
+
                 if (dataRow){
                     cell = dataRow.getElement("td");
-
                     if( module.json.type == "ImageClipper" ){
                         this._createImage( cell, module, data.text );
                     }else{
-                        var text = this._getValueText(idx, data.text.join(", "));
-                        if( module.json.type == "Textarea"){
+                        if( module && module.json.type == "Textarea" ){
                             cell.set("html", text);
                         }else{
-                            cell.set("text", data.text.join(", "));
+                            cell.set("text", text);
                         }
-
                         //cell.set("text", data.text.join(", "));
                     }
                 }else{
@@ -720,8 +762,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                     if( module.json.type == "ImageClipper" ){
                         this._createImage( cell, module, data.text );
                     }else{
-                        var text = this._getValueText(idx, data.text.join(", "));
-                        if( module.json.type == "Textarea"){
+                        if( module && module.json.type == "Textarea" ){
                             cell.set("html", text);
                         }else{
                             cell.set("text", text);
@@ -1157,13 +1198,33 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         this.setData(this._getValue());
     },
     setData: function(data){
-        // if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
-        if (data){
-            this._setBusinessData(data);
-            this.gridData = data;
+        if (!data){
+            data = this._getValue();
+        }
+        this._setData(data);
+    },
+    _setData: function(data){
+        if (data && data.isAG){
+            this.moduleValueAG = data;
+            data.addResolve(function(v){
+                this._setData(v);
+            }.bind(this));
         }else{
-            this.gridData = this._getValue();
+            if (o2.typeOf(data)=="array") data = {"data": data};
+            this.__setData(data);
+            this.moduleValueAG = null;
         }
+    },
+    __setData: function(data){
+        // if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
+        // if (data){
+        //     this._setBusinessData(data);
+        //     this.gridData = data;
+        // }else{
+        //     this.gridData = this._getValue();
+        // }
+        this._setBusinessData(data);
+        this.gridData = data;
 
         // if (this.isEdit) this._completeLineEdit();
         if( this.isEdit ){

+ 67 - 44
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -38,19 +38,20 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			this._loadDatagridDataModules();
 			this._addTitleActionColumn();
 
-			this._loadEditDatagrid();
-
-			this.fireEvent("postLoad");
-			this.fireEvent("load");
+			this._loadEditDatagrid(function(){
+				this.fireEvent("postLoad");
+				this.fireEvent("load");
+			}.bind(this));
 			//this._loadReadDatagrid();
 		}else{
 			this._loadDatagridDataModules();
 			this._getDatagridEditorTr();
-			this._loadReadDatagrid();
-			if(this.editorTr)this.editorTr.setStyle("display", "none");
+			this._loadReadDatagrid(function(){
+				if(this.editorTr)this.editorTr.setStyle("display", "none");
+				this.fireEvent("postLoad");
+				this.fireEvent("load");
+			}.bind(this));
 
-			this.fireEvent("postLoad");
-			this.fireEvent("load");
 		}
 	},
 	_loadStyles: function(){
@@ -58,14 +59,18 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		this.node.setStyles(this.json.styles);
 	},
 	_getValue: function(){
+		if (this.moduleValueAG) return this.moduleValueAG;
 		var value = [];
 		value = this._getBusinessData();
 		if (!value){
 			if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
-			value = {"data": value || []};
+			if (!value.isAG) if (o2.typeOf(value)=="array") value = {"data": value || []};
 		}
 		return value || {};
 	},
+	getValue: function(){
+		return this._getValue();
+	},
 	_getDatagridTr: function(){
 		this._getDatagridTitleTr();
 		this._getDatagridEditorTr();
@@ -109,7 +114,21 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		//}
 	},
 
-	_loadEditDatagrid: function(){
+	_loadEditDatagrid: function(callback){
+		debugger;
+		if (this.gridData && this.gridData.isAG){
+			this.moduleValueAG = this.gridData;
+			this.gridData.addResolve(function(v){
+				this.gridData = v;
+				this._loadEditDatagrid(callback);
+			}.bind(this));
+		}else{
+			if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+			this.__loadEditDatagrid(callback);
+			this.moduleValueAG = null;
+		}
+	},
+	__loadEditDatagrid: function(callback){
 		var titleThs = this.titleTr.getElements("th");
 		var editorTds = this.editorTr.getElements("td");
 
@@ -129,11 +148,11 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				}.bind(this));
 			}.bind(this));
 		}
-
-
 		this.editorTr.setStyle("display", "none");
+		if (callback) callback();
 	},
 
+
 	_getValueText: function(idx, value){
 		debugger;
 		var module = this.editModules[idx];
@@ -713,9 +732,22 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		drag.start(e);
 		tr.setStyle("display", "none");
 	},
-	_loadReadDatagrid: function(){
-		this.gridData = this._getValue();
+	_loadReadDatagrid: function(callback){
+		if (this.gridData && this.gridData.isAG){
+			this.moduleValueAG = this.gridData;
+			this.gridData.addResolve(function(v){
+				this.gridData = v;
+				this._loadReadDatagrid(callback);
+			}.bind(this));
+		}else{
+			if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+			this.__loadReadDatagrid(callback);
+			this.moduleValueAG = null;
+		}
+	},
 
+	__loadReadDatagrid: function(callback){
+		//this.gridData = this._getValue();
 		if (!this.titleTr) this._getDatagridTitleTr();
 		//var titleTr = this.table.getElement("tr");
 		var titleHeaders = this.titleTr.getElements("th");
@@ -749,23 +781,6 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 									cell.set("text", text);
 								}
 							}
-
-
-							// if (typeOf(v)==="array"){
-							// 	var textArray = [];
-							// 	v.each( function( item ){
-							// 		if (typeOf(item)==="object"){
-							// 			textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
-							// 		}else{
-							// 			textArray.push(item);
-							// 		}
-							// 	}.bind(this));
-							// 	cell.set("text", textArray.join(", "));
-							// }else if (typeOf(v)==="object"){
-							//    cell.set("text", v.name+((v.unitName) ? "("+v.unitName+")" : ""));
-							// }else{
-							//    cell.set("text", v);
-							// }
 							break;
 						}
 					}else{ //Sequence
@@ -776,14 +791,9 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				}.bind(this));
 			}.bind(this));
 		}
-
-
-		//lastTr.destroy();
-
 		this._loadTotal();
-		//   this._loadSequenceRead();
-
 
+		if (callback) callback();
 	},
 
 	_loadDatagridStyle: function(){
@@ -971,13 +981,27 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		this.setData(this._getValue());
 	},
 	setData: function(data){
-		// if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
-		if (data){
-			this._setBusinessData(data);
-			this.gridData = data;
+		if (!data){
+			data = this._getValue();
+		}
+		this._setData(data);
+	},
+	_setData: function(data){
+		if (data && data.isAG){
+			this.moduleValueAG = data;
+			data.addResolve(function(v){
+				this._setData(v);
+			}.bind(this));
 		}else{
-			this.gridData = this._getValue();
+			if (o2.typeOf(data)=="array") data = {"data": data};
+			this.__setData(data);
+			this.moduleValueAG = null;
 		}
+	},
+	__setData: function(data){
+		// if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
+		this._setBusinessData(data);
+		this.gridData = data;
 
 		// if (this.isEdit) this._completeLineEdit();
 		if( this.isEdit ){ //如果有在编辑的,取消编辑行
@@ -1020,9 +1044,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			}
 			this._loadDatagridStyle();
 		}
-
-
 	},
+
 	getTotal: function(){
 		this._loadTotal();
 		return this.totalResaults;

+ 12 - 0
o2web/source/x_component_process_Xform/Documenteditor.js

@@ -1356,6 +1356,18 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor =  new Cla
                 }
                 //e.editor.getSelection().scrollIntoView();
 
+                var text = this.data.filetext.replace(/\u3000*/g, "");
+                if (!text){
+                    var range = e.editor.createRange();
+                    range.moveToElementEditEnd(e.editor.editable());
+
+                    range.select();
+                    range.scrollIntoView();
+                }else{
+                    e.editor.getSelection().scrollIntoView();
+                }
+                // e.editor.getSelection().scrollIntoView();
+                //
                 //this.getFiletextToolber();
                 //this.filetextToolbarNode.inject(this.layout_filetext.getOffsetParent());
 

+ 13 - 2
o2web/source/x_component_process_Xform/Label.js

@@ -10,7 +10,9 @@ MWF.xApplication.process.Xform.Label = MWF.APPLabel =  new Class({
 		if (this.json.valueType == "script"){
 			var code = (this.json.script) ? this.json.script.code : "";
 			if (code){
-				this.node.set("text", this.form.Macro.exec(code, this) || "");
+			    var value = this.form.Macro.exec(code, this);
+			    this._setNodeText(value);
+				//this.node.set("text", this.form.Macro.exec(code, this) || "");
 			} 
 		}
 		if (this.json.prefixIcon || this.json.suffixIcon){
@@ -41,7 +43,16 @@ MWF.xApplication.process.Xform.Label = MWF.APPLabel =  new Class({
             }
 		}
 	},
+    _setNodeText: function(value){
+        if (value && value.isAG){
+            value.addResolve(function(v){
+                this._setNodeText(v);
+            }.bind(this));
+        }else{
+            this.node.set("text", value || "");
+        }
+    },
     setText: function(text){
         this.node.set("text", text);
     }
-});
+});

+ 9 - 1
o2web/source/x_component_process_Xform/Number.js

@@ -196,8 +196,16 @@ MWF.xApplication.process.Xform.Number = MWF.APPNumber =  new Class({
         return (this.json.defaultValue && this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "0");
     },
     getValue: function(){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
         return value || "0";
+    },
+    __setValue: function(value){
+        this._setBusinessData(value);
+        if (this.node.getFirst()) this.node.getFirst().set("value", value || "0");
+        if (this.readonly || this.json.isReadonly) this.node.set("text", value);
+        this.moduleValueAG = null;
+        return value;
     }
-});
+});

+ 215 - 95
o2web/source/x_component_process_Xform/Org.js

@@ -91,7 +91,15 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         //}
     },
 
-
+    _valueMerge: function(values, v){
+        if (o2.typeOf(v)=="function"){
+            return v.then(function(re){
+                this._valueMerge(values, re)
+            }.bind(this));
+        }else{
+            return values.concat(v);
+        }
+    },
     _computeValue: function(){
         var simple = this.json.storeRange === "simple";
         var values = [];
@@ -109,27 +117,73 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             if (dutys.length){
                 dutys.each(function(duty){
                     if (duty.code) par = this.form.Macro.exec(duty.code, this);
-                    var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\")";
-                    var d = this.form.Macro.exec(code, this);
-                    if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
-                    d.each(function(dd){if (dd) values.push(MWF.org.parseOrgData(dd, true, simple));});
+                    if (par && par.isAG){
+                        var ag = o2.AG.all(par).then(function(p){
+                            var uName = "";
+                            if (p && p.length) uName = p[0].distinguishedName || p[0];
+                            var code = "return this.org.getDuty(\""+duty.name+"\", \""+uName+"\", true)";
+                            var r = this.form.Macro.exec(code, this);
+
+                            o2.AG.all(r).then(function(d) {
+                                //var d = rd[0];
+                                if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                                var arr = [];
+                                d.each(function(dd){
+                                    if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                                });
+                                return arr;
+                            }.bind(this));
+                        }.bind(this));
+                        values.push(ag);
+                    }else{
+                        var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\", true)";
+                        var r = this.form.Macro.exec(code, this);
+                        var ag = o2.AG.all(r).then(function(d) {
+                            //var d = rd[0];
+                            if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                            var arr = [];
+                            d.each(function(dd){
+                                if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                            });
+                            return arr;
+                        }.bind(this));
+                        values.push(ag);
+
+                        // if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                        // d.each(function(dd){if (dd) values.push(MWF.org.parseOrgData(dd, true, simple));});
+                    }
+
                 }.bind(this));
             }
         }
         if (this.json.defaultValue && this.json.defaultValue.code){
             var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
-            if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
-            fd.each(function(fdd){
-                if (fdd){
-                    if (typeOf(fdd)==="string"){
-                        var data;
-                        this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
-                        values.push(data);
-                    }else{
-                        values.push(fdd);
+
+            if (fd && fd.isAG){
+                // value.addResolve(function(v){
+                //     this._setBusinessData(v);
+                //     if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+                //     if (this.readonly || this.json.isReadonly) this.node.set("text", v);
+                // }.bind(this));
+                values.push(fd);
+                // fd.then(function(v){
+                //     return this._valueMerge(values, v);
+                // }.bind(this));
+                // return fd;
+            }else{
+                if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
+                fd.each(function(fdd){
+                    if (fdd){
+                        if (typeOf(fdd)==="string"){
+                            var data;
+                            this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
+                            values.push(data);
+                        }else{
+                            values.push(fdd);
+                        }
                     }
-                }
-            }.bind(this));
+                }.bind(this));
+            }
         }
         if (this.json.count>0){
             return values.slice(0, this.json.count);
@@ -367,6 +421,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }
     },
     resetData: function(){
+        debugger;
         var v = this.getValue();
         //this.setData((v) ? v.join(", ") : "");
         this.setData(v);
@@ -715,51 +770,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             }
         }.bind(this));
     },
-    setData: function(value){
-        if (!value) return false;
-        var oldValues = this.getData();
-        var values = [];
-        var comboxValues = [];
-
-        var simple = this.json.storeRange === "simple";
-
-        var type = typeOf(value);
-        if (type==="array"){
-            value.each(function(v){
-                var vtype = typeOf(v);
-                var data = null;
-                if (vtype==="string"){
-                    var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
-                    this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
-                }
-                if (vtype==="object") {
-                    data = MWF.org.parseOrgData(v, true, simple);
-                    if(data.woPerson)delete data.woPerson;
-                }
-                if (data){
-                    values.push(data);
-                    comboxValues.push({"text": this.getDataText(data),"value": data});
-                }
-            }.bind(this));
-        }
-        if (type==="string"){
-            var vData;
-            var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
-            this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
-            if (vData){
-                values.push(vData);
-                comboxValues.push({"text": this.getDataText(vData),"value": vData});
-            }
-        }
-        if (type==="object"){
-            var vData = MWF.org.parseOrgData(value, true, simple);
-            if(vData.woPerson)delete vData.woPerson;
-            values.push( vData );
-            comboxValues.push({"text": this.getDataText(value),"value": vData});
-        }
-
+    checkChange: function(oldValues, values){
         var change = false;
-        if (oldValues.length && values.length){
+        if (!values) values = [];
+        if (oldValues.length && (values && values.length)){
             if (oldValues.length === values.length){
                 for (var i=0; i<oldValues.length; i++){
                     if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
@@ -773,46 +787,109 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }else if (values.length || oldValues.length) {
             change = true;
         }
-        this._setBusinessData(values);
         if (change) this.fireEvent("change");
+    },
+    setData: function(value){
+        if (!value) return false;
+        var oldValues = this.getData();
+        if (value.length==1 && !(value[0])) value=[];
 
-        if (this.json.isInput){
-            if (this.combox){
-                this.combox.clear();
-                this.combox.addNewValues(comboxValues);
-            }else{
-                var node = this.node.getFirst();
-                if (node){
-                    node.empty();
-                    comboxValues.each(function(v, i){
-                        this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
-                    }.bind(this));
-                }
-            }
-            //
-            // this.combox.clear();
-            // values.each(function(v){
-            //     var vtype = typeOf(v);
-            //     if (vtype==="string"){
-            //         var data;
-            //         this.getOrgAction()[this.getValueMethod(v)](function(json){ data = json.data }.bind(this), null, v, false);
-            //         if (data) this.combox.addNewValue(this.getDataText(data), data);
-            //     }
-            //     if (vtype==="object"){
-            //         this.combox.addNewValue(this.getDataText(v), v);
-            //     }
-            // }.bind(this));
-        }else{
-            if (this.node.getFirst()){
-                var node = this.node.getFirst();
-                node.empty();
-                this.loadOrgWidget(values, node)
+        var ag = this._setValue(value);
+        ag.then(function(values){
+            if (values && values.isAG){
+                values.then(function(v){
+                    this.checkChange(oldValues, v)
+                }.bind(this));
             }else{
-                this.node.empty();
-                this.loadOrgWidget(values, this.node);
+                this.checkChange(oldValues, values)
             }
-        }
+        }.bind(this));
     },
+    // __setData: function(value){
+    //     if (!value) return false;
+    //     var oldValues = this.getData();
+    //     var values = [];
+    //     var comboxValues = [];
+    //
+    //     var simple = this.json.storeRange === "simple";
+    //
+    //     var type = typeOf(value);
+    //     if (type==="array"){
+    //         value.each(function(v){
+    //             var vtype = typeOf(v);
+    //             var data = null;
+    //             if (vtype==="string"){
+    //                 var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
+    //                 this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
+    //             }
+    //             if (vtype==="object") {
+    //                 data = MWF.org.parseOrgData(v, true, simple);
+    //                 if(data.woPerson)delete data.woPerson;
+    //             }
+    //             if (data){
+    //                 values.push(data);
+    //                 comboxValues.push({"text": this.getDataText(data),"value": data});
+    //             }
+    //         }.bind(this));
+    //     }
+    //     if (type==="string"){
+    //         var vData;
+    //         var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
+    //         this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
+    //         if (vData){
+    //             values.push(vData);
+    //             comboxValues.push({"text": this.getDataText(vData),"value": vData});
+    //         }
+    //     }
+    //     if (type==="object"){
+    //         var vData = MWF.org.parseOrgData(value, true, simple);
+    //         if(vData.woPerson)delete vData.woPerson;
+    //         values.push( vData );
+    //         comboxValues.push({"text": this.getDataText(value),"value": vData});
+    //     }
+    //
+    //     var change = false;
+    //     if (oldValues.length && values.length){
+    //         if (oldValues.length === values.length){
+    //             for (var i=0; i<oldValues.length; i++){
+    //                 if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
+    //                     change = true;
+    //                     break;
+    //                 }
+    //             }
+    //         }else{
+    //             change = true;
+    //         }
+    //     }else if (values.length || oldValues.length) {
+    //         change = true;
+    //     }
+    //     this._setBusinessData(values);
+    //     if (change) this.fireEvent("change");
+    //
+    //     if (this.json.isInput){
+    //         if (this.combox){
+    //             this.combox.clear();
+    //             this.combox.addNewValues(comboxValues);
+    //         }else{
+    //             var node = this.node.getFirst();
+    //             if (node){
+    //                 node.empty();
+    //                 comboxValues.each(function(v, i){
+    //                     this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
+    //                 }.bind(this));
+    //             }
+    //         }
+    //     }else{
+    //         if (this.node.getFirst()){
+    //             var node = this.node.getFirst();
+    //             node.empty();
+    //             this.loadOrgWidget(values, node)
+    //         }else{
+    //             this.node.empty();
+    //             this.loadOrgWidget(values, this.node);
+    //         }
+    //     }
+    // },
     creteShowNode: function(data, islast){
         var nodeText = (data.text) ?  data.text : data;
         if (!islast) nodeText = nodeText + (this.json.splitShow || ", ");
@@ -858,6 +935,47 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         return node;
     },
     _setValue: function(value){
+        var values = [];
+        var ags = [];
+        var simple = this.json.storeRange === "simple";
+        var flag = false;
+        var ag = o2.AG.all(value).then(function(d) {
+            if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+
+            d.each(function(dd){
+                //if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                if (dd){
+                    if (typeOf(dd)==="string"){
+                        ags.push(this.getOrgAction()[this.getValueMethod(dd)](function(json){
+                            return MWF.org.parseOrgData(json.data, true, simple);
+                        }.bind(this).ag(), null, dd, true));
+                    }else{
+                        values.push(dd);
+                    }
+                }
+            }.bind(this));
+            if (ags.length){
+                return o2.AG.all(ags).then(function(data){
+                    values = values.concat(data);
+                    flag = true;
+                    this.__setValue(values);
+                    return values;
+                }.bind(this));
+            }else{
+                flag = true;
+                this.__setValue(values);
+                return values
+            }
+        }.bind(this));
+
+        this.moduleValueAG = ag;
+        if (ag) ag.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+        return ag;
+    },
+    __setValue: function(value){
+        this.moduleValueAG = null;
         if (value.length==1 && !(value[0])) value=[];
         var values = [];
         var comboxValues = [];
@@ -922,8 +1040,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }else{
             if (this.node.getFirst()){
                 var node = this.node.getFirst();
+                node.empty();
                 this.loadOrgWidget(values, node)
             }else{
+                this.node.empty();
                 this.loadOrgWidget(values, this.node);
             }
         }

+ 96 - 44
o2web/source/x_component_process_Xform/Radio.js

@@ -100,56 +100,86 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
 		}
 		return [];
 	},
-	
-	setOptions: function(){
-		var radioValues = this.getOptions();
-        if (!radioValues) radioValues = [];
-        if (o2.typeOf(radioValues)==="array"){
-            var flag = (new MWF.widget.UUID).toString();
-            radioValues.each(function(item){
-                var tmps = item.split("|");
-                var text = tmps[0];
-                var value = tmps[1] || text;
+    setOptions: function(){
+        var optionItems = this.getOptions();
+        this._setOptions(optionItems);
+    },
 
-                var radio = new Element("input", {
-                    "type": "radio",
-                    "name": (this.json.properties && this.json.properties.name) ? this.json.properties.name : flag+this.json.id,
-                    "value": value,
-                    "showText": text,
-                    "styles": this.json.buttonStyles
-                }).inject(this.node);
-                //radio.appendText(text, "after");
+	_setOptions: function(optionItems){
+        this.moduleSelectAG = o2.AG.all(optionItems).then(function(radioValues){
+            this.moduleSelectAG = null;
 
-                var textNode = new Element( "span", {
-                    "text" : text,
-                    "styles" : { "cursor" : "default" }
-                }).inject(this.node);
-                textNode.addEvent("click", function( ev ){
-                    if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
-                    this.radio.checked = true;
-                    this.radio.fireEvent("change");
-                    this.radio.fireEvent("click");
-                }.bind( {radio : radio} ) );
+            if (!radioValues) radioValues = [];
+            if (o2.typeOf(radioValues)==="array"){
+                var flag = (new MWF.widget.UUID).toString();
+                radioValues.each(function(item){
+                    var tmps = item.split("|");
+                    var text = tmps[0];
+                    var value = tmps[1] || text;
 
-                radio.addEvent("click", function(){
-                    this.validationMode();
-                    if (this.validation()) this._setBusinessData(this.getInputData("change"));
-                }.bind(this));
+                    var radio = new Element("input", {
+                        "type": "radio",
+                        "name": (this.json.properties && this.json.properties.name) ? this.json.properties.name : flag+this.json.id,
+                        "value": value,
+                        "showText": text,
+                        "styles": this.json.buttonStyles
+                    }).inject(this.node);
+                    //radio.appendText(text, "after");
 
-                Object.each(this.json.events, function(e, key){
-                    if (e.code){
-                        if (this.options.moduleEvents.indexOf(key)!=-1){
-                        }else{
-                            radio.addEvent(key, function(event){
-                                return this.form.Macro.fire(e.code, this, event);
-                            }.bind(this));
+                    var textNode = new Element( "span", {
+                        "text" : text,
+                        "styles" : { "cursor" : "default" }
+                    }).inject(this.node);
+                    textNode.addEvent("click", function( ev ){
+                        if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
+                        this.radio.checked = true;
+                        this.radio.fireEvent("change");
+                        this.radio.fireEvent("click");
+                    }.bind( {radio : radio} ) );
+
+                    radio.addEvent("click", function(){
+                        this.validationMode();
+                        if (this.validation()) this._setBusinessData(this.getInputData("change"));
+                    }.bind(this));
+
+                    Object.each(this.json.events, function(e, key){
+                        if (e.code){
+                            if (this.options.moduleEvents.indexOf(key)!=-1){
+                            }else{
+                                radio.addEvent(key, function(event){
+                                    return this.form.Macro.fire(e.code, this, event);
+                                }.bind(this));
+                            }
                         }
-                    }
+                    }.bind(this));
                 }.bind(this));
-            }.bind(this));
-        }
+            }
+        }.bind(this))
+        if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
 	},
-	_setValue: function(value){
+
+    _setValue: function(value){
+        this.moduleValueAG = o2.AG.all(value).then(function(v){
+            if (o2.typeOf(v)=="array") v = v[0];
+            if (this.moduleSelectAG){
+                this.moduleValueAG = this.moduleSelectAG;
+                this.moduleSelectAG.then(function(){
+                    this.__setValue(v);
+                }.bind(this));
+            }else{
+                this.__setValue(v)
+            }
+            return v;
+        }.bind(this));
+
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+    },
+
+    __setValue: function(value){
         this._setBusinessData(value);
 		var radios = this.node.getElements("input");
 		for (var i=0; i<radios.length; i++){
@@ -206,7 +236,29 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
         }
         return null;
     },
-	setData: function(data){
+
+    setData: function(data){
+        if (data && data.isAG){
+            this.moduleValueAG = o2.AG.all(data).then(function(v){
+                if (o2.typeOf(v)=="array") v = v[0];
+                this.__setData(v);
+            }.bind(this));
+        }else{
+            this.__setData(data);
+        }
+
+        // if (data && data.isAG){
+        //     this.moduleValueAG = data;
+        //     data.addResolve(function(v){
+        //         this.setData(v);
+        //     }.bind(this));
+        // }else{
+        //     this.__setData(data);
+        //     this.moduleValueAG = null;
+        // }
+    },
+
+    __setData: function(data){
         this._setBusinessData(data);
 		var inputs = this.node.getElements("input");
 		

+ 122 - 26
o2web/source/x_component_process_Xform/Select.js

@@ -131,21 +131,47 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 	},
 	setOptions: function(){
 		var optionItems = this.getOptions();
-        if (!optionItems) optionItems = [];
-        if (o2.typeOf(optionItems)==="array"){
-			optionItems.each(function(item){
-				var tmps = item.split("|");
-				var text = tmps[0];
-				var value = tmps[1] || text;
+		this._setOptions(optionItems);
+	},
+	_setOptions: function(optionItems){
+		this.moduleSelectAG = o2.AG.all(optionItems).then(function(options){
+			this.moduleSelectAG = null;
+			if (!options) options = [];
+			if (o2.typeOf(options)==="array"){
+				options.each(function(item){
+					var tmps = item.split("|");
+					var text = tmps[0];
+					var value = tmps[1] || text;
 
-				var option = new Element("option", {
-					"value": value,
-					"text": text
-				}).inject(this.node);
-			}.bind(this));
-			this.fireEvent("setOptions", [optionItems])
-		}
+					var option = new Element("option", {
+						"value": value,
+						"text": text
+					}).inject(this.node);
+				}.bind(this));
+				this.fireEvent("setOptions", [options])
+			}
+		}.bind(this));
+		if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+			this.moduleSelectAG = null;
+		}.bind(this));
 	},
+	// __setOptions: function(){
+	// 	var optionItems = this.getOptions();
+    //     if (!optionItems) optionItems = [];
+    //     if (o2.typeOf(optionItems)==="array"){
+	// 		optionItems.each(function(item){
+	// 			var tmps = item.split("|");
+	// 			var text = tmps[0];
+	// 			var value = tmps[1] || text;
+	//
+	// 			var option = new Element("option", {
+	// 				"value": value,
+	// 				"text": text
+	// 			}).inject(this.node);
+	// 		}.bind(this));
+	// 		this.fireEvent("setOptions", [optionItems])
+	// 	}
+	// },
 	addOption: function(text, value){
         var option = new Element("option", {
             "value": value || text,
@@ -153,21 +179,69 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
         }).inject(this.node);
 		this.fireEvent("addOption", [text, value])
 	},
+
 	_setValue: function(value){
+		this.moduleValueAG = o2.AG.all(value).then(function(v){
+			if (o2.typeOf(v)=="array") v = v[0];
+			if (this.moduleSelectAG){
+				this.moduleValueAG = this.moduleSelectAG;
+				this.moduleSelectAG.then(function(){
+					this.__setValue(v);
+				}.bind(this));
+			}else{
+				this.__setValue(v)
+			}
+			return v;
+		}.bind(this));
+
+		if (this.moduleValueAG) this.moduleValueAG.then(function(){
+			this.moduleValueAG = null;
+		}.bind(this));
+
+
+		// if (value && value.isAG){
+		// 	this.moduleValueAG = o2.AG.all(value),then(function(v){
+		// 		this._setValue(v);
+		// 	}.bind(this));
+		// 	// this.moduleValueAG = value;
+		// 	// value.addResolve(function(v){
+		// 	// 	this._setValue(v);
+		// 	// }.bind(this));
+		// }else{
+		//
+		// }
+	},
+	__setValue: function(value){
 		if (!this.readonly && !this.json.isReadonly ) {
-            this._setBusinessData(value);
-            for (var i=0; i<this.node.options.length; i++){
-                var option = this.node.options[i];
-                if (option.value==value){
-                    option.selected = true;
-                    //	break;
-                }else{
-                    option.selected = false;
-                }
-            }
-        }
-		//this.node.set("value", value);
+			this._setBusinessData(value);
+			for (var i=0; i<this.node.options.length; i++){
+				var option = this.node.options[i];
+				if (option.value==value){
+					option.selected = true;
+					//	break;
+				}else{
+					option.selected = false;
+				}
+			}
+		}
+		this.moduleValueAG = null;
 	},
+
+	// _setValue: function(value){
+	// 	if (!this.readonly && !this.json.isReadonly ) {
+    //         this._setBusinessData(value);
+    //         for (var i=0; i<this.node.options.length; i++){
+    //             var option = this.node.options[i];
+    //             if (option.value==value){
+    //                 option.selected = true;
+    //                 //	break;
+    //             }else{
+    //                 option.selected = false;
+    //             }
+    //         }
+    //     }
+	// 	//this.node.set("value", value);
+	// },
 	getTextData: function(){
 		var value = [];
 		var text = [];
@@ -208,6 +282,7 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 		return (value.length==1) ? value[0] : value;
 	},
     resetData: function(){
+		debugger;
         this.setData(this.getValue());
     },
 	getOptionsObj : function(){
@@ -224,7 +299,28 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 		}
 		return { textList : textList, valueList : valueList };
 	},
+
 	setData: function(data){
+		if (data && data.isAG){
+			this.moduleValueAG = o2.AG.all(data).then(function(v){
+				if (o2.typeOf(v)=="array") v = v[0];
+				this.__setData(v);
+			}.bind(this));
+		}else{
+			this.__setData(data);
+		}
+		// if (data && data.isAG){
+		// 	this.moduleValueAG = data;
+		// 	data.addResolve(function(v){
+		// 		this.setData(v);
+		// 	}.bind(this));
+		// }else{
+		// 	this.__setData(data);
+		// 	this.moduleValueAG = null;
+		// }
+	},
+
+	__setData: function(data){
         this._setBusinessData(data);
 		if (this.readonly|| this.json.isReadonly){
 			var d = typeOf(data) === "array" ? data : [data];
@@ -234,7 +330,7 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 				var idx = ops.valueList.indexOf( v );
 				result.push( idx > -1 ? ops.textList[idx] : v);
 			})
-			this.node.set("text", result.join(","))
+			this.node.set("text", result.join(","));
 		}else{
 			var ops = this.node.getElements("option");
 			ops.each(function(op){

+ 48 - 6
o2web/source/x_component_process_Xform/Textarea.js

@@ -4,7 +4,7 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
 	Extends: MWF.APP$Input,
 	
 	_loadUserInterface: function(){
-
+debugger;
 		this._loadNode();
         if (this.json.compute == "show"){
             this._setValue(this._computeValue());
@@ -22,17 +22,59 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
     _loadNodeRead: function(){
         this.node.empty();
     },
+
+
     _setValue: function(value){
-        this._setBusinessData(value);
-        if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
-        if (this.readonly || this.json.isReadonly){
+        this.moduleValueAG = o2.AG.all(value).then(function(v){
+            this.moduleValueAG = null;
+            if (o2.typeOf(v)=="array") v = v[0];
+            this._setBusinessData(v);
+            if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+            if (this.readonly || this.json.isReadonly){
                 var reg = new RegExp("\n","g");
                 var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
                 var reg3 = new RegExp("\u003e","g");
                 var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
                 this.node.set("html", text);
-        }
+            }
+        }.bind(this));
+
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        return value;
+
+        // if (value && value.isAG){
+        //     this.moduleValueAG = value;
+        //     value.addResolve(function(v){
+        //         this._setValue(v);
+        //     }.bind(this));
+        // }else{
+        //     this._setBusinessData(value);
+        //     if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
+        //     if (this.readonly || this.json.isReadonly){
+        //         var reg = new RegExp("\n","g");
+        //         var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+        //         var reg3 = new RegExp("\u003e","g");
+        //         var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+        //         this.node.set("html", text);
+        //     }
+        //     return value;
+        // }
     },
+
+    // _setValue: function(value){
+    //     this._setBusinessData(value);
+    //     if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
+    //     if (this.readonly || this.json.isReadonly){
+    //             var reg = new RegExp("\n","g");
+    //             var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+    //             var reg3 = new RegExp("\u003e","g");
+    //             var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+    //             this.node.set("html", text);
+    //     }
+    // },
     _resetNodeEdit: function(){
         var input = new Element("textarea", {"styles": {
                 "background": "transparent",
@@ -130,4 +172,4 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
         }
     }
 	
-}); 
+}); 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff