add postData to get data
This commit is contained in:
@ -36,8 +36,6 @@ class EdtRec
|
||||
this.pBarCnt=0; //Progress Bar
|
||||
this.pBarDiv=null; //Progress Bar
|
||||
|
||||
this.request = new TRequest(this);
|
||||
|
||||
//this.fields = new Array();
|
||||
|
||||
ERec_mas[this.uid]=this;
|
||||
@ -82,10 +80,24 @@ class EdtRec
|
||||
this.f_TypeName=typeName;
|
||||
this.f_Settings=settings;
|
||||
this.record_id=id;
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+typeName+'"></type></metadata>'))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+typeName+'"></type></metadata>',
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.eRecNo(data,this.record_id);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
};
|
||||
|
||||
//Задать CDATA значение для узла "type->properties->prop" по "n"
|
||||
@ -140,17 +152,17 @@ class EdtRec
|
||||
//Записываю record_id в соответствующее XML поле
|
||||
this.setPropCdata(nodeType.getAttribute("ObjectID"),record_id);
|
||||
|
||||
let str='';
|
||||
str+=' <table class="SEdit" id="eTable'+this.uid+'" border="0px" cellspacing="1" cellpadding="1" style="width: 100%; height: 100%;">';
|
||||
str+=' <caption><b id="caption'+this.uid+'"></b></caption>';
|
||||
str+=' <thead>';
|
||||
str+=' <tr style="background-color:#dadada;">';
|
||||
str+=' <th style="width:20%">'+trt('Name')+'</th>';
|
||||
str+=' <th style="width:80%">'+trt('Value')+'</th>';
|
||||
str+=' </tr>';
|
||||
str+=' </thead>';
|
||||
str+=' <tbody></tbody>';
|
||||
str+=' </table>';
|
||||
let str=`
|
||||
<table class="SEdit" id="eTable`+this.uid+`" border="0px" cellspacing="1" cellpadding="1" style="width: 100%; height: 100%;">
|
||||
<caption><b id="caption`+this.uid+`"></b></caption>
|
||||
<thead>
|
||||
<tr style="background-color:#dadada;">
|
||||
<th style="width:20%">`+trt('Name')+`</th>
|
||||
<th style="width:80%">`+trt('Value')+`</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>`;
|
||||
document.getElementById('eDiv'+this.uid).innerHTML=str;
|
||||
//this.win.setContent(str);
|
||||
|
||||
@ -236,14 +248,9 @@ class EdtRec
|
||||
}
|
||||
nP=nP.nextSibling;
|
||||
}
|
||||
subSRec.f_Settings=nodeProp;
|
||||
|
||||
subSRec.f_State='0';
|
||||
if(subSRec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+nodeProp.getAttribute("n")+'"></type></metadata>'))
|
||||
{
|
||||
//obj.showProgressBar();
|
||||
}
|
||||
|
||||
subSRec.callData(nodeProp.getAttribute("n"),nodeProp);
|
||||
|
||||
}else
|
||||
if (nodeProp.nodeName=="divide") //Grouping fields.
|
||||
{
|
||||
@ -673,7 +680,7 @@ class EdtRec
|
||||
}else
|
||||
if(vt==="blob" || vt==="file")
|
||||
{
|
||||
let ifr=createIFrame("prop_"+this.uid+"_"+nodeProp.getAttribute("n")+'_frm', ScriptUName+"?fn=9", td2, false); //IFrame to send the file to the server.
|
||||
let ifr=createIFrame("prop_"+this.uid+"_"+nodeProp.getAttribute("n")+'_frm', ScriptUName, td2, false); //IFrame to send the file to the server.
|
||||
document.body.appendChild(ifr);
|
||||
|
||||
let tbl_b=document.createElement('table');
|
||||
@ -865,10 +872,21 @@ class EdtRec
|
||||
this.fillGUIFromXML();
|
||||
}else
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="5"><type id="'+this.record_id+'" n="'+type_name+'" ObjectID="'+nodeType.getAttribute("ObjectID")+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="5"><type id="'+this.record_id+'" n="'+type_name+'" ObjectID="'+nodeType.getAttribute("ObjectID")+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setData(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
};
|
||||
|
||||
@ -914,11 +932,26 @@ class EdtRec
|
||||
let option=document.getElementById("prop_"+this.uid+"_"+node.getAttribute("n"));
|
||||
setCdataValue(node,0,option.value);
|
||||
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
|
||||
//if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
@ -988,14 +1021,9 @@ class EdtRec
|
||||
rec.create(null);
|
||||
rec.f_State=1;
|
||||
rec.f_PropName=nodeProp.getAttribute("n");
|
||||
rec.f_Settings=settings;
|
||||
rec.f_TypeName=TypeName;
|
||||
rec.win.setLeftTop(pageX-250,pageY-10);
|
||||
rec.win.setParent(this.win);
|
||||
if(rec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+TypeName+'"></type></metadata>'))
|
||||
{
|
||||
rec.showProgressBar();
|
||||
}
|
||||
rec.callData(TypeName,settings)
|
||||
};
|
||||
|
||||
//Запросить данные для выпадающих списков и других объектов (только после загрузки данных полей)
|
||||
@ -1029,18 +1057,46 @@ class EdtRec
|
||||
}
|
||||
nColF = nColF.nextSibling;
|
||||
}
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}else
|
||||
{
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'"></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
}else
|
||||
{
|
||||
@ -1199,39 +1255,6 @@ class EdtRec
|
||||
}
|
||||
};
|
||||
|
||||
applyReq(req,fn,node,xmldoc,win)
|
||||
{
|
||||
this.hideProgressBar();
|
||||
|
||||
if(node.error_code>0) {
|
||||
alert2(trt('Alert'), node.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fn==0) {
|
||||
this.eRecNo(node,this.record_id);
|
||||
} else
|
||||
if (fn==1) { //returned id
|
||||
this.insertRows(node);
|
||||
} else
|
||||
if (fn==2) { //Returned id and type of updated record
|
||||
this.updateRows(node);
|
||||
} else
|
||||
if (fn==3) { //Returned id of deleted record
|
||||
this.deleteRows(node);
|
||||
} else
|
||||
if (fn==5) {
|
||||
this.setData(node);
|
||||
} else
|
||||
if (fn==6) { //Fill in the drop-down lists.
|
||||
this.setDataSelect(node);
|
||||
} else
|
||||
if (fn==7) {
|
||||
this.setData(node);
|
||||
} else {
|
||||
alert2(trt('Alert'),"Unknown function! fn=\""+fn+"\"" );
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Request data to fill in the field with the button
|
||||
*
|
||||
@ -1267,10 +1290,25 @@ class EdtRec
|
||||
'</type></metadata>';
|
||||
}
|
||||
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),'Field "'+prop_id+'" not find!');
|
||||
@ -1291,10 +1329,25 @@ class EdtRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+typeName+'" c="'+name+'" pn="'+htmlid+'"><objects-list><filter>';
|
||||
xml+='<column n="'+filterName+'"><![CDATA['+value+']]></column>';
|
||||
xml+='</filter></objects-list></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1377,10 +1430,25 @@ class EdtRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'" id="'+value+'">';
|
||||
xml+='<objects-list><filter><column n="'+findFirstNode(this.nodeMetadata, 'type').getAttribute('ObjectID')+'"><![CDATA['+value+']]></column></filter></objects-list>';
|
||||
xml+='</type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1459,11 +1527,41 @@ class EdtRec
|
||||
s+=' </properties>\n';
|
||||
s+='</type>\n';
|
||||
s+='</metadata>';
|
||||
//alert2(trt('Alert'),s);
|
||||
if(this.request.callServer(ScriptName,s,true))
|
||||
{
|
||||
|
||||
if (this.record_id!=-1) {
|
||||
postXMLData(ScriptName, s, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.updateRows(data);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}else{
|
||||
postXMLData(ScriptName, s, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.insertRows(data);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
//if(this.request.callServer(ScriptName,s,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
};
|
||||
//Check the field according to its type
|
||||
checkData(value,type,maybenull)
|
||||
|
||||
Reference in New Issue
Block a user