huqi 5 лет назад
Родитель
Сommit
9e8c515fe1

+ 1 - 2
o2web/source/o2_core/o2.js

@@ -1683,7 +1683,6 @@
 
     var _AsyncGeneratorPrototype = _Class.create({
         initialize: function(resolve, reject, name){
-            debugger;
             this.isAG = true;
             this.name = name || "";
             this._createSuccess();
@@ -1712,7 +1711,7 @@
             var _self = this;
             this.failure = function(){
                 var result;
-                if (_self.failure.reject) result = _self.failure.reject(arguments);
+                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;

+ 21 - 7
o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js

@@ -91,19 +91,33 @@ 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.success){
-                option.success = function(v){return v;}.ag();
-                if (option.failure) {
-                    option.success.catch(option.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")){

+ 3 - 3
o2web/source/o2_core/o2/xScript/Environment.js

@@ -2230,7 +2230,7 @@ MWF.xScript.createDict = 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;
                 }
             }
@@ -2241,9 +2241,9 @@ MWF.xScript.createDict = function(application){
             var cb = function(json){
                 value = json.data;
                 MWF.xScript.addDictToCache(opt, path, value);
-                if (success) value = success(json.data);
+                if (success && o2.typeOf(success)=="function") value = success(json.data);
                 return value;
-            }.ag().catch(function(xhr, text, error){ if (failure) return failure(xhr, text, error); });
+            }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
 
             if (path){
                 var p = encodePath( path );

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

@@ -61,8 +61,7 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
     },
 
     __setValue: function(value){
-	    var d = Date.parse(value);
-	    var v = d.format(this.json.format);
+        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);

+ 10 - 1
o2web/source/x_component_process_Xform/Checkbox.js

@@ -149,6 +149,9 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
                 }.bind(this));
             }
         }.bind(this));
+        if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
 	},
 
     _setValue: function(value){
@@ -156,13 +159,19 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
             if (this.moduleSelectAG){
                 this.moduleValueAG = this.moduleSelectAG;
                 this.moduleSelectAG.then(function(){
+                    this.moduleValueAG = null;
                     this.__setValue(v);
                 }.bind(this));
             }else{
-                this.__setValue(v)
+                this.moduleValueAG = null;
+                this.__setValue(v);
             }
             return v;
         }.bind(this));
+
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = "";
+        }.bind(this));
     },
 
     __setValue: function(value){

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

@@ -1321,8 +1321,19 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor =  new Cla
         if (this.allowEdit){
             this.loadCkeditorFiletext(function(e){
                 e.editor.focus();
-                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());
 

+ 5 - 3
o2web/source/x_component_process_Xform/Org.js

@@ -932,10 +932,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         return node;
     },
     _setValue: function(value){
-        debugger;
         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()] : [];
 
@@ -954,18 +954,20 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             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;
-        ag.then(function(){
-            this.moduleValueAG = "";
+        if (ag) ag.then(function(){
+            this.moduleValueAG = null;
         }.bind(this));
         return ag;
     },

+ 7 - 1
o2web/source/x_component_process_Xform/Radio.js

@@ -155,7 +155,9 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
                 }.bind(this));
             }
         }.bind(this))
-
+        if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
 	},
 
     _setValue: function(value){
@@ -171,6 +173,10 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
             }
             return v;
         }.bind(this));
+
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
     },
 
     __setValue: function(value){

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

@@ -150,7 +150,10 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 				}.bind(this));
 				this.fireEvent("setOptions", [options])
 			}
-		}.bind(this))
+		}.bind(this));
+		if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+			this.moduleSelectAG = null;
+		}.bind(this));
 	},
 	// __setOptions: function(){
 	// 	var optionItems = this.getOptions();
@@ -191,6 +194,11 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 			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);

+ 7 - 1
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());
@@ -27,6 +27,7 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
     _setValue: function(value){
         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){
@@ -37,6 +38,11 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
                 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){