Сохранение настроек фильтра при нажатии на ...

This commit is contained in:
2022-01-24 15:38:12 +06:00
parent 6258a39b12
commit d9cd847bb4
6 changed files with 188 additions and 115 deletions

View File

@ -92,10 +92,10 @@ class SRec
{
if ((xmlStr!=null)&&(xmlStr!=""))
{
xmlDOC=CreateXMLDOC(xmlStr);
let xmlDOC=CreateXMLDOC(xmlStr);
//let nPFilter=findFirstNode(xmlDOC,"filter")
let nPFilter=findNodeOnPath(xmlDOC.documentElement,"type/objects-list/filter");
nPColumn=nPFilter.firstChild;
let nPColumn=nPFilter.firstChild;
while (nPColumn != null)
{
if(nPColumn.nodeName=="column")
@ -156,6 +156,7 @@ class SRec
<table style="width:100%;"><tr><td><img src="../resources/metadata/dbms/images/rplus.png" alt="add" id="SRec_Add_'+this.uid+'" title="'+trt('Add_record')+'" style="cursor: pointer;"/></td>\
<td><img src="../resources/metadata/dbms/images/rdel.png" alt="del" id="SRec_Del_'+this.uid+'" title="'+trt('Delete_record')+'" style="cursor: pointer;"/></td>\
<td><img src="../resources/metadata/dbms/images/excel.png" alt="excel" id="SRec_Exc_'+this.uid+'" title="'+trt('Export_to_Excel')+'" style="cursor: pointer;"/></td>\
<td style="white-space: nowrap; padding-left: 10px;"><label style="display:none;"><input type="checkbox" id="Selection_'+this.uid+'" checked> '+trt('Selection_mode')+'</label></td>\
<td style="width: 99%;">&nbsp;</td>\
<td><img src="../resources/metadata/dbms/images/config.png" alt="'+trt('Settings')+'" id="SRec_Cnf_'+this.uid+'" title="'+trt('Settings')+'" style="cursor: pointer;"/></td>\
<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>\
@ -387,29 +388,49 @@ class SRec
}
}
//we pass the id to the object filter prop_id - the name of the filter
setFilterObject(TypeName, prop_id, id)
//we pass the id to the object filter column_n - the name of the filter
setFilterObject(TypeName, column_n, id, filter)
{
let node=findFirstNodeOnAttribute(this.nodeMetadata,'column','n',prop_id);
if(node!=null)
let node=findFirstNodeOnAttribute(this.nodeMetadata,'column','n',column_n);
if(node!==null)
{
let name=node.getAttribute("FieldCaption");
getCdata(node).nodeValue=id;
//we request data from the server to fill in the comments on the record id
let prop=document.getElementById('filter_'+this.uid+'_'+prop_id);
if(prop!=null) prop.value=id;
//request comment on the id of the record from the server
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+TypeName+'" c="'+name+'" pn="'+prop_id+'" fn="'+name+'"><objects-list><filter><column n="id"><![CDATA['+id+']]></column></filter></objects-list></type></metadata>',true))
let prop=document.getElementById('filter_'+this.uid+'_'+column_n);
if(prop!==null) {
prop.value = id;
}
//Request a comment on the record id from the server
let xml = '';
if(filter!=''){
//Настройка для последующего вызова
xml='<column n="'+column_n+'"><type n="' + TypeName + '"><objects-list>'+filter+'</objects-list></type></column>';
applyNodeToNode(CreateXMLDOC(xml).documentElement, node, "n");
//Настройка для фильтрации списка
xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<metadata fn="6"><type n="' + TypeName + '" c="' + name + '" pn="' + column_n + '" fn="' + name + '">' +
'<objects-list>' + filter + '</objects-list>' +
'</type></metadata>';
}else{
xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<metadata fn="6"><type n="' + TypeName + '" c="' + name + '" pn="' + column_n + '" fn="' + name + '">' +
'<objects-list><filter><column n="id"><![CDATA[' + id + ']]></column></filter></objects-list>' +
'</type></metadata>';
}
if(this.request.callServer(ScriptName,xml,true))
{
this.showProgressBar();
}
}else
{
alert2(trt('Alert'),'Filter "'+prop_id+'" not find!');
alert2(trt('Alert'),'Filter "'+column_n+'" not find!');
}
}
//The function to collect data from HTML fields in XML
//The function to collect data from HTML fields in to XML
appendFilter()
{
let nodeType=findFirstNode(this.nodeMetadata, "type");
@ -953,6 +974,10 @@ class SRec
}
if((count==0)||(h=0)) deleteHTML("idfilter"+this.uid);
if(this.f_State>0){
document.getElementById('Selection_'+this.uid).parentNode.style.display = "block";
}
//Columns in which there are links to the array
let pos=0;
let columnNode=this.nodeMetadataObjList.firstChild;
@ -1325,7 +1350,38 @@ class SRec
}
}
//Call the ShowRecord.html window with the parameters for the filter (not just the object name)
//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)
{
let rec=new SRec();
rec.opener=this;
rec.create();
rec.f_State=1;
rec.f_PropName=propname;
rec.f_TypeName=typeName;
rec.win.setCenter(); //rec.win.setLeftTop(pageX-250,pageY-10);
rec.win.setParent(this.win);
let settings="";
let node=findNodeOnPath(this.nodeMetadata, "type/objects-list/filter/column[@n='"+propname+"']/type");
if(node!=null){
settings=getXMLNodeSerialisation(node);
console.log("settings = "+settings);
}
rec.callData(rec.f_TypeName,settings);
//if(rec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+rec.f_TypeName+'"></type></metadata>'))
//{
// rec.showProgressBar();
//}
//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");
}
//Call the ShowRecord window with the parameters for the filter (not just the object name)
//id - id records from the database
//col - Column Number
callWindow(id,col)
@ -1440,28 +1496,6 @@ class SRec
}
}
//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)
{
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,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+rec.f_TypeName+'"></type></metadata>'))
{
rec.showProgressBar();
}
//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");
}
openPage(page)
{
open(page);
@ -1533,19 +1567,36 @@ class SRec
{
if(this.f_State=="0") //editing
{
let erec = new EdtRec("");
erec.win.setParent(this.win);
erec.opener=this;
erec.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
if(this.f_State=="1") //select one record
{
//Send the id of the selected record to the parent of the selected record and close the window
//alert2(trt('Alert'),"id="+id+" f_PropName="+this.f_PropName+" f_TypeName="+this.f_TypeName);
this.opener.setFilterObject(this.f_TypeName,this.f_PropName,id);
this.win.Close();
if(document.getElementById('Selection_'+this.uid).checked) {
//this.appendFilter(); //To write filter fields in XML
let filter="";
let nodeType=findFirstNode(this.nodeMetadata, "type");
let nodeFilter=findNodeOnPath(nodeType,"objects-list/filter");
if (nodeFilter!=null)
{
filter=getXMLNodeSerialisation(nodeFilter)
}
//Send the id of the selected record to the parent of the selected record and close the window
//alert2(trt('Alert'),"id="+id+" f_PropName="+this.f_PropName+" f_TypeName="+this.f_TypeName);
this.opener.setFilterObject(this.f_TypeName, this.f_PropName, id, filter);
this.win.Close();
}else{
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
if(this.f_State=="2") //Multiple choice (on the records of ticking TODO is not implemented)
{