|
|
@@ -117,7 +117,7 @@ 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);
|
|
|
- if (o2.typeOf(par)=="o2_async_function"){
|
|
|
+ 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];
|
|
|
@@ -159,7 +159,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg = new Class({
|
|
|
if (this.json.defaultValue && this.json.defaultValue.code){
|
|
|
var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
|
|
|
|
|
|
- if (o2.typeOf(fd)=="o2_async_function"){
|
|
|
+ if (fd && fd.isAG){
|
|
|
// value.addResolve(function(v){
|
|
|
// this._setBusinessData(v);
|
|
|
// if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
|
|
|
@@ -418,6 +418,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);
|
|
|
@@ -766,49 +767,7 @@ 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 (oldValues.length === values.length){
|
|
|
@@ -824,46 +783,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 || ", ");
|
|
|
@@ -912,7 +934,8 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg = new Class({
|
|
|
debugger;
|
|
|
var values = [];
|
|
|
var ags = [];
|
|
|
- this.moduleValueAG = o2.AG.all(value).then(function(d) {
|
|
|
+ var simple = this.json.storeRange === "simple";
|
|
|
+ var ag = o2.AG.all(value).then(function(d) {
|
|
|
if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
|
|
|
|
|
|
d.each(function(dd){
|
|
|
@@ -926,17 +949,24 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg = new Class({
|
|
|
values.push(dd);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }.bind(this));
|
|
|
if (ags.length){
|
|
|
- o2.AG.all(ags).then(function(data){
|
|
|
- values.push(data);
|
|
|
+ return o2.AG.all(ags).then(function(data){
|
|
|
+ values = values.concat(data);
|
|
|
this.__setValue(values);
|
|
|
- });
|
|
|
+ return values;
|
|
|
+ }.bind(this));
|
|
|
}else{
|
|
|
this.__setValue(values);
|
|
|
+ return values
|
|
|
}
|
|
|
+ }.bind(this));
|
|
|
|
|
|
+ this.moduleValueAG = ag;
|
|
|
+ ag.then(function(){
|
|
|
+ this.moduleValueAG = "";
|
|
|
}.bind(this));
|
|
|
+ return ag;
|
|
|
},
|
|
|
__setValue: function(value){
|
|
|
this.moduleValueAG = null;
|
|
|
@@ -1004,8 +1034,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);
|
|
|
}
|
|
|
}
|