|
@@ -19,6 +19,8 @@ function print(msg){
|
|
}
|
|
}
|
|
|
|
|
|
function makeQuery(containerName,queryName,fieldName,filterArray){
|
|
function makeQuery(containerName,queryName,fieldName,filterArray){
|
|
|
|
+ //generates an instruction entry that looks up queryName from container and stores
|
|
|
|
+ //the resulting table to fieldName potentially using filterArray
|
|
let e=new Object();
|
|
let e=new Object();
|
|
e.containerName=containerName;
|
|
e.containerName=containerName;
|
|
e.queryName=queryName;
|
|
e.queryName=queryName;
|
|
@@ -221,7 +223,7 @@ function generateSetup(){
|
|
return setup;
|
|
return setup;
|
|
}
|
|
}
|
|
|
|
|
|
-function fullAccessSetup(listName){
|
|
|
|
|
|
+function fullAccessSetup(sectionId,listName){
|
|
//generate setup object whcih should contain fields:
|
|
//generate setup object whcih should contain fields:
|
|
//readonlyFlag - whether the dataset is writeable
|
|
//readonlyFlag - whether the dataset is writeable
|
|
//filters - selection fields that allow creation of LABKEY.Filter.create()
|
|
//filters - selection fields that allow creation of LABKEY.Filter.create()
|
|
@@ -237,14 +239,15 @@ function fullAccessSetup(listName){
|
|
setup.readonlyFlag=function(vName){return false};
|
|
setup.readonlyFlag=function(vName){return false};
|
|
setup.filters=new Object();
|
|
setup.filters=new Object();
|
|
setup.filters['crfRef']=getCRFref();
|
|
setup.filters['crfRef']=getCRFref();
|
|
- setup.getInputId=function(vName){return listName+"_"+vName;}
|
|
|
|
|
|
+ setup.getInputId=function(vName){return sectionId+"_"+vName;}
|
|
setup.addApply="Save";
|
|
setup.addApply="Save";
|
|
setup.isReview=false;
|
|
setup.isReview=false;
|
|
|
|
+ setup.sectionId=sectionId;
|
|
return setup;
|
|
return setup;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-function readonlySetup(listName){
|
|
|
|
|
|
+function readonlySetup(sectionId,listName){
|
|
//see definition of setup object above
|
|
//see definition of setup object above
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug) print("readonlySetup");
|
|
if (debug) print("readonlySetup");
|
|
@@ -254,22 +257,23 @@ function readonlySetup(listName){
|
|
setup.readonlyFlag=function(vName){return true};
|
|
setup.readonlyFlag=function(vName){return true};
|
|
setup.filters=new Object();
|
|
setup.filters=new Object();
|
|
setup.filters['crfRef']=getCRFref();
|
|
setup.filters['crfRef']=getCRFref();
|
|
- setup.getInputId=function(vName){return listName+'_'+vName;}
|
|
|
|
|
|
+ setup.getInputId=function(vName){return sectionId+'_'+vName;}
|
|
setup.isReview=false;
|
|
setup.isReview=false;
|
|
|
|
+ setup.sectionId=sectionId;
|
|
return setup;
|
|
return setup;
|
|
}
|
|
}
|
|
|
|
|
|
-function getSetup(listName,writeAccess=true){
|
|
|
|
|
|
+function getSetup(sectionId,listName,writeAccess=true){
|
|
//change to section granulated permission of type EDIT, COMMENT, READ
|
|
//change to section granulated permission of type EDIT, COMMENT, READ
|
|
//let formStatus=config.formConfig.formStatus;
|
|
//let formStatus=config.formConfig.formStatus;
|
|
//equivalent to READ
|
|
//equivalent to READ
|
|
|
|
|
|
if (!writeAccess)
|
|
if (!writeAccess)
|
|
//if (formStatus=="Submitted")
|
|
//if (formStatus=="Submitted")
|
|
- return readonlySetup(listName);
|
|
|
|
|
|
+ return readonlySetup(sectionId,listName);
|
|
//if (formStatus=="Approved")
|
|
//if (formStatus=="Approved")
|
|
// return readonlySetup(listName);
|
|
// return readonlySetup(listName);
|
|
- return fullAccessSetup(listName);
|
|
|
|
|
|
+ return fullAccessSetup(sectionId,listName);
|
|
}
|
|
}
|
|
|
|
|
|
function parseVariableDefinition(formSetupEntry){
|
|
function parseVariableDefinition(formSetupEntry){
|
|
@@ -292,13 +296,30 @@ function parseVariableDefinition(formSetupEntry){
|
|
return vars;
|
|
return vars;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function setHelp(setup,formSetupEntry){
|
|
|
|
+ let helpRows=config.formConfig.help.rows;
|
|
|
|
+ for (let i=0;i<helpRows.length;i++){
|
|
|
|
+ let eh=helpRows[i];
|
|
|
|
+ if (eh['query']==formSetupEntry['queryName']){
|
|
|
|
+ if (!("help" in setup)){
|
|
|
|
+ setup["help"]=new Object();
|
|
|
|
+ setup["help"].rows=new Array();
|
|
|
|
+ }
|
|
|
|
+ setup["help"].rows.push(eh);
|
|
|
|
+ print('Adding help to '+config.formConfig.queryMap[eh['query']]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //this updates setup
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
function generateSection(formSetupEntry){
|
|
function generateSection(formSetupEntry){
|
|
|
|
|
|
//generates a (hideable) section according to setup in formEntrySetup
|
|
//generates a (hideable) section according to setup in formEntrySetup
|
|
|
|
|
|
let listName=config.formConfig.queryMap[formSetupEntry['queryName']];
|
|
let listName=config.formConfig.queryMap[formSetupEntry['queryName']];
|
|
- let fName='[generateSection/'+listName+']';
|
|
|
|
|
|
+ let sectionId='section'+formSetupEntry['Key'];
|
|
|
|
+ let fName='[generateSection/'+listName+'/'+sectionId+']';
|
|
let sectionTitle=formSetupEntry['title'];
|
|
let sectionTitle=formSetupEntry['title'];
|
|
let accessModeColumn=config.formConfig.operator+'Mode';
|
|
let accessModeColumn=config.formConfig.operator+'Mode';
|
|
let accessMode=formSetupEntry[accessModeColumn];
|
|
let accessMode=formSetupEntry[accessModeColumn];
|
|
@@ -322,24 +343,26 @@ function generateSection(formSetupEntry){
|
|
let input=config.document.createElement("input");
|
|
let input=config.document.createElement("input");
|
|
input.type="button";
|
|
input.type="button";
|
|
input.value="Show";
|
|
input.value="Show";
|
|
- input.id="toggle"+listName+"VisbilityButton";
|
|
|
|
- input.onclick=function(){toggleVisibility(listName,input.id)};
|
|
|
|
|
|
+ input.id="toggle"+sectionId+"VisbilityButton";
|
|
|
|
+ input.onclick=function(){toggleVisibility(sectionId,input.id)};
|
|
|
|
+ //toggleVisibilityArgumentList changed!
|
|
cell.appendChild(input);
|
|
cell.appendChild(input);
|
|
config.document.getElementById(formName).appendChild(tb);
|
|
config.document.getElementById(formName).appendChild(tb);
|
|
|
|
|
|
let div=config.document.createElement('div');
|
|
let div=config.document.createElement('div');
|
|
- div.id=listName;
|
|
|
|
|
|
+ //relabel this to allow multiple entries for the same list
|
|
|
|
+ div.id=sectionId;
|
|
div.style.display="none";
|
|
div.style.display="none";
|
|
config.document.getElementById(formName).appendChild(div);
|
|
config.document.getElementById(formName).appendChild(div);
|
|
|
|
|
|
let divTable=config.document.createElement('div');
|
|
let divTable=config.document.createElement('div');
|
|
- divTable.id=listName+"Table";
|
|
|
|
|
|
+ divTable.id=sectionId+"Table";
|
|
div.appendChild(divTable);
|
|
div.appendChild(divTable);
|
|
|
|
|
|
if ("showFlag" in additionalData) {
|
|
if ("showFlag" in additionalData) {
|
|
|
|
|
|
- additionalData.divName=listName+"SubDiv";
|
|
|
|
- additionalData.divQueryName=listName+"SubDivList";
|
|
|
|
|
|
+ additionalData.divName=sectionId+"SubDiv";
|
|
|
|
+ additionalData.divQueryName=sectionId+"SubDivList";
|
|
|
|
|
|
let div1=config.document.createElement('div');
|
|
let div1=config.document.createElement('div');
|
|
div1.id=additionalData.divName;
|
|
div1.id=additionalData.divName;
|
|
@@ -364,10 +387,12 @@ function generateSection(formSetupEntry){
|
|
}
|
|
}
|
|
//master table is unique per visit
|
|
//master table is unique per visit
|
|
|
|
|
|
- let setup=getSetup(listName,writeMode);
|
|
|
|
|
|
+ let setup=getSetup(sectionId,listName,writeMode);
|
|
|
|
|
|
setup.unique=true;
|
|
setup.unique=true;
|
|
|
|
|
|
|
|
+ setHelp(setup,formSetupEntry);
|
|
|
|
+
|
|
//set variables from formSetup variableDefinition field
|
|
//set variables from formSetup variableDefinition field
|
|
//to setup.setVariables
|
|
//to setup.setVariables
|
|
setup.setVariables=parseVariableDefinition(formSetupEntry);
|
|
setup.setVariables=parseVariableDefinition(formSetupEntry);
|
|
@@ -392,7 +417,7 @@ function generateSection(formSetupEntry){
|
|
let dName=additionalData.divName;
|
|
let dName=additionalData.divName;
|
|
|
|
|
|
|
|
|
|
- let subSetup=fullAccessSetup(qName);
|
|
|
|
|
|
+ let subSetup=fullAccessSetup(sectionId,qName);
|
|
//only set master query for additionalData
|
|
//only set master query for additionalData
|
|
subSetup.masterQuery=listName;
|
|
subSetup.masterQuery=listName;
|
|
//if (readonly) setup=readonlySetup(config);
|
|
//if (readonly) setup=readonlySetup(config);
|
|
@@ -403,11 +428,11 @@ function generateSection(formSetupEntry){
|
|
print(fName+" generate review");
|
|
print(fName+" generate review");
|
|
|
|
|
|
let divReviewList=config.document.createElement('div');
|
|
let divReviewList=config.document.createElement('div');
|
|
- divReviewList.id=listName+"ReviewList";
|
|
|
|
|
|
+ divReviewList.id=sectionId+"ReviewList";
|
|
div.appendChild(divReviewList);
|
|
div.appendChild(divReviewList);
|
|
|
|
|
|
let divReview=config.document.createElement('div');
|
|
let divReview=config.document.createElement('div');
|
|
- divReview.id=listName+"Review";
|
|
|
|
|
|
+ divReview.id=sectionId+"Review";
|
|
div.appendChild(divReview);
|
|
div.appendChild(divReview);
|
|
|
|
|
|
|
|
|
|
@@ -415,6 +440,7 @@ function generateSection(formSetupEntry){
|
|
//we need listName also
|
|
//we need listName also
|
|
//qconfig.queryName=config.setupQueryName;
|
|
//qconfig.queryName=config.setupQueryName;
|
|
generateReview(divReview.id,divReviewList.id,listName,accessMode);
|
|
generateReview(divReview.id,divReviewList.id,listName,accessMode);
|
|
|
|
+ //generateReview depends on listName
|
|
|
|
|
|
print(fName+" generate review complete");
|
|
print(fName+" generate review complete");
|
|
|
|
|
|
@@ -422,7 +448,7 @@ function generateSection(formSetupEntry){
|
|
print('Adding generate button');
|
|
print('Adding generate button');
|
|
//add generateButton
|
|
//add generateButton
|
|
let divGenerateButton=config.document.createElement('div');
|
|
let divGenerateButton=config.document.createElement('div');
|
|
- divGenerateButton.id=listName+'GenerateButton';
|
|
|
|
|
|
+ divGenerateButton.id=sectionId+'GenerateButton';
|
|
div.appendChild(divGenerateButton);
|
|
div.appendChild(divGenerateButton);
|
|
print('Adding generate button completed to here');
|
|
print('Adding generate button completed to here');
|
|
let cb=function(){onGenerateQuery(listName);};
|
|
let cb=function(){onGenerateQuery(listName);};
|
|
@@ -971,18 +997,17 @@ function updateFailure(data){
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//TODO: this should trigger a data refresh on section, ie populateData(field)
|
|
|
|
-function toggleVisibility(divName,buttonName){
|
|
|
|
- let fName='[toggleVisibility/'+divName+']';
|
|
|
|
|
|
+function toggleVisibility(sectionId,buttonName){
|
|
|
|
+ let fName='[toggleVisibility/'+sectionId+']';
|
|
print(fName);
|
|
print(fName);
|
|
|
|
|
|
- let x = config.document.getElementById(divName);
|
|
|
|
|
|
+ let x = config.document.getElementById(sectionId);
|
|
if (x.style.display === "none") {
|
|
if (x.style.display === "none") {
|
|
//exclude non data sections (like debug)...
|
|
//exclude non data sections (like debug)...
|
|
print(fName+': issuing setData(populateSection)');
|
|
print(fName+': issuing setData(populateSection)');
|
|
x.style.display = "block";
|
|
x.style.display = "block";
|
|
config.document.getElementById(buttonName).value="Hide";
|
|
config.document.getElementById(buttonName).value="Hide";
|
|
- let cb=function(){populateSection(divName);};
|
|
|
|
|
|
+ let cb=function(){populateSection(sectionId);};
|
|
setData(cb);
|
|
setData(cb);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -1354,6 +1379,8 @@ function populateField(entry,field,setup){
|
|
//figure out the element type
|
|
//figure out the element type
|
|
let eType=input.nodeName.toLowerCase();
|
|
let eType=input.nodeName.toLowerCase();
|
|
print('Element type: '+eType);
|
|
print('Element type: '+eType);
|
|
|
|
+ print('Value '+varValue);
|
|
|
|
+
|
|
|
|
|
|
//change varValue for printing
|
|
//change varValue for printing
|
|
if (varValue=="UNDEF") varValue="";
|
|
if (varValue=="UNDEF") varValue="";
|
|
@@ -1411,7 +1438,7 @@ function populateField(entry,field,setup){
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-function populateTable(listName,writeMode,setup=undefined){
|
|
|
|
|
|
+function populateTable(listName,writeMode,setup){
|
|
//function populateTable(formSetupEntry){
|
|
//function populateTable(formSetupEntry){
|
|
//let listName=config.formConfig.queryMap[formSetupEntry['queryName']];
|
|
//let listName=config.formConfig.queryMap[formSetupEntry['queryName']];
|
|
//let accessMode=config.formConfig.operator+'Mode';
|
|
//let accessMode=config.formConfig.operator+'Mode';
|
|
@@ -1419,10 +1446,6 @@ function populateTable(listName,writeMode,setup=undefined){
|
|
|
|
|
|
let fName='[populateTable/'+listName+']';
|
|
let fName='[populateTable/'+listName+']';
|
|
print(fName+' setup '+setup);
|
|
print(fName+' setup '+setup);
|
|
- if (setup==undefined){
|
|
|
|
- print(fName+' generating default setup');
|
|
|
|
- setup=getSetup(listName,writeMode);
|
|
|
|
- }
|
|
|
|
|
|
|
|
//data snapshot
|
|
//data snapshot
|
|
let fQuery=config.formConfig.dataQueries[listName];
|
|
let fQuery=config.formConfig.dataQueries[listName];
|
|
@@ -1436,19 +1459,151 @@ function populateTable(listName,writeMode,setup=undefined){
|
|
let entry=selectEntry(fQuery.rows,setup.setVariables);
|
|
let entry=selectEntry(fQuery.rows,setup.setVariables);
|
|
|
|
|
|
let fields=fQuery.fields;
|
|
let fields=fQuery.fields;
|
|
-
|
|
|
|
|
|
+ let helpRows=new Array();
|
|
|
|
+
|
|
for (f in fields){
|
|
for (f in fields){
|
|
let field=fields[f];
|
|
let field=fields[f];
|
|
//each field is a new row
|
|
//each field is a new row
|
|
print(fName+": Adding field: "+f+'/'+field.name+' hidden: '+field.hidden);
|
|
print(fName+": Adding field: "+f+'/'+field.name+' hidden: '+field.hidden);
|
|
if (field.hidden) continue;
|
|
if (field.hidden) continue;
|
|
if (field.name=="crfRef") continue;
|
|
if (field.name=="crfRef") continue;
|
|
- populateFieldRow(entry,field,setup);
|
|
|
|
-
|
|
|
|
|
|
+ if (field.name in setup.setVariables) continue;
|
|
|
|
+ populateFieldRow(entry,field,setup);
|
|
|
|
+ let helpItem=getHelpItem(field,setup);
|
|
|
|
+ if (helpItem) helpRows.push(helpItem);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ populateHelp(listName,helpRows,setup);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function getHelpVar(queryName,code,setup){
|
|
|
|
+ let fName='[getHelpVar('+code+')]';
|
|
|
|
+
|
|
|
|
+ let subs=code.match(/_[^_]*_/g);
|
|
|
|
+ if (!subs){
|
|
|
|
+ print(fName+' no match for '+code);
|
|
|
|
+ return code;
|
|
|
|
+ }
|
|
|
|
+ let rpc=new Object();
|
|
|
|
+ for (let i=0;i<subs.length;i++){
|
|
|
|
+ let c=subs[i].replace(/_/g,'');
|
|
|
|
+ let qf=c.match(/\[[^\]]*\]/g);
|
|
|
|
+ let lField=undefined;
|
|
|
|
+ if (qf){
|
|
|
|
+ qf[0]=qf[0].replace(/[\[\]]/g,'');
|
|
|
|
+ lField=qf[0];
|
|
|
|
+ }
|
|
|
|
+ //drop field
|
|
|
|
+ c=c.replace(/\[[^\]]*\]/,'');
|
|
|
|
+
|
|
|
|
+ //field in lookup (if not lookup.keyColumn)
|
|
|
|
+ //query
|
|
|
|
+ let query=queryName;
|
|
|
|
+ let vField=c;
|
|
|
|
+ let qq=c.split(':');
|
|
|
|
+ if (qq.length>1){
|
|
|
|
+ query=qq[0];
|
|
|
|
+ vField=qq[1];
|
|
|
|
+ }
|
|
|
|
+ let value='';
|
|
|
|
+ if (vField in setup.setVariables){
|
|
|
|
+ value=setup.setVariables[vField];
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ value=config.formConfig.dataQueries[query].rows[0][vField];
|
|
|
|
+ }
|
|
|
|
+ if (lField==undefined){
|
|
|
|
+ rpc[subs[i]]=value;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ let fQuery=config.formConfig.dataQueries[query];
|
|
|
|
+ //variable vField must be a lookup
|
|
|
|
+ //let field=fQuery.fields[vField];
|
|
|
|
+ let field=undefined;
|
|
|
|
+ for (let f in fQuery.fields){
|
|
|
|
+ if (fQuery.fields[f].name==vField){
|
|
|
|
+ field=fQuery.fields[f];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let lookup=config.formConfig.lookup[field.lookup.queryName];
|
|
|
|
+
|
|
|
|
+ for (let j=0;j<lookup.rows.length;j++){
|
|
|
|
+ let o=lookup.rows[j];
|
|
|
|
+ if (o[lookup.keyColumn]==value){
|
|
|
|
+ rpc[subs[i]]=o[lField];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (let x in rpc){
|
|
|
|
+ code=code.replace(x,rpc[x]);
|
|
|
|
+ }
|
|
|
|
+ print('Returning '+code);
|
|
|
|
+ return code;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getHelpItem(field,setup){
|
|
|
|
+ if (!("help" in setup)) return undefined;
|
|
|
|
+
|
|
|
|
+ let fName='[getHelpItem]';
|
|
|
|
+ print(fName);
|
|
|
|
+
|
|
|
|
+ for (let i=0;i<setup["help"].rows.length;i++){
|
|
|
|
+ if (setup["help"].rows[i]["variable"]==field.name){
|
|
|
|
+ helpItem=new Object();
|
|
|
|
+ helpItem.setup=setup["help"].rows[i];
|
|
|
|
+ helpItem.field=field;
|
|
|
|
+ print(fName+' adding help for '+field.name);
|
|
|
|
+ return helpItem;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return undefined;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function generateHelp(tb,helpRows,setup){
|
|
|
|
+ let fName='[generateHelp]';
|
|
|
|
+ for (let i=0; i<helpRows.length; i++){
|
|
|
|
+ let eh=helpRows[i];
|
|
|
|
+ let row=tb.insertRow();
|
|
|
|
+ let th=config.document.createElement('th');
|
|
|
|
+ row.appendChild(th);
|
|
|
|
+ th.innerHTML=eh.setup['helpTitle'];
|
|
|
|
+ let cell=row.insertCell();
|
|
|
|
+ cell.setAttribute('colspan','3');
|
|
|
|
+ let el=config.document.createElement('textarea');
|
|
|
|
+ //el.id=sectionId+'_help';
|
|
|
|
+ el.cols="70";
|
|
|
|
+ el.rows="10";
|
|
|
|
+ el.value="Loading";
|
|
|
|
+ el.id=setup.sectionId+"_help"+eh.setup['Key'];
|
|
|
|
+ print(fName+' creating '+el.id);
|
|
|
|
+ cell.appendChild(el);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function populateHelp(listName,helpRows,setup){
|
|
|
|
+ let fName='[populateHelp]';
|
|
|
|
+ for (let i=0; i<helpRows.length; i++){
|
|
|
|
+ let eh=helpRows[i];
|
|
|
|
+ let lookup=eh.field['lookup'];
|
|
|
|
+ let qName=lookup.queryName;
|
|
|
|
+ let tLookup=config.formConfig.lookup[qName];
|
|
|
|
+ let varName=getHelpVar(listName,eh.setup['fieldDescriptor'],setup);
|
|
|
|
+ let text="";
|
|
|
|
+ for (let j=0;j<tLookup.rows.length;j++){
|
|
|
|
+ print(tLookup.rows[j][tLookup.keyColumn]+' '+tLookup.rows[j][tLookup.displayColumn]+
|
|
|
|
+ ' '+tLookup.rows[j][varName]);
|
|
|
|
+ text+=tLookup.rows[j][tLookup.displayColumn]+" - "+tLookup.rows[j][varName]+"\n";
|
|
|
|
+ }
|
|
|
|
+ let id=setup.sectionId+'_help'+eh.setup['Key']
|
|
|
|
+ let el=config.document.getElementById(id);
|
|
|
|
+ print(fName+' setting '+id+': '+el);
|
|
|
|
+ el.value=text;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
function generateTable(listName,divName,additionalData,setup){
|
|
function generateTable(listName,divName,additionalData,setup){
|
|
let debug=true;
|
|
let debug=true;
|
|
let fName="[generateTable/"+listName+"]";
|
|
let fName="[generateTable/"+listName+"]";
|
|
@@ -1475,7 +1630,8 @@ function generateTable(listName,divName,additionalData,setup){
|
|
|
|
|
|
//this are the fields (probably constant)
|
|
//this are the fields (probably constant)
|
|
let fields=fQuery.fields;
|
|
let fields=fQuery.fields;
|
|
-
|
|
|
|
|
|
+ let helpRows=new Array();
|
|
|
|
+
|
|
for (f in fields){
|
|
for (f in fields){
|
|
let field=fields[f];
|
|
let field=fields[f];
|
|
//each field is a new row
|
|
//each field is a new row
|
|
@@ -1486,11 +1642,17 @@ function generateTable(listName,divName,additionalData,setup){
|
|
if (field.name in setup.setVariables) continue;
|
|
if (field.name in setup.setVariables) continue;
|
|
addFieldRow(tb,field,setup,additionalData);
|
|
addFieldRow(tb,field,setup,additionalData);
|
|
populateFieldRow(entry,field,setup);
|
|
populateFieldRow(entry,field,setup);
|
|
-
|
|
|
|
|
|
+ let helpItem=getHelpItem(field,setup);
|
|
|
|
+ if (helpItem) helpRows.push(helpItem);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ generateHelp(tb,helpRows,setup);
|
|
|
|
+ populateHelp(listName,helpRows,setup);
|
|
|
|
+
|
|
|
|
+
|
|
//add comment field
|
|
//add comment field
|
|
if (!("addApply" in setup)) {
|
|
if (!("addApply" in setup)) {
|
|
- print(fName+"populateTable: done");
|
|
|
|
|
|
+ print(fName+"generateTable: done");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2699,28 +2861,32 @@ function afterData(){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-function findSetupRow(queryName){
|
|
|
|
|
|
+function findSetupRow(sectionId){
|
|
let rowsSetup=config.formConfig.formSetupRows;
|
|
let rowsSetup=config.formConfig.formSetupRows;
|
|
|
|
+ let key=sectionId.replace('section','');
|
|
for (let i=0;i<rowsSetup.length;i++){
|
|
for (let i=0;i<rowsSetup.length;i++){
|
|
let e=rowsSetup[i];
|
|
let e=rowsSetup[i];
|
|
- let queryName1=config.formConfig.queryMap[e['queryName']];
|
|
|
|
|
|
+ //let queryName1=config.formConfig.queryMap[e['queryName']];
|
|
if (e.formName!=config.formId) continue;
|
|
if (e.formName!=config.formId) continue;
|
|
- if (queryName1!=queryName) continue;
|
|
|
|
- return e;
|
|
|
|
|
|
+ if (e['Key']==key) return e;
|
|
|
|
+ //if (queryName1!=queryName) continue;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
-function populateSection(queryName){
|
|
|
|
- let fName='[populateSection/'+queryName+']';
|
|
|
|
|
|
+function populateSection(sectionId){
|
|
|
|
+ //queryName should be found from setup
|
|
|
|
+ let fName='[populateSection/'+sectionId+']';
|
|
print(fName);
|
|
print(fName);
|
|
|
|
|
|
- let entry=findSetupRow(queryName);
|
|
|
|
|
|
+ let entry=findSetupRow(sectionId);
|
|
//ignore names without associated entry in formSetup
|
|
//ignore names without associated entry in formSetup
|
|
if (entry==undefined){
|
|
if (entry==undefined){
|
|
print(fName+': no matching FormSetup entry found');
|
|
print(fName+': no matching FormSetup entry found');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ let queryName=config.formConfig.queryMap[entry['queryName']];
|
|
//populate comes after generate, we should be pretty safe in taking
|
|
//populate comes after generate, we should be pretty safe in taking
|
|
//already generated additionalData
|
|
//already generated additionalData
|
|
|
|
|
|
@@ -2744,8 +2910,9 @@ function populateSection(queryName){
|
|
if (aM!='GENERATE'){
|
|
if (aM!='GENERATE'){
|
|
let writeMode=(aM=='EDIT');
|
|
let writeMode=(aM=='EDIT');
|
|
print(fName+': writeMode '+writeMode);
|
|
print(fName+': writeMode '+writeMode);
|
|
- let setup=getSetup(listName,writeMode);
|
|
|
|
|
|
+ let setup=getSetup(sectionId,queryName,writeMode);
|
|
setup.setVariables=parseVariableDefinition(entry);
|
|
setup.setVariables=parseVariableDefinition(entry);
|
|
|
|
+ setHelp(setup,entry);
|
|
//this fails for setVariables, although they are available via entry['variableDefinition']
|
|
//this fails for setVariables, although they are available via entry['variableDefinition']
|
|
populateTable(queryName,writeMode,setup);
|
|
populateTable(queryName,writeMode,setup);
|
|
return;
|
|
return;
|
|
@@ -2754,11 +2921,11 @@ function populateSection(queryName){
|
|
//deal with generate
|
|
//deal with generate
|
|
//
|
|
//
|
|
//already available -> shift to READ mode
|
|
//already available -> shift to READ mode
|
|
- let divTable=queryName+'Table';
|
|
|
|
|
|
+ let divTable=sectionId+'Table';
|
|
let divObj=config.document.getElementById(divTable);
|
|
let divObj=config.document.getElementById(divTable);
|
|
- let divRev=config.document.getElementById(queryName+'Review');
|
|
|
|
- let divRLi=config.document.getElementById(queryName+'ReviewList');
|
|
|
|
- let divGBu=config.document.getElementById(queryName+'GenerateButton');
|
|
|
|
|
|
+ let divRev=config.document.getElementById(sectionId+'Review');
|
|
|
|
+ let divRLi=config.document.getElementById(sectionId+'ReviewList');
|
|
|
|
+ let divGBu=config.document.getElementById(sectionId+'GenerateButton');
|
|
|
|
|
|
print('div GBU: '+divGBu);
|
|
print('div GBU: '+divGBu);
|
|
divObj.style.display="block";
|
|
divObj.style.display="block";
|
|
@@ -2769,7 +2936,10 @@ function populateSection(queryName){
|
|
let nData=config.formConfig.dataQueries[queryName].rows.length;
|
|
let nData=config.formConfig.dataQueries[queryName].rows.length;
|
|
print('['+queryName+']: nrows '+nData);
|
|
print('['+queryName+']: nrows '+nData);
|
|
if (nData>0){
|
|
if (nData>0){
|
|
- populateTable(queryName,0);
|
|
|
|
|
|
+ let setup=getSetup(sectionId,queryName,false);
|
|
|
|
+ setup.setVariables=parseVariableDefinition(entry);
|
|
|
|
+ //this fails for setVariables, although they are available via entry['variableDefinition']
|
|
|
|
+ populateTable(queryName,false,setup);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//hide table
|
|
//hide table
|
|
@@ -3022,7 +3192,7 @@ function setFormConfig(){
|
|
//add object to store form related data
|
|
//add object to store form related data
|
|
config.formConfig=new Object();
|
|
config.formConfig=new Object();
|
|
|
|
|
|
- config.formConfig.softwareVersion='0.14.32';
|
|
|
|
|
|
+ config.formConfig.softwareVersion='0.15.02';
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
|
|
if (debug)
|
|
if (debug)
|
|
@@ -3139,6 +3309,7 @@ function collectData(){
|
|
let crfFilter=LABKEY.Filter.create('entryId',parentCrf);
|
|
let crfFilter=LABKEY.Filter.create('entryId',parentCrf);
|
|
queryArray.push(makeQuery('data','crfEntry','parentCrfData',[crfFilter]));
|
|
queryArray.push(makeQuery('data','crfEntry','parentCrfData',[crfFilter]));
|
|
}
|
|
}
|
|
|
|
+ queryArray.push(makeQuery('data','help','help'));
|
|
|
|
|
|
print('running getDataFromQueries');
|
|
print('running getDataFromQueries');
|
|
getDataFromQueries(queryArray,fcontinue);
|
|
getDataFromQueries(queryArray,fcontinue);
|
|
@@ -3393,8 +3564,8 @@ function afterDatasets(data,cb){
|
|
if ("containerPath" in field.lookup){
|
|
if ("containerPath" in field.lookup){
|
|
selectRows.containerPath=field.lookup.containerPath;
|
|
selectRows.containerPath=field.lookup.containerPath;
|
|
}
|
|
}
|
|
- selectRows.columns=field.lookup.keyColumn+","+
|
|
|
|
- field.lookup.displayColumn;
|
|
|
|
|
|
+ //selectRows.columns=field.lookup.keyColumn+","+field.lookup.displayColumn;
|
|
|
|
+ //get all, descriptions may be hidden in further variables
|
|
//wait for all lookups to return
|
|
//wait for all lookups to return
|
|
selectRows.success=function(data){addLookup(data,qobject,f,cb);};
|
|
selectRows.success=function(data){addLookup(data,qobject,f,cb);};
|
|
print("Sending query: ["+
|
|
print("Sending query: ["+
|
|
@@ -3426,6 +3597,7 @@ function addLookup(data,qobject,f,cb){
|
|
lObject.LUT[data.rows[i][key]]=data.rows[i][val];
|
|
lObject.LUT[data.rows[i][key]]=data.rows[i][val];
|
|
lObject.ValToKey[data.rows[i][val]]=data.rows[i][key];
|
|
lObject.ValToKey[data.rows[i][val]]=data.rows[i][key];
|
|
}
|
|
}
|
|
|
|
+ lObject.rows=data.rows;
|
|
qobject.lookup[f]="DONE";
|
|
qobject.lookup[f]="DONE";
|
|
if (!dataLayoutSet()) return;
|
|
if (!dataLayoutSet()) return;
|
|
cb();
|
|
cb();
|