add postData to get data
This commit is contained in:
@ -31,7 +31,6 @@ class SRec
|
||||
this.masCL=new Array();//node table column
|
||||
this.masVis=new Array(); //Whether to display a column
|
||||
this.masChBox=new Array(); //Checkboxes
|
||||
this.xmldoc=null; //accepted XML document (for CDATA creation)
|
||||
this.pagepos=0; //current data page
|
||||
|
||||
this.pBarCnt=0; //Progress bar
|
||||
@ -40,57 +39,12 @@ class SRec
|
||||
this.name="";
|
||||
|
||||
this.uid=getUID();
|
||||
this.request = new TRequest(this);
|
||||
SRec_mas[this.uid]=this;
|
||||
|
||||
this.onUpdate=null; //For call set function
|
||||
this.onInsert=null; //For call set function
|
||||
}
|
||||
|
||||
applyReq(req,fn,node,xmldoc)
|
||||
{
|
||||
this.hideProgressBar();
|
||||
|
||||
if(node.error_code>0) {
|
||||
alert2(trt('Alert'), node.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
this.xmldoc=node.ownerDocument; //xmldoc;
|
||||
|
||||
if (fn==0)
|
||||
{
|
||||
//alert2(trt('Alert'),getXMLNodeSerialisation(node));
|
||||
this.setMetadata(node);
|
||||
this.updateSize();
|
||||
}else
|
||||
if (fn==11) //Update record after editing, 1 entry has come.
|
||||
{
|
||||
this.updateRows(node);
|
||||
}else
|
||||
if (fn==3) //Information which record or records were deleted.
|
||||
{
|
||||
this.ApplyDelRec(node);
|
||||
}else
|
||||
if (fn==4) //Data after the selection of records, replacement of existing ones.
|
||||
{
|
||||
this.insertRows(node,true);
|
||||
}else
|
||||
if (fn==6) //Fill in the drop-down lists.
|
||||
{
|
||||
this.setDataSelect(node);
|
||||
}else
|
||||
if (fn==8) //There was a link to the report.
|
||||
{
|
||||
if(this.rwin!=null)
|
||||
{
|
||||
this.rwin.hideProgressBar();
|
||||
this.rwin.setContent('<table border="0px" style="width: 100%; height: 100%; background-color: var(--back-color-1);"><tr><td align="center"><a href="'+ScriptRName+(ScriptRName.indexOf('?')!=-1 ? '&file=' : '?file=')+findFirstNode(node,'#cdata-section').nodeValue+'" target="_blank">'+trt('Download_report')+': "'+this.win.getCaption().innerHTML+'".</a></td></tr></table>');
|
||||
}
|
||||
}else
|
||||
alert2(trt('Alert'),"Unknown function! fn=\""+fn+"\"" );
|
||||
}
|
||||
|
||||
//Edit the GUI filter from the xml string.
|
||||
setGUISettings(xmlStr)
|
||||
{
|
||||
@ -166,7 +120,7 @@ class SRec
|
||||
<td><img src="../resources/metadata/dbms/images/refresh.png" alt="`+trt('Refresh')+`" id="SRec_Rfr_`+this.uid+`" title="`+trt('Update')+`" style="cursor: pointer;"/></td></tr>
|
||||
</table>
|
||||
</td></tr><tr><td id="tblContainer_`+this.uid+`" style="vertical-align:top; overflow:hidden; width:100%; height:100%; text-align:center;">
|
||||
<div id="tblSContainer_`+this.uid+`" style="position: absolute; overflow:scroll; width: 400px; height: 400px;">
|
||||
<div id="tblSContainer_`+this.uid+`" style="background-color: var(--back-color2); position: absolute; overflow:scroll; width: 400px; height: 400px;">
|
||||
<table id="thetable`+this.uid+`" class="SShow">
|
||||
<caption></caption>
|
||||
<thead><tr><th></th></tr></thead>
|
||||
@ -430,11 +384,7 @@ class SRec
|
||||
'<objects-list><filter><column n="id"><![CDATA[' + id + ']]></column></filter></objects-list>' +
|
||||
'</type></metadata>';
|
||||
}
|
||||
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(xml);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),'Filter "'+column_n+'" not find!');
|
||||
@ -512,12 +462,34 @@ class SRec
|
||||
xs+='</filter></objects-list></type>\n';
|
||||
xs+='</metadata>';
|
||||
|
||||
//alert2(trt('Alert'),xs);
|
||||
|
||||
if(this.request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.showProgressBar();
|
||||
if(id!=-1) {
|
||||
postXMLData(ScriptName, xs, (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();
|
||||
});
|
||||
}else{
|
||||
postXMLData(ScriptName, xs, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.insertRows(data, true);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
}
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
//Get metadata records and break them into global variables.
|
||||
@ -532,6 +504,7 @@ class SRec
|
||||
let tablefilter=document.getElementById('idfilter'+this.uid);
|
||||
if (tablefilter==null || tablefilter.tBodies==null) alert2(trt('Alert'),'tablefilter=null');
|
||||
let nodeType=findFirstNode(node, "type");
|
||||
if (nodeType==null) alert2(trt('Alert'),'Not_find_data');
|
||||
this.f_pI=nodeType.getAttribute("ins");//access rights
|
||||
this.f_pU=nodeType.getAttribute("upd");
|
||||
this.f_pD=nodeType.getAttribute("del");
|
||||
@ -890,17 +863,10 @@ class SRec
|
||||
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();
|
||||
}
|
||||
this.callDataSelect(strXMLF);
|
||||
}else
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+object+'" c="'+fc+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect('<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+object+'" c="'+fc+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"></type></metadata>');
|
||||
}
|
||||
}else
|
||||
{
|
||||
@ -945,10 +911,7 @@ class SRec
|
||||
if ((value!="")&&(value!=-1))
|
||||
{
|
||||
let xmlString='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+columnNode.getAttribute("object")+'" c="'+columnNode.getAttribute("FieldCaption")+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"><objects-list><filter><column n="id"><![CDATA['+value+']]></column></filter></objects-list></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xmlString,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(xmlString);
|
||||
}
|
||||
}
|
||||
td2.appendChild( table );
|
||||
@ -1054,10 +1017,7 @@ class SRec
|
||||
}
|
||||
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(strXMLF);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1066,6 +1026,26 @@ class SRec
|
||||
}
|
||||
}
|
||||
|
||||
callDataSelect(data) {
|
||||
postXMLData(ScriptName,data,
|
||||
(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();
|
||||
}
|
||||
|
||||
//We ask the server for a list of values almost like a drop-down list.
|
||||
//typeName - The name of the object (TODO if the current is the variable f TypeName)
|
||||
//name - the name of the column for selecting the values (must match the name of any filter in typeName)
|
||||
@ -1079,10 +1059,7 @@ class SRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+typeName+'" c="'+name+'" pn="'+htmlid+'" id="'+id+'"><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();
|
||||
}
|
||||
this.callDataSelect(xml);
|
||||
}else
|
||||
{
|
||||
document.getElementById("filter_"+this.uid+"_"+htmlid).value='';
|
||||
@ -1401,14 +1378,9 @@ class SRec
|
||||
rec.create(null);
|
||||
rec.f_State=1; //Зачем коментил?
|
||||
rec.f_PropName=nodeColu.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);
|
||||
};
|
||||
//Call the ShowRecord window with the parameters for the filter (not just the object name)
|
||||
//id - id records from the database
|
||||
@ -1432,16 +1404,9 @@ class SRec
|
||||
//wishWin = window.open("showrecord.html?name="+typeName,typeName,"width=800,height=600,menubar=no,location=no,resizable=yes,scrollbars=yes");
|
||||
let rec=new SRec();
|
||||
rec.create(null);
|
||||
//rec.f_State=1; not used
|
||||
//rec.f_PropName=propname; not used
|
||||
rec.f_Settings=xmlString;
|
||||
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="'+rec.f_TypeName+'"></type></metadata>'))
|
||||
{
|
||||
rec.showProgressBar();
|
||||
}
|
||||
rec.callData(typeName,xmlString);
|
||||
}
|
||||
|
||||
//Get column number by name
|
||||
@ -1566,10 +1531,28 @@ class SRec
|
||||
xs+=' </filter></objects-list>\n';
|
||||
xs+=' </type>\n';
|
||||
xs+='</metadata>';
|
||||
if(this.request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.rwin.showProgressBar();
|
||||
}
|
||||
|
||||
postXMLData(ScriptName,xs,
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
if(this.rwin!=null)
|
||||
{
|
||||
this.rwin.hideProgressBar();
|
||||
this.rwin.setContent('<table border="0px" style="width: 100%; height: 100%; background-color: var(--back-color-1);"><tr><td align="center"><a href="'+ScriptRName+(ScriptRName.indexOf('?')!=-1 ? '&file=' : '?file=')+findFirstNode(node,'#cdata-section').nodeValue+'" target="_blank">'+trt('Download_report')+': "'+this.win.getCaption().innerHTML+'".</a></td></tr></table>');
|
||||
}
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
chp(page)
|
||||
@ -1639,10 +1622,23 @@ class SRec
|
||||
{
|
||||
if(this.masChBox[i].checked)
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="3"><type n="'+this.f_TypeName+'" id="'+this.masChBox[i].value+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="3"><type n="'+this.f_TypeName+'" id="'+this.masChBox[i].value+'"></type></metadata>',
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.ApplyDelRec(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1672,13 +1668,23 @@ class SRec
|
||||
{
|
||||
this.f_TypeName=typeName;
|
||||
this.f_Settings=settings;
|
||||
|
||||
if(this.request.callServer(ScriptName,'<metadata fn="0"><type n="'+this.f_TypeName+'"></type></metadata>'))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<metadata fn="0"><type n="'+this.f_TypeName+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setMetadata(data);
|
||||
this.updateSize();
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Convert XML to array
|
||||
|
||||
Reference in New Issue
Block a user