diff --git a/metadata/dbms/editrecord.js b/metadata/dbms/editrecord.js index 83f2d2d..8493b2d 100644 --- a/metadata/dbms/editrecord.js +++ b/metadata/dbms/editrecord.js @@ -511,7 +511,7 @@ class EdtRec button.setAttribute("type","button"); button.setAttribute("value","..."); button.style.cssText="width:30px;font-size:9pt;margin:0px;padding:0px;height:100%;"; - button.onclick=this.onSelObj(nodeProp.getAttribute("ot"),nodeProp.getAttribute("n")); + button.onclick=function(thiz,val1,val2){return function(){thiz.SelectObjects(val1,val2);};}(this,nodeProp.getAttribute("ot"),nodeProp.getAttribute("n")); newCell2.appendChild(button); td2.appendChild( table ); @@ -578,7 +578,7 @@ class EdtRec button.setAttribute("type","button"); button.setAttribute("value","..."); button.style.cssText="width:30px;font-size:9pt;margin:0px;padding:0px;"; - button.onclick=this.onSelObj(nodeProp.getAttribute("ot"),nodeProp.getAttribute("n")); + button.onclick=function(thiz,val1,val2){return function(){thiz.SelectObjects(val1,val2);};}(this,nodeProp.getAttribute("ot"),nodeProp.getAttribute("n")); newCell2.appendChild(button); td2.appendChild( table ); @@ -883,26 +883,23 @@ class EdtRec win.setContent(str); }; - onSelObj(val1,val2) + //request data to fill the Object Filter + //The result can fill the filter field with complete information or a window with a further choice of the value + SelectObjects(typeName,propname) { - var obj=this; - return function() + let rec=new SRec(); + rec.opener=this; + rec.create(); + rec.f_State=1; + rec.f_PropName=propname; + rec.f_TypeName=typeName; + rec.win.setLeftTop(pageX-250,pageY-10); + rec.win.setParent(this.win); + if(rec.request.callServer(ScriptName,'')) { - var rec=new SRec(); - rec.create(); - //rec.f_Settings=xmlString; - rec.f_State='0'; - rec.f_TypeName=val1; - rec.f_PropName=val2; - rec.win.setLeftTop(pageX-250,pageY-10); - rec.win.setParent(obj.win); - if(rec.request.callServer(ScriptName,'')) - { - obj.showProgressBar(); - } - //win.selObj(val1,val2); - }; - }; + rec.showProgressBar(); + } + } //Call the ShowRecord.html window with the parameters for the filter (not just the object name). callWindow(nodeProp) diff --git a/metadata/dbms/showrecord.js b/metadata/dbms/showrecord.js index aca3887..a4d48d0 100644 --- a/metadata/dbms/showrecord.js +++ b/metadata/dbms/showrecord.js @@ -11,9 +11,40 @@ function setFilterVal(uid,id,c,p) var SRec_mas = new Array(); //List of all objects "EdtRec" (then something better to think of) -function SRec() +class SRec { - this.applyReq=function(req,fn,node,xmldoc) + constructor() + { + this.win=null; + this.rwin=null; + + this.f_State='0'; //"0" - editing, "1" - selecting a single entry, "2" - selecting a multiple record + this.f_PropName=""; //If the mode f_State is 1 then f_PropName saves the name of the field for which the data is intended + this.f_TypeName=""; //the name of the displayed object (type-> n attribute) + //this.record_id=-1; //from here the form of editing takes the values id after its loading + this.f_Settings=""; //XML that is superimposed on the current node Metadata + this.f_pI=0; this.f_pU=0; this.f_pD=0; this.f_pS=0; //rights + this.nodeMetadata=null; //accepted metadata + this.nodeMetadataObjList=null; + this.f_nodeData=null; //received data, hidden fields + this.masCT=new Array();//parameter table for cells + 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 + this.pBarDiv=null; //Progress bar + + this.name=""; + + this.uid=getUID(); + this.request = new TRequest(this); + SRec_mas[this.uid]=this; + } + + applyReq(req,fn,node,xmldoc) { //alert(getXMLNodeSerialisation(node)); this.hideProgressBar(); @@ -54,27 +85,27 @@ function SRec() } }else alert("Unknown function! fn=\""+fn+"\"" ); - }; + } //Edit the GUI filter from the xml string. - this.setGUISettings=function(xmlStr) + setGUISettings(xmlStr) { if ((xmlStr!=null)&&(xmlStr!="")) { xmlDOC=CreateXMLDOC(xmlStr); - //var nPFilter=findFirstNode(xmlDOC,"filter") - var nPFilter=findNodeOnPath(xmlDOC.documentElement,"type/objects-list/filter"); + //let nPFilter=findFirstNode(xmlDOC,"filter") + let nPFilter=findNodeOnPath(xmlDOC.documentElement,"type/objects-list/filter"); nPColumn=nPFilter.firstChild; while (nPColumn != null) { if(nPColumn.nodeName=="column") { - var prop=document.getElementById('filter_'+this.uid+'_'+nPColumn.getAttribute("n")); + let prop=document.getElementById('filter_'+this.uid+'_'+nPColumn.getAttribute("n")); if(prop!==null) prop.value=getCdata(nPColumn).nodeValue; - /*var np=nPColumn.getAttribute("n") - var vp=nPColumn.getAttribute("visible") - var cdata=getCdata(nPColumn).nodeValue + /*let np=nPColumn.getAttribute("n") + let vp=nPColumn.getAttribute("visible") + let cdata=getCdata(nPColumn).nodeValue columnNode=findNodeOnAttribute(nodeFilter, 'column', 'n', np) if(columnNode!=null) @@ -85,13 +116,13 @@ function SRec() } nPColumn=nPColumn.nextSibling; } - var btn=document.getElementById("btnfilter_"+this.uid); + let btn=document.getElementById("btnfilter_"+this.uid); if(btn!==null) btn.focus(); } - }; + } //Apply the settings to the current node "type-> n" must match. - this.setXMLSettings=function(xml) + setXMLSettings(xml) { //Apply the parameters to the current XML filter if there are filter settings in the parent window! if(xml===null || typeof(xml) == "undefined") return; @@ -108,11 +139,11 @@ function SRec() applyNodeToNode(xml, findFirstNodeOnAttribute(this.nodeMetadata, "type", "n", this.f_TypeName), "n"); } } - }; + } - this.create=function(htmlElement) + create(htmlElement) { - var str='\ + let str='\
\
\ \ @@ -159,13 +190,13 @@ function SRec() document.getElementById('SRec_Del_'+this.uid).onclick=function(thiz){return function(){thiz.deleteRecord();};}(this); document.getElementById('SRec_Exc_'+this.uid).onclick=function(thiz){return function(){thiz.showreport('xls');};}(this); document.getElementById('SRec_Rfr_'+this.uid).onclick=function(thiz){return function(){thiz.appendFilter(); thiz.sendFilter(-1,0);};}(this); - }; + } //Update dimensions of the elements (the main table in absolute coordinates). - this.updateSize=function() + updateSize() { - var dv1=document.getElementById("tblSContainer_"+this.uid); - var dv2=document.getElementById("tblContainer_"+this.uid); + let dv1=document.getElementById("tblSContainer_"+this.uid); + let dv2=document.getElementById("tblContainer_"+this.uid); if(dv1!=null && dv2!=null) { dv1.style.width = dv2.offsetWidth+"px"; @@ -174,7 +205,7 @@ function SRec() } //Show progress bar - this.showProgressBar=function() + showProgressBar() { this.pBarCnt++; if(this.pBarDiv==null) @@ -183,13 +214,13 @@ function SRec() this.pBarDiv.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1; background-color: rgba(0,0,0,0.5); width:100%; height: 100%;'; this.pBarDiv.innerHTML='
'; - var eDiv=document.getElementById('eDiv'+this.uid); + let eDiv=document.getElementById('eDiv'+this.uid); eDiv.appendChild(this.pBarDiv); } - }; + } //Hide progress bar - this.hideProgressBar=function() + hideProgressBar() { this.pBarCnt--; if(this.pBarCnt<=0) @@ -198,22 +229,22 @@ function SRec() this.pBarCnt=0; this.pBarDiv=null; } - }; + } //Function to fill the drop-down lists (here it is necessary to ensure that everywhere there is a "var" in front of the variables). - this.setDataSelect=function(node) + setDataSelect(node) { //alert("setDataSelect = " + getXMLNodeSerialisation(node)); - var nodeType,prop_id,prop,option,nodeProp,id,value,cdataNode; + let nodeType,prop_id,prop,option,nodeProp,id,value,cdataNode; nodeType=findFirstNode(node, 'type'); prop_id=nodeType.getAttribute("pn");//Field name prop=document.getElementById('filter_'+this.uid+'_'+prop_id); //Determine what type of node was a drop-down list or a field with a button. - var selector=null; - nodeFilter=findNodeOnPath(this.nodeMetadata,"type/objects-list/filter"); - nodeCur=findNodeOnAttribute(nodeFilter, 'column', 'n', prop_id); + let selector=null; + let nodeFilter=findNodeOnPath(this.nodeMetadata,"type/objects-list/filter"); + let nodeCur=findNodeOnAttribute(nodeFilter, 'column', 'n', prop_id); if(nodeCur!=null) selector=nodeCur.getAttribute("selector"); //alert("nodeCur = " + getXMLNodeSerialisation(nodeCur)); @@ -233,9 +264,9 @@ function SRec() prop.innerHTML = ""; //Select the value for this list - var val=null; - var nodeFilter=findNodeOnPath(this.nodeMetadata,"type/objects-list/filter"); - nodeCol=nodeFilter.firstChild; + let val=null; + let nodeFilter=findNodeOnPath(this.nodeMetadata,"type/objects-list/filter"); + let nodeCol=nodeFilter.firstChild; while(nodeCol!=null) { if((nodeCol.nodeName==="column")&&(nodeCol.getAttribute("n")==prop_id)) @@ -284,7 +315,7 @@ function SRec() }else //if the field with the button { //count the number of values - var count=0; + let count=0; nodeProp=nodeType.firstChild; while (nodeProp!=null) { if (nodeProp.nodeName=="record") @@ -307,7 +338,7 @@ function SRec() }else if(count>1) //The item selection window is displayed. { - var htmlString=''; + let htmlString='
'; nodeProp=nodeType.firstChild i=0; while (nodeProp!=null) @@ -325,7 +356,7 @@ function SRec() } htmlString+='
'; - var win=new TWin(); + let win=new TWin(); win.TWin(pageX-10,pageY-10); win.setHeight(400); win.setContent(htmlString); @@ -337,7 +368,7 @@ function SRec() }; //Set the value for the object filter with a text field search - this.setFilterVal=function(id,caption,prop_id) + setFilterVal(id,caption,prop_id) { prop=document.getElementById('filter_'+this.uid+'_'+prop_id); propvis=document.getElementById('filter_'+this.uid+'_'+prop_id+'_visible'); @@ -349,15 +380,15 @@ function SRec() this.appendFilter(); //We move the values from the HTML fields to XML. this.sendFilter(-1,0); } - }; + } //we pass the id to the object filter prop_id - the name of the filter - this.setFilterObject=function(TypeName, prop_id, id) + setFilterObject(TypeName, prop_id, id) { node=findFirstNodeOnAttribute(this.nodeMetadata,'column','n',prop_id); if(node!=null) { - var name=node.getAttribute("FieldCaption"); + let name=node.getAttribute("FieldCaption"); getCdata(node).nodeValue=id; //we request data from the server to fill in the comments on the record id prop=document.getElementById('filter_'+this.uid+'_'+prop_id); @@ -371,10 +402,10 @@ function SRec() { alert('Filter "'+prop_id+'" not find!'); } - }; + } //The function to collect data from HTML fields in XML - this.appendFilter=function() + appendFilter() { nodeType=findFirstNode(this.nodeMetadata, "type"); nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); @@ -385,15 +416,15 @@ function SRec() { if (columnNode.nodeName=="column") { - var value = ''; - var input = document.getElementById('filter_'+this.uid+'_'+columnNode.getAttribute("n")); + let value = ''; + let input = document.getElementById('filter_'+this.uid+'_'+columnNode.getAttribute("n")); if(input!=null) value=input.value; //'2016-02-27 00:00:00' if(columnNode.getAttribute("vt")=="dateTime" || columnNode.getAttribute("vt")=="date") //If field is "dateTime" then transmit in UnixTime format in second { if(value!=""){ - var date = new Date(value.replace(/-/g, "/")); + let date = new Date(value.replace(/-/g, "/")); value=date.getTime()/1000;// - date.getTimezoneOffset()*60; if(isNaN(value)) value=''; } @@ -405,25 +436,25 @@ function SRec() } } //alert(getXMLNodeSerialisation(this.nodeMetadata)); - }; + } /** Function to send filter data to the server * id - id of record -1 then all * page - result page number */ - this.sendFilter=function(id,page) + sendFilter(id,page) { - var nodeType=findFirstNode(this.nodeMetadata, "type"); - var nodeObjectsList=findFirstNode(nodeType, "objects-list"); - var nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); - var typename=nodeType.getAttribute("n"); - var xs=''; + let nodeType=findFirstNode(this.nodeMetadata, "type"); + let nodeObjectsList=findFirstNode(nodeType, "objects-list"); + let nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); + let typename=nodeType.getAttribute("n"); + let xs=''; xs+='\n'; if(id!=-1) xs+='\n'; else xs+='\n'; xs+=' '; //Opera does not serialize CDATA, so we form the filter manually - var nextNode=nodeFilter.firstChild; + let nextNode=nodeFilter.firstChild; while(nextNode!=null) { if(nextNode.nodeName=="column") @@ -451,26 +482,26 @@ function SRec() { this.showProgressBar(); } - }; + } //Get metadata records and break them into global variables. - this.setMetadata=function(node) + setMetadata(node) { this.nodeMetadata=node; //Create GUI filter - var td,tr,td1,td2; - var nodeFilter=null; - var tablefilter=document.getElementById('idfilter'+this.uid); + let td,tr,td1,td2; + let nodeFilter=null; + let tablefilter=document.getElementById('idfilter'+this.uid); if (tablefilter.tBodies==null) alert('tablefilter=null'); - nodeType=findFirstNode(node, "type"); + let nodeType=findFirstNode(node, "type"); this.f_pI=nodeType.getAttribute("ins");//access rights this.f_pU=nodeType.getAttribute("upd"); this.f_pD=nodeType.getAttribute("del"); this.f_pS=nodeType.getAttribute("sel"); this.f_TypeName = nodeType.getAttribute("n"); this.name=this.f_TypeName; - rep=nodeType.getAttribute("rep"); + let rep=nodeType.getAttribute("rep"); if(rep!='1') deleteHTML("id_pdf"); //TODO if(this.f_pI!='1') deleteHTML('SRec_Add_'+this.uid); if(this.f_pD!='1') deleteHTML('SRec_Del_'+this.uid); @@ -481,20 +512,20 @@ function SRec() //Appending settings to nodeMetadata this.setXMLSettings(this.f_Settings); - //var id=-1; + //let id=-1; //After loading the metadata, we request the data by sending an XML filter. count=0; - row=1; nRow=null; - h=nodeFilter.getAttribute("height"); + let row=1; let nRow=null; + let h=nodeFilter.getAttribute("height"); if((nodeFilter!=null)&&(h!=0)) //Create HTML elements by XML filter. { - columnNode=nodeFilter.firstChild; + let columnNode=nodeFilter.firstChild; while (columnNode != null) { if ((columnNode.nodeName==="column")&&(columnNode.getAttribute("visible")!="0")) { count++; - var value=getCdataValue(columnNode); + let value=getCdataValue(columnNode); if(row>1) row--; if(columnNode.getAttribute("row")!=null) row=parseInt(columnNode.getAttribute("row"))+1; @@ -505,7 +536,7 @@ function SRec() tr.appendChild(td1); td1.colSpan='2'; - var table=document.createElement('table'); + let table=document.createElement('table'); table.border=0; table.setAttribute("width","100%"); table.cellspacing=0; @@ -536,16 +567,16 @@ function SRec() td1.style.cssText='white-space:nowrap;'; if (columnNode.getAttribute("vt")==="dateTime") { - var table=document.createElement('table'); + let table=document.createElement('table'); table.border=0; table.style.cssText="width:100%;/*table-layout:fixed;*/border-spacing:0;border-collapse:collapse;"; - newRow=table.insertRow(0); - var newCell1 = newRow.insertCell(0); + let newRow=table.insertRow(0); + let newCell1 = newRow.insertCell(0); newCell1.style.cssText="padding:0px;width:100%;"; - var newCell2 = newRow.insertCell(1); + let newCell2 = newRow.insertCell(1); newCell2.style.cssText="padding:0px;width:25px;"; - input = document.createElement('input'); + let input = document.createElement('input'); input.style.cssText="width: 100%;"; input.setAttribute("type","text"); input.onkeydown=function(event){ @@ -561,7 +592,7 @@ function SRec() newCell1.appendChild( input ); - var img = document.createElement('img'); + let img = document.createElement('img'); img.src='../resources/metadata/dbms/images/datepicker.jpg'; img.style.cssText="cursor: pointer;"; newCell2.appendChild(img); @@ -582,13 +613,13 @@ function SRec() }else if (columnNode.getAttribute("vt")==="date") { - var table=document.createElement('table'); + let table=document.createElement('table'); table.border=0; table.style.cssText="width:100%;/*table-layout:fixed;*/border-spacing:0;border-collapse:collapse;"; newRow=table.insertRow(0); - var newCell1 = newRow.insertCell(0); + let newCell1 = newRow.insertCell(0); newCell1.style.cssText="padding:0px;width:100%;"; - var newCell2 = newRow.insertCell(1); + let newCell2 = newRow.insertCell(1); newCell2.style.cssText="padding:0px;width:25px;"; input = document.createElement('input'); @@ -607,7 +638,7 @@ function SRec() newCell1.appendChild( input ); - var img = document.createElement('img'); + let img = document.createElement('img'); img.src='../resources/metadata/dbms/images/datepicker.jpg'; img.style.cssText="cursor: pointer;"; newCell2.appendChild(img); @@ -626,15 +657,15 @@ function SRec() }else if (columnNode.getAttribute("vt")==="b") { - select = document.createElement('select'); + let select = document.createElement('select'); select.onkeydown=function(){ if(event.keyCode==13) event.keyCode=9; }; select.style.cssText="width: 100%;"; - var opt=findFirstNode(columnNode,"options"); + let opt=findFirstNode(columnNode,"options"); if(opt==null) { - option=document.createElement("option"); + let option=document.createElement("option"); option.setAttribute("value",""); option.appendChild(document.createTextNode("")); if(value=="") option.selected=true; @@ -670,7 +701,7 @@ function SRec() }else if (columnNode.getAttribute("vt")==="string") { - input = document.createElement('input'); + let input = document.createElement('input'); input.style.cssText="width: 100%;"; input.setAttribute("type","text"); input.onkeydown=function(event){if(event.which==13) event.which=9;}; @@ -683,18 +714,18 @@ function SRec() }else if (columnNode.getAttribute("vt")==="i4") { - var table=document.createElement('table'); + let table=document.createElement('table'); table.border=0; table.style.cssText="width:100%;/*table-layout:fixed;*/border-spacing:0;border-collapse:collapse;"; - newRow=table.insertRow(0); //We add a row in the created table. - var newCell1 = newRow.insertCell(0); + let newRow=table.insertRow(0); //We add a row in the created table. + let newCell1 = newRow.insertCell(0); newCell1.style.cssText="padding:0px;padding-right:1px;width:100%;"; - var newCell2 = newRow.insertCell(1); + let newCell2 = newRow.insertCell(1); newCell2.style.cssText="padding:0px;padding-right:1px;height:100%;"; - var newCell3 = newRow.insertCell(2); + let newCell3 = newRow.insertCell(2); newCell3.style.cssText="padding:0px;width:25px;height:100%;"; - input = document.createElement('input'); + let input = document.createElement('input'); input.style.cssText="width: 100%;"; input.setAttribute("type","text"); input.onkeydown=function(){ if(event.keyCode==13) event.keyCode=9; }; @@ -705,7 +736,7 @@ function SRec() input.setAttribute("id",'filter_'+this.uid+'_'+columnNode.getAttribute("n")); newCell1.appendChild( input ); - button = document.createElement('input'); + let button = document.createElement('input'); button.setAttribute("type","button"); button.setAttribute("value","+"); button.style.cssText="height:100%;width:22px;margin:0px;padding:0px;"; @@ -723,7 +754,7 @@ function SRec() }else if (columnNode.getAttribute("vt")==="f8") { - input = document.createElement('input'); + let input = document.createElement('input'); input.style.cssText="width: 100%;"; input.setAttribute("type","text"); input.onkeydown=function(){ if(event.keyCode==13) event.keyCode=9; }; @@ -736,23 +767,23 @@ function SRec() }else if (columnNode.getAttribute("vt")==="object") { - selector=columnNode.getAttribute("selector"); - object=columnNode.getAttribute("object"); - fc=columnNode.getAttribute("FieldCaption"); + let selector=columnNode.getAttribute("selector"); + let object=columnNode.getAttribute("object"); + let fc=columnNode.getAttribute("FieldCaption"); - var table=document.createElement('table'); + let table=document.createElement('table'); //table.setAttribute("bgColor","#0000FF") table.border=0; table.style.cssText="width:100%;/*table-layout:fixed;*/border-spacing:0;border-collapse:collapse;"; - newRow=table.insertRow(0); //We add a row in the created table. - var newCell1 = newRow.insertCell(0); - newCell1.style.cssText="padding:0px; border: 0px solid #999999; width:100%;"; - var newCell2 = newRow.insertCell(1); + let newRow=table.insertRow(0); //We add a row in the created table. + let newCell1 = newRow.insertCell(0); + newCell1.style.cssText="padding:0px; border: 0px solid #999999; /*width:100%;*/"; + let newCell2 = newRow.insertCell(1); newCell2.style.cssText="padding:0px; padding-left:1px; border: 0px solid #999999; width:30px; height:100%;"; if(selector=="combo") { - select = document.createElement('select'); + let select = document.createElement('select'); select.style.cssText="width: 100%;"; select.onkeydown=function(){ if(event.keyCode==13) event.keyCode=9; }; //select.setAttribute("name",columnNode.getAttribute("n")) @@ -762,15 +793,15 @@ function SRec() newCell1.appendChild(select); - button = document.createElement('input'); + let button = document.createElement('input'); button.setAttribute("type","button"); button.setAttribute("value","..."); - button.style.cssText="display:block; box-sizing: border-box; margin: 0px; padding: 0px; width:100%; height:100%; font-size: 9pt;"; + button.style.cssText="display:block; box-sizing: border-box; margin: 0px; padding: 0px;width:100%; height:100%; font-size: 9pt;"; button.onclick=function(thiz,val1,val2){return function(){thiz.SelectObjects(val1,val2);};}(this,object,columnNode.getAttribute("n")); newCell2.appendChild(button); //I collect values from XML and inserting a request to the server (to fill out the dropdown). - var nTypeF = findFirstNode(columnNode, "type"); + let nTypeF = findFirstNode(columnNode, "type"); if(nTypeF != null) { //Add parameters to request @@ -778,13 +809,13 @@ function SRec() nTypeF.setAttribute("pn",columnNode.getAttribute("n")); nTypeF.setAttribute("fn",columnNode.getAttribute("n")); - var strXMLF = getXMLNodeSerialisation(nTypeF); - var nColF=nodeFilter.firstChild; + let strXMLF = getXMLNodeSerialisation(nTypeF); + let nColF=nodeFilter.firstChild; while(nColF != null) { if(nColF.nodeName==="column") { - var valF=getCdataValue(nColF); + let valF=getCdataValue(nColF); strXMLF=strXMLF.replace('${'+nColF.getAttribute('n')+'}', valF); } nColF = nColF.nextSibling; @@ -805,7 +836,7 @@ function SRec() }else { //Two elements are placed in the table - input = document.createElement('input'); + let input = document.createElement('input'); //After pressing Enter we pass the entered line to the server input.onkeydown=function(obj,val1,val2,val3,val4){ return function(e){ @@ -841,7 +872,7 @@ function SRec() //If the field is filled then we request the field header by its id if ((value!="")&&(value!=-1)) { - var xmlString=''; + let xmlString=''; if(this.request.callServer(ScriptName,xmlString,true)) { this.showProgressBar(); @@ -863,7 +894,7 @@ function SRec() td = document.createElement('td'); td.setAttribute("align","right"); - button = document.createElement('input'); + let button = document.createElement('input'); button.setAttribute("type","button"); button.setAttribute("value",_("Filtering")); button.setAttribute("id","btnfilter_"+this.uid); @@ -880,8 +911,8 @@ function SRec() if((count==0)||(h=0)) deleteHTML("idfilter"+this.uid); //Columns in which there are links to the array - var pos=0; - columnNode=this.nodeMetadataObjList.firstChild; + let pos=0; + let columnNode=this.nodeMetadataObjList.firstChild; while (columnNode != null) { @@ -903,15 +934,15 @@ function SRec() //this.sendFilter(id,0); this.sendFilter(-1,0); - }; + } /** The event occurs when you change the list of the referenced to "vt = Object" and if there is a dependency, then the field is updated. */ - this.onComboObjectChangeHandler = function(node) + onComboObjectChangeHandler(node) { //I go through the fields and if there is a configurable query, I ask the data again. - var nodeType=findFirstNode(this.nodeMetadata, "type"); - var nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); + let nodeType=findFirstNode(this.nodeMetadata, "type"); + let nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); if(nodeFilter!=null) //Create HTML elements by XML filter. { columnNode=nodeFilter.firstChild; @@ -919,7 +950,7 @@ function SRec() { if (columnNode.nodeName==="column") { - var nTypeF = findFirstNode(columnNode, "type"); + let nTypeF = findFirstNode(columnNode, "type"); if(nTypeF != null) { //Add parameters to request @@ -927,18 +958,18 @@ function SRec() nTypeF.setAttribute("pn",columnNode.getAttribute("n")); nTypeF.setAttribute("fn",columnNode.getAttribute("n")); - var strXMLF = getXMLNodeSerialisation(nTypeF); + let strXMLF = getXMLNodeSerialisation(nTypeF); if(strXMLF.indexOf('${'+node.getAttribute('n')+'}')!=-1) //If it does not participate then it does not react to the change. { - var nColF=nodeFilter.firstChild; + let nColF=nodeFilter.firstChild; while(nColF != null) { if(nColF.nodeName==="column") { - var elm=document.getElementById('filter_'+this.uid+'_'+nColF.getAttribute("n")); + let elm=document.getElementById('filter_'+this.uid+'_'+nColF.getAttribute("n")); if(elm!=null) { - var valF=elm.value; + let valF=elm.value; strXMLF=strXMLF.replace('${'+nColF.getAttribute('n')+'}', valF); } } @@ -964,7 +995,7 @@ function SRec() //id - id of record if it is necessary to return only the description, if -1 then it is not considered //value - filter value text field //htmlid - field name in filter n - this.callFilterVal=function(typeName,name,id,value,htmlid) + callFilterVal(typeName,name,id,value,htmlid) { if(value!="") { @@ -978,18 +1009,18 @@ function SRec() appendFilter(); this.sendFilter(-1,0); } - }; + } //Building a table header for the data - this.buildHead = function() + buildHead() { if(this.win!=null) this.win.setCaption(this.nodeMetadataObjList.getAttribute("d")); - var thetable = document.getElementById('thetable'+this.uid); + let thetable = document.getElementById('thetable'+this.uid); delChild(thetable.tHead); - var tr=document.createElement('tr'); + let tr=document.createElement('tr'); tr.style.cssText='background-color: #dadada;'; - var th=document.createElement('th'); + let th=document.createElement('th'); th.appendChild( document.createTextNode('№')); th.style.cssText='width: 1%;'; tr.appendChild(th); @@ -999,11 +1030,11 @@ function SRec() th.style.cssText='width: 1%; cursor: pointer; text-decoration: underline;'; th.onmouseover=function(){ this.style.backgroundColor='#C2D7FC'; }; th.onmouseout=function(){ this.style.backgroundColor='#dadada'; }; - th.onclick=function(thiz){return function(){ for(var i=0;i1) { - newRow=tablepages.insertRow(-1); + let newRow=tablepages.insertRow(-1); for(i=0;i=0) //Color from Result { bgColorT=findNodeOnNum(nodeRecord,"#cdata-section",nColor).nodeValue; if(bgColorT!="") bgColor=bgColorT; } - var id=nodeRecord.getAttribute("id"); + let id=nodeRecord.getAttribute("id"); //add rows to an existing record table - var tr = document.createElement('tr'); + let tr = document.createElement('tr'); tr.onmouseover=function(){this.setAttribute("bgColor","#C2D7FC");}; tr.onmouseout=function(val1,val2){return function(){val1.setAttribute("bgColor",val2);}}(tr,bgColor); tr.setAttribute("id",id+'_'+this.uid); tr.setAttribute("bgColor",bgColor); //sequential record number - var td = document.createElement('td'); + let td = document.createElement('td'); td.appendChild( document.createTextNode( i+100*this.pagepos ) ); tr.appendChild(td); @@ -1144,7 +1175,7 @@ function SRec() td.style.cssText="text-align: center;"; if(!(this.f_pD!="1" || nodeRecord.getAttribute("a").indexOf("d")==-1)) { - var checkbox = document.createElement('input'); + let checkbox = document.createElement('input'); this.masChBox.push(checkbox); //checkbox.disabled=true; checkbox.setAttribute("type","checkbox"); @@ -1155,23 +1186,23 @@ function SRec() tr.appendChild(td); //for each column we make a column - var i=0; //column number - cdataNode = nodeRecord.firstChild; + let colN=0; //column number + let cdataNode = nodeRecord.firstChild; while (cdataNode!=null) { if(cdataNode.nodeName=="#cdata-section") { - if(this.masVis[i]) + if(this.masVis[colN]) { td = document.createElement('td'); if((this.f_pU=="1")||(this.f_State=="1")){ td.style.cssText="cursor: pointer;"; } - textNode=document.createTextNode(cdataNode.nodeValue); - td.setAttribute("id",id+this.masCL[i].getAttribute("n")); //so that you can identify each record when you update + let textNode=document.createTextNode(cdataNode.nodeValue); + td.setAttribute("id",id+this.masCL[colN].getAttribute("n")); //so that you can identify each record when you update td.appendChild(textNode); //if in the metadata for this column there is a reference object then add a link - if (this.masCT[i]!=null) + if (this.masCT[colN]!=null) { //Opening a new window in the filter is passed to the current values of the row td.setAttribute("bgColor","#AAFFFF"); @@ -1212,13 +1243,13 @@ function SRec() } nodeRecord = nodeRecord.nextSibling; } - }; + } //by the column number, return the reference to the column node (numbering from 0) - this.getColumnOnNum=function(num) + getColumnOnNum(num) { - var i=0; - var fNodeProp = findFirstNode(this.nodeMetadata,"objects-list").firstChild; + let i=0; + let fNodeProp = findFirstNode(this.nodeMetadata,"objects-list").firstChild; while(fNodeProp != null) { if(fNodeProp.nodeName=="column") @@ -1229,12 +1260,13 @@ function SRec() fNodeProp=fNodeProp.nextSibling; } return null; - }; + } + //Name the column number - this.getColNumOnName=function(name) + getColNumOnName(name) { - var i=0; - var nn = findNode(this.nodeMetadata,"objects-list").firstChild; + let i=0; + let nn = findNode(this.nodeMetadata,"objects-list").firstChild; while (nn != null) { if(nn.nodeName=='column') @@ -1244,29 +1276,29 @@ function SRec() } nextNode=nextNode.nextSibling; } - }; + } //Call the ShowRecord.html window with the parameters for the filter (not just the object name) //id - id records from the database //col - Column Number - this.callWindow=function(id,col) + callWindow(id,col) { //we represent xml as a string and replace values of type $ {id} with values from the current record typeName=this.masCT[col].getAttribute("n"); - var xmlString=getXMLNodeSerialisation(this.masCT[col]); + let xmlString=getXMLNodeSerialisation(this.masCT[col]); while(true) { - var sub1=BeforeFirst(xmlString,"${"); + let sub1=BeforeFirst(xmlString,"${"); if(sub1==null) break; - var sub2=AfterFirst(xmlString,"}"); + let sub2=AfterFirst(xmlString,"}"); if(sub2==null) break; - var val=BeforeFirst(AfterFirst(xmlString,"${"),"}"); + let val=BeforeFirst(AfterFirst(xmlString,"${"),"}"); xmlString=sub1+this.getData(id,val)+sub2; } //We assign a string of the global variable so that we can take the infu from the child //Settings.add(0,xmlString) //wishWin = window.open("showrecord.html?name="+typeName,typeName,"width=800,height=600,menubar=no,location=no,resizable=yes,scrollbars=yes"); - var rec=new SRec(); + let rec=new SRec(); rec.create(); rec.f_Settings=xmlString; //rec.f_State=state; @@ -1278,16 +1310,16 @@ function SRec() { rec.showProgressBar(); } - }; + } //find the node cdata in the data by the record id and column name - this.getDataC=function(id,col) + getDataC(id,col) { - var i=0; - var b=false; + let i=0; + let b=false; //determine the sequence number of the column - var node=findNodeOnPath(this.nodeMetadata,"type/objects-list"); - var nodeCol = node.firstChild; + let node=findNodeOnPath(this.nodeMetadata,"type/objects-list"); + let nodeCol = node.firstChild; while (nodeCol != null) { if(nodeCol.nodeName=="column") @@ -1304,43 +1336,43 @@ function SRec() //we search for value in result set node=findFirstNode(this.f_nodeData, 'type'); - var nodeRec=findNodeOnAttribute(node, 'record', 'id', id); + let nodeRec=findNodeOnAttribute(node, 'record', 'id', id); return findNodeOnNum(nodeRec,"#cdata-section",i); - }; + } //find the value in the result set by the id of the record and the name of the column - this.getData=function(id,col) + getData(id,col) { if(findNode(this.nodeMetadata,'type').getAttribute("ObjectID")==col) return id; - var cdt=this.getDataC(id,col); + let cdt=this.getDataC(id,col); if(cdt!=null) return cdt.nodeValue; else return ''; - }; + } //look for a string by id and update the values (TODO consecutively without hidden fields) - this.updateRows=function(node) + updateRows(node) { //We sort through the received records and update the values - var nodeRecord = findNode(node,"type").firstChild + let nodeRecord = findNode(node,"type").firstChild while (nodeRecord != null) { if(nodeRecord.nodeName=="record") { - var ii=0; - var jj=0; - var id=nodeRecord.getAttribute("id"); - var tr=document.getElementById(id+'_'+this.uid); + let ii=0; + let jj=0; + let id=nodeRecord.getAttribute("id"); + let tr=document.getElementById(id+'_'+this.uid); if (tr==null) { this.insertRows(node,false); //If not then insert }else { - cdataNode = nodeRecord.firstChild; + let cdataNode = nodeRecord.firstChild; while (cdataNode!=null) { if (cdataNode.nodeName=="#cdata-section") { - var cd=this.getDataC(id,this.masCL[ii].getAttribute("n")); + let cd=this.getDataC(id,this.masCL[ii].getAttribute("n")); if(cd!=null) cd.nodeValue=cdataNode.nodeValue; if(this.masCL[ii].getAttribute("visible")!="0") @@ -1359,13 +1391,13 @@ function SRec() } nodeRecord = nodeRecord.nextSibling; } - }; + } //request data to fill the Object Filter //The result can fill the filter field with complete information or a window with a further choice of the value - this.SelectObjects=function(typeName,propname) + SelectObjects(typeName,propname) { - var rec=new SRec(); + let rec=new SRec(); rec.opener=this; rec.create(); rec.f_State=1; @@ -1381,20 +1413,20 @@ function SRec() //the filter is sent if not 1 value has come and much it is necessary to display a window with a choice of one of them //if the "..." button was pressed to display the showrecord.html window with the object selection mode //wishWin = window.open("showrecord.html?name="+typeName+"&state=1&propname="+propname,typeName+Math.floor(Math.random()*1000000),"width=800,height=600,menubar=no,location=no,resizable=yes,scrollbars=yes"); - }; + } - this.openPage=function(page) + openPage(page) { open(page); - }; + } - this.dataalert=function() + dataalert() { - var error_msg=""; + let error_msg=""; if (error_msg!="") alert("ShowRecords: \n"+error_msg); - }; + } - this.showreport=function(ext) + showreport(ext) { if(this.rwin!=null) this.rwin.Close(); @@ -1410,12 +1442,12 @@ function SRec() nodeType=findFirstNode(this.nodeMetadata, "type"); typename=nodeType.getAttribute("n"); nodeFilter=findNodeOnPath(nodeType,"objects-list/filter"); - var xs=''; + let xs=''; xs+='\n'; xs+='\n'; xs+=' \n'; xs+=' '; - var nextNode=nodeFilter.firstChild; + let nextNode=nodeFilter.firstChild; while(nextNode!=null) { if(nextNode.nodeName=="column") @@ -1433,31 +1465,31 @@ function SRec() { this.rwin.showProgressBar(); } - }; + } - this.chp=function(page) + chp(page) { //The current filter values are sent to the script to form a page change document.forms.filter.xml_page.value=page; document.forms.filter.submit(); - }; + } - this.insertRecord=function() + insertRecord() { - e = new EdtRec(""); - e.opener=this; - e.eRecNo(this.nodeMetadata,-1); - e.win.setParent(this.win); - }; + let erec = new EdtRec(""); + erec.opener=this; + erec.eRecNo(this.nodeMetadata,-1); + erec.win.setParent(this.win); + } - this.updateRecord=function(id) + updateRecord(id) { if(this.f_State=="0") //editing { - e = new EdtRec(""); - e.win.setParent(this.win); - e.opener=this; - e.eRecNo(this.nodeMetadata,id); + let erec = new EdtRec(""); + erec.win.setParent(this.win); + erec.opener=this; + erec.eRecNo(this.nodeMetadata,id); //e.win.setLeftTop(pageX-10,pageY-10); }else @@ -1471,14 +1503,14 @@ function SRec() if(this.f_State=="2") //Multiple choice (on the records of ticking TODO is not implemented) { } - }; + } //We run through the marked records and request their removal - this.deleteRecord=function(recordid) + deleteRecord(recordid) { if (confirm(_("Are_you_sure_you_want_to_delete_the_entries")+'?')) { - for(var i=0;i n attribute) - //this.record_id=-1; //from here the form of editing takes the values id after its loading - this.f_Settings=""; //XML that is superimposed on the current node Metadata - this.f_pI=0; this.f_pU=0; this.f_pD=0; this.f_pS=0; //rights - this.nodeMetadata=null; //accepted metadata - this.nodeMetadataObjList=null; - this.f_nodeData=null; //received data, hidden fields - this.masCT=new Array();//parameter table for cells - 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 - this.pBarDiv=null; //Progress bar - - this.name=""; - - this.uid=getUID(); - this.request = new TRequest(this); - SRec_mas[this.uid]=this; } //Convert XML to array function nodeToTable(node) { - var result=new Array(); + let result=new Array(); - var nType=findFirstNode(node, "type"); + let nType=findFirstNode(node, "type"); //Read name fields - var nList=findFirstNode(node, "objects-list"); - var cols=new Array(); - var pos=0; - var nCols=nList.firstChild; + let nList=findFirstNode(node, "objects-list"); + let cols=new Array(); + let pos=0; + let nCols=nList.firstChild; while(nCols != null) { if(nCols.nodeName=="column") @@ -1571,13 +1576,13 @@ function nodeToTable(node) } pos=0; //Line number - var nRecord = nType.firstChild; + let nRecord = nType.firstChild; while(nRecord != null) { if(nRecord.nodeName=="record") { result[pos]['id']=nRecord.getAttribute("id"); - var i=0; //column number + let i=0; //column number cdataNode = nRecord.firstChild; while (cdataNode!=null) diff --git a/metadata/tree/tree.php b/metadata/tree/tree.php index 75335fe..9e4ff1e 100644 --- a/metadata/tree/tree.php +++ b/metadata/tree/tree.php @@ -16,8 +16,7 @@ /** * Отправить клиенту информацию о ошибке - * @param type $e - Наименование ошибки - * @param type $winid - Идентификатор окна + * @param String $e - Наименование ошибки */ function sendError($e) { @@ -29,8 +28,8 @@ /** * Взять данные из базы данных в результсет - * @param unknown_type $treeNode - DOM узел переданной клиентом - * @param unknown_type $currNode - DOM узел из файла tree.xml параметрам фильтра которого будут присвоенны значения из treeNode (недостающие фильтры возтмуться из nodeMetadata) + * @param Node $treeNode - DOM узел переданной клиентом + * @param Node $currNode - DOM узел из файла tree.xml параметрам фильтра которого будут присвоенны значения из treeNode (недостающие фильтры возтмуться из nodeMetadata) * @return PDOStatement|NULL Результ-сет */ function fnGetData($treeNode,$currNode)