const config=new Object();
function clear(){
let el=config.document.getElementById(config.debugId);
if (el===null) {
//alert("Debug section not initialized");
return;
}
config.document.getElementById(config.debugId).value="";
}
function print(msg){
let el=config.document.getElementById(config.debugId);
if (el===null) {
//alert("Debug section not initialized. Message: "+msg);
return;
}
el.value+="\n"+msg;
}
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();
e.containerName=containerName;
e.queryName=queryName;
e.fieldName=fieldName;
e.filterArray=filterArray;
return e;
}
function getDataFromQueries(queryArray,cb){
//queryArray should contain elements with
//- fieldName to set the data variable
//- containerName to select container (data,config,CRF)
//- queryName to select query
//- filterArray to perform filtering, empty array works
//- callback cb to be called with no arguments
//
afterQuery(new Object(),-1,queryArray,cb);
}
function afterQuery(data,id,queryArray,cb){
//queryArray should contain elements with
//- fieldName to set the data variable
//- containerName to select container (data,config,CRF)
//- queryName to select query
//- filterArray to perform filtering, empty array works
//- callback cb to be called with no arguments
//
//it should be called with id -1.
//
print('afterQuery['+id+']: ');
if (id>-1){
let fieldName=queryArray[id].fieldName;
print('afterQuery['+fieldName+']: '+data.rows.length);
config.formConfig[fieldName]=data;
}
id+=1;
if (id==queryArray.length) {
cb();
return;
}
let e=queryArray[id];
let qconfig=new Object();
qconfig.containerPath=getContainer(e.containerName);
qconfig.schemaName="lists";
if ("schemaName" in e){
print('afterQuery: schemaName='+e.schemaName);
qconfig.schemaName=e.schemaName;
}
if ("columns" in e){
print('afterQuery: columns='+e.columns);
qconfig.columns=e.columns;
}
qconfig.queryName=e.queryName;
//this should point to configuration container
//don't filter -> so we can pick up other forms (say registration) later on
//qconfig.filterArray=[LABKEY.Filter.create('Key',config.formId)];
if ("filterArray" in e)
qconfig.filterArray=e.filterArray;
//qconfig.filterArray=[LABKEY.Filter.create('formStatus',1)]
qconfig.success=function(data){afterQuery(data,id,queryArray,cb);};
qconfig.failure=doNothing;
LABKEY.Query.selectRows(qconfig);
}
function getCRFrefFirst(){
//crfRef is part of html call and gets stored in the page
return config.document.getElementById(config.crfRefId).innerHTML;
}
function getCRFref(){
//'crfRefId'
return config.formConfig.crfEntry['entryId'];
}
function getCRFrefData(){
let parentCrf=config.formConfig.crfEntry['parentCrf'];
if (parentCrf!=undefined) return parentCrf;
return getCRFref();
}
function onFailure(errorInfo, options, responseObj){
if (errorInfo && errorInfo.exception)
alert("Failure: " + errorInfo.exception);
else
alert("Failure: " + responseObj.statusText);
}
function doNothing(){
print('doNothing called');
}
function generateDebugSection(){
//let debug=true;
//if (debug) print("generateDebugSection "+sectionName);
let formName=config.debugDiv;
let sectionName="debugSection";
let sectionTitle="Debug Messages";
let tb=config.document.createElement('table');
tb.className='t2';
let row=tb.insertRow();
let cell=config.document.createElement('th');
row.appendChild(cell);
cell.setAttribute("colspan","4");
cell.style.fontSize="20px";
cell.style.textAlign="center";
let cellData=config.document.createTextNode(sectionTitle);
cell.appendChild(cellData);
cell=row.insertCell();
let input=config.document.createElement("input");
input.type="button";
input.id="toggle"+sectionName+"VisbilityButton";
input.onclick=function(){toggleVisibility(sectionName,input.id)};
cell.appendChild(input);
config.document.getElementById(formName).appendChild(tb);
let div=config.document.createElement('div');
div.id=sectionName;
config.document.getElementById(formName).appendChild(div);
//start open (for debug)
//input.value="Hide";
//div.style.display="block";
//start hidden (for production)
input.value="Show";
div.style.display="none";
let debugArea=config.document.createElement('textarea');
debugArea.rows=10;
debugArea.cols=95;
debugArea.id=config.debugId;
div.appendChild(debugArea);
//print('ver: 0.10');
}
function getAdditionalData(formSetupEntry){
let queryName=config.formConfig.queryMap[formSetupEntry['queryName']];
let fName='[getAdditionalData/'+queryName+']';
print(fName);
if (queryName in config.formConfig.additionalData){
print(fName+': Returning preset value');
return config.formConfig.additionalData[queryName];
}
print(fName+': generating');
config.formConfig.additionalData[queryName]=new Object();
//takes address, so further changes will be to the newly created object
let ad=config.formConfig.additionalData[queryName];
if (formSetupEntry["showFlag"]==="NONE") {
print(fName+": empty");
return ad;
}
if (formSetupEntry["showFlag"]==="REVIEW") {
//abuse additionalData to signal different segment
print(fName+": generateReport");
ad.isReview=true;
return ad;
}
print(fName+': setting values');
ad.showFlag=formSetupEntry["showFlag"];
ad.showFlagValue=formSetupEntry["showFlagValue"];
//variables associated with target query
let qVars=formSetupEntry["showQuery"].split(';');
ad.queryName=qVars[0];
//remove first element
qVars.shift();
//join back to string for parsing
let code=qVars.join(";");
//if empty string, set to undefined for parseCode
if (code.length==0){
code=undefined;
}
//parse var=value pairs
ad.variableDefinition=parseCode(code);
//print for debugging
for (let f in ad.variableDefinition){
let v=ad.variableDefinition[f];
print(fName+': adding ['+f+']='+v);
}
ad.filters=new Object();
ad.filters['crfRef']=getCRFref();
let msg=fName+": flag "+ad.showFlag;
msg+=" value "+ad.showFlagValue;
msg+=" query "+ad.queryName;
print(msg);
return ad;
}
function generateSetup(){
let setup=new Object();
//setVariables contains special variables that have a
//preset value in a specified table:
//A.) these values won't appear in the form
//B.) will be submitted with value specified to the database
//make sure setVariables object is present in an object
setup.setVariables=new Object();
return setup;
}
function fullAccessSetup(sectionId,listName){
//generate setup object whcih should contain fields:
//readonlyFlag - whether the dataset is writeable
//filters - selection fields that allow creation of LABKEY.Filter.create()
//getInputId - formating of unique ids for html elements
//addApply - whether a submit/Save button is generated
//unique - whether entries in list are unique
let debug=true;
if (debug) print("fullAccessSetup");
let setup=generateSetup();
setup.queryName=listName;
setup.readonlyFlag=function(vName){return false};
setup.filters=new Object();
setup.filters['crfRef']=getCRFref();
setup.getInputId=function(vName){return sectionId+"_"+vName;}
setup.addApply="Save";
setup.isReview=false;
setup.sectionId=sectionId;
return setup;
}
function readonlySetup(sectionId,listName){
//see definition of setup object above
let debug=true;
if (debug) print("readonlySetup");
let setup=generateSetup();
setup.queryName=listName;
setup.readonlyFlag=function(vName){return true};
setup.filters=new Object();
setup.filters['crfRef']=getCRFref();
setup.getInputId=function(vName){return sectionId+'_'+vName;}
setup.isReview=false;
setup.sectionId=sectionId;
return setup;
}
function getSetup(sectionId,listName,writeAccess=true){
//change to section granulated permission of type EDIT, COMMENT, READ
//let formStatus=config.formConfig.formStatus;
//equivalent to READ
if (!writeAccess)
//if (formStatus=="Submitted")
return readonlySetup(sectionId,listName);
//if (formStatus=="Approved")
// return readonlySetup(listName);
return fullAccessSetup(sectionId,listName);
}
function parseVariableDefinition(formSetupEntry){
let fName='parseVariableDefinition['+formSetupEntry['title']+']';
let code=formSetupEntry['variableDefinition'];
print(fName+' '+code);
return parseCode(code);
}
function parseCode(code){
//helper function to decode content of variableDefinition
//to a JS object
//
//should contain semicolon split var=value pairs
let vars=new Object();
if (code==undefined)
//variableDefinition field is empty, return empyt object
return vars;
let ar=code.split(';');
for (let i=0;i>>>reviewSection associated routines
function parseResponseXML(){
//print(config.config,'Status:' +this.status);
print('Status:'+this.status);
if (this.status!=200) return;
config.loadFileConfig.json=JSON.parse(this.responseText);
config.loadFileConfig.cb();
}
function loadFile(){
print('YY: '+config.loadFileConfig.url);
let connRequest=new XMLHttpRequest();
connRequest.addEventListener("loadend",parseResponseXML);
//function(e){parseResponseXML(e,config);});
connRequest.open("GET", config.loadFileConfig.url);
connRequest.send();
}
function getBasePath(){
let server=LABKEY.ActionURL.getBaseURL();
let basePath=server+"_webdav";
basePath+=LABKEY.ActionURL.getContainer();
return basePath;
}
function generateReviewSection(listName,id,callback){
//callback should be generateReviewSectionCB and it takes no arguments
print("generateReviewSection");
//need base path
config.loadFileConfig=new Object();
config.loadFileConfig.cb=callback;
config.loadFileConfig.id=id;
config.loadFileConfig.url=getBasePath()+'/@files/reportSetup/'+listName+'.json';
loadFile();
//load file and continue in the next function
}
function generateErrorMessage(id,listName,msg){
print('generateErrorMessage:');
let eid=listName+"_errorMsg";
let el=config.document.getElementById(eid);
if (el===null){
el=config.document.createElement("p");
config.document.getElementById(id).appendChild(el);
}
el.innerHTML=msg;
}
function clearErrorMessage(listName){
let eid=listName+"_errorMsg";
let el=config.document.getElementById(eid);
if (el===null) return;
el.remove();
}
function getParticipantCode(pid){
let selectRows=new Object();
selectRows.schemaName='lists';
//we should now which form we are in
let mfId=config.formConfig.form['masterQuery'];
selectRows.queryName=config.formConfig.queryMap[mfId];
//point to data container
selectRows.containerPath=getContainer('data');
//selectRows.queryName='PET';
pid.afterId=setParticipantCode;
pid.participantField=config.formConfig.studyData["SubjectColumnName"];
selectRows.success=function(data){afterRegistration(pid,data);}
selectRows.filterArray=[LABKEY.Filter.create("crfRef",getCRFref())];
LABKEY.Query.selectRows(selectRows);
}
function visitCodeFromVisitId(visitId){
if (visitId<0) return "NONE";
let project=getContainer('data');
print('visitCodeFromVisitId: '+project.search('retro'));
if (project.search('retro')>-1)
visitId-=1;
return 'VISIT_'+visitId.toString();
}
function replaceSlash(x){
return x.replace(/\//,'_');
}
function setParticipantCode(pid){
let fName='[setParticipantCode]';
let rows=pid.registration.rows;
//pick from study
let participantField=config.formConfig.studyData["SubjectColumnName"];
if (rows.length==1){
print(fName+': '+rows[0][participantField]+'/'+rows[0].visitId);
let visitCode=visitCodeFromVisitId(rows[0].visitId);
print('setParticipantCode: '+pid.participantId+'/'+visitCode);
pid.participantCode=replaceSlash(pid.participantId);
pid.visitCode=visitCode;
}
generateReviewSection2(pid);
}
function generateReviewSectionCB(){
let listName=config.loadFileConfig.listName;
let id=config.loadFileConfig.id;
clearErrorMessage(listName);
let pid=new Object();
pid.participantCode="NONE";
pid.visitCode="NONE";
getParticipantCode(pid);
print('Get participant code sent');
//involves database search, continue after callback
}
function getValueFromElement(id,defaultValue){
let e=config.document.getElementById(id);
if (e!=null){
defaultValue=e.innerHTML;
}
return defaultValue;
}
function pickParticipantCodeFromPage(){
let pid=new Object();
pid.participantCode=getValueFromElement("participantCode","NIX-LJU-D2002-IRAE-A000");
pid.visitCode=getValueFromElement("visitCode","VISIT_1");
generateReviewSection2(pid);
}
function patternReplace(src,replacements,values){
for (rep in replacements){
let txt1=src.replace(new RegExp(rep),values[replacements[rep]]);
src=txt1;
}
return src;
}
function plotImage(cell,k,row,rowVariable,obj,pid){
let baseDir=patternReplace(obj.imageDir,obj.replacements,pid);
print('Base dir: '+pid.basePath);
pid[obj.variable]=obj.values[k];
cell.id=pid[obj.variable]+"_"+rowVariable+pid[rowVariable];
let img=null;
let imgId=cell.id+'_img_';
img=config.document.getElementById(imgId);
if (img===null){
img=config.document.createElement('img');
img.id=imgId;
cell.appendChild(img);
}
let imgSrc=patternReplace(obj.file,obj.replacements,pid);
print('Image: '+imgSrc);
let imagePath=pid.basePath+'/'+baseDir+'/'+imgSrc;
img.src=imagePath;
img.width="300";
}
function showReport(cell,k,row,rowVariable,obj,pid){
cell.width="300px";
cell.id='report_'+obj.values[k]+"_"+rowVariable+pid[rowVariable];
let reportConfig=new Object();
reportConfig.partName="Report";
reportConfig.renderTo=cell.id;
//reportConfig.showFrame=false;
//reportConfig.width="300";
reportConfig.frame="none";
reportConfig.partConfig=new Object();
reportConfig.partConfig.width="300";
reportConfig.partConfig.title="R Report";
reportConfig.partConfig.reportName=obj.values[k];
for (f in obj.parameters){
reportConfig.partConfig[f]=pid[f];
}
reportConfig.partConfig.showSection="myscatterplot";
let reportWebPartRenderer = new LABKEY.WebPart(reportConfig);
print('Render to: '+reportConfig.renderTo);
reportWebPartRenderer.render();
}
function showProbability(cell,k,row,rowSetup,j,obj,pid){
print('showProbability: '+rowSetup);
let rowVariable=rowSetup.variable;
cell.id='prob_'+obj.values[k]+"_"+rowVariable+pid[rowVariable];
let probDensity=new Object();
probDensity.mean=rowSetup.mean[j];
probDensity.sigma=rowSetup.sigma[j];
print('showProbability: mean '+probDensity.mean+' sigma '+probDensity.sigma);
probDensity.func=obj.values[k];
probDensity.organCode=pid.organCode;
pid[obj.variable]=rowSetup[obj.variable][j];
probDensity.percentile=pid.percentile;
let selectRows=new Object();
selectRows.queryName=obj.queryName;
selectRows.schemaName="study";
selectRows.filterArray=[];
selectRows.containerPath=getContainer('data');
for (let f in obj.filters){
selectRows.filterArray.push(
LABKEY.Filter.create(f,pid[obj.filters[f]]));
print('Filter ['+f+']: '+pid[obj.filters[f]]);
}
selectRows.success=function(data){
drawProbability(data,cell,obj,pid,probDensity);}
LABKEY.Query.selectRows(selectRows);
}
function erf(x){
let fx=[0,0.02,0.04,0.06,0.08,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,
1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,
2.1,2.2,2.3,2.4,2.5,3,3.5];
let fy=[0,0.222702589,0.328626759,0.428392355,0.520499878,
0.603856091,0.677801194,0.742100965,0.796908212,
0.842700793,0.880205070,0.910313978,0.934007945,
0.952285120,0.966105146,0.976348383,
0.983790459,0.989090502,0.992790429,0.995322265,
0.997020533,0.998137154,0.998856823,0.999311486,
0.999593048,0.999977910,0.999999257];
let n=32;
let i0=n-1;
for (let i=1;ifx[i]) continue;
i0=i-1;
break;
}
let fval=1;
if (i0obj.intervals.zlimits[i]) continue;
color=obj.intervals.colors[i-1];
break;
}
let fboxId=cell.id+'_fbox_';
let fbox=config.document.getElementById(fboxId);
if (fbox===null){
fbox=config.document.createElement("div");
fbox.id=fboxId;
cell.appendChild(fbox);
}
fbox.style.backgroundColor=color;
fbox.style.width="180px";
fbox.style.height="180px";
print('organCode '+probDensity.organCode);
let organName="Lung";
if (probDensity.organCode==4){
organName="Thyroid";
}
if (probDensity.organCode==5){
organName="Bowel";
}
setLine(fbox,'_fp4_',organName,"16px");
setLine(fbox,'_fp_',val.toPrecision(3),"25px");
setLine(fbox,'_fp1_',"SUV("+probDensity.percentile+"%)","16px");
setLine(fbox,'_fp2_',fzx.toPrecision(3),"25px");
setLine(fbox,'_fp3_',"z-value","16px");
}
function generateReviewSection2(pid){
let listName=config.loadFileConfig.listName;
let id=config.loadFileConfig.id;
print('generateReviewSection2: '+pid.participantCode+'/'+
pid.visitCode);
if (pid.participantCode=="NONE" || pid.visitCode=="NONE"){
generateErrorMessage(id,listName,
"ParticipantId/visitId not set");
return;
}
print('JSON: '+config.loadFileConfig.json);
let json=config.loadFileConfig.json;
let nrows=json.rows.values.length;
let ncol=json.columns.length;
pid.basePath=getBasePath()+"/@files";
let el=config.document.getElementById(id);
let tableId=id+'_Table';
let table=config.document.getElementById(tableId);
if (table==null){
table=config.document.createElement('table');
table.id=tableId;
el.appendChild(table);
}
table.style.tableLayout="fixed";
table.style.columnWidth="300px";
for (let i=0;i>>>>>>>>>>>>>end of reviewSection(REPORT)
function generateReview(divReviewId,divReviewListId, listName, accessMode){
let listId=config.formConfig.fields[listName].queryId;
//listId is a number->should it be queryName?
let debug=true;
if (debug) print("Generate review for: "+listId+'/'+listName);
let reviewSetup=generateSetup();
reviewSetup.readonlyFlag=function(vName){
if (vName=="queryName") return true;
if (vName=="queryname") return true;
if (vName=="ModifiedBy") return true;
return false;};
reviewSetup.addApply="Add Review";
let generateTableFlag=true;
let formStatus=config.formConfig.formStatus;
//COMMENTS allowed or not
//three levels of access: EDIT, COMMENT, READ
if (accessMode == "READ"){
//if (formStatus == "Approved" ){
delete reviewSetup.addApply;
reviewSetup.readonlyFlag=function(vName){return false;}
generateTableFlag=false;
}
reviewSetup.filters=new Object();
reviewSetup.filters["crfRef"]=getCRFref();
reviewSetup.filters["queryName"]=listId;//entry in reviewComments list is queryname, all in small caps
//needs listName, in argument
reviewSetup.getInputId=function(vName){return divReviewId+"_add"+vName};
reviewSetup.divReviewListId=divReviewListId;
reviewSetup.isReview=true;
if (debug) {
let msg="Review: divId: "+divReviewId;
//msg+=" inputId: "+reviewSetup.getInputId;
print(msg);
}
updateListDisplay(divReviewListId,"reviewComments",reviewSetup.filters,true);
if (! generateTableFlag) return;
generateTable("reviewComments",divReviewId,new Object(),reviewSetup);
}
//>>>>>>>>>>trigger visibility of additional lists
function setListVisibility(input,setup,readonlyFlag){
let debug=true;
let fName="[setListVisibility/"+setup.queryName+"]";
print(fName);
let additionalData=config.formConfig.additionalData[setup.queryName];
let x = config.document.getElementById(additionalData.divName);
if (debug) print(fName+": Div: "+x);
x.style.display="none";
let sText;
if ("setVariable" in input){
sText=input.setVariable;
}
else{
if (readonlyFlag) sText=input.innerText;
else sText=input.options[input.selectedIndex].text;
}
if (debug) print(fName+": Selected option text: "+sText);
if (sText == additionalData.showFlagValue){
let filters=new Object();
if ("filters" in additionalData) filters=additionalData.filters;
x.style.display = "block";
updateListDisplay(additionalData.divQueryName,
additionalData.queryName,filters,readonlyFlag);
}
}
//>>have list refresh when data is added (not optimal yet)
function updateListDisplay(divName,queryName,filters,readonlyFlag){
//use Labkey.QueryWebPart to show list
let debug=true;
let fName="[updateListDisplay]";
if (debug)
print(fName+": Query - "+queryName
+" div - "+divName);
if (divName=="NONE") return;
let crfRef=getCRFref();
let div=config.document.getElementById(divName);
print(fName+": setting border");
div.style.border="thin solid black";
div.style.width="800px";
if (debug)
print(fName+": generating WebPart: "+queryName);
var qconfig=new Object();
qconfig.renderTo=divName;
//point to data container
qconfig.containerPath=getContainer('data');
qconfig.schemaName='lists';
qconfig.queryName=queryName;
qconfig.buttonBarPosition='top';
qconfig.filters=[];
for (f in filters){
qconfig.filters.push(LABKEY.Filter.create(f, filters[f]));
}
qconfig.success=updateSuccess;
qconfig.failure=updateFailure;
//show only print button
if (readonlyFlag){
qconfig.buttonBar=new Object();
qconfig.buttonBar.items=["print"];
}
LABKEY.QueryWebPart(qconfig);
}
function updateSuccess(data){
print("Update success");
}
function updateFailure(data){
print("Update failed");
}
function toggleVisibility(sectionId,buttonName){
let fName='[toggleVisibility/'+sectionId+']';
print(fName);
let x = config.document.getElementById(sectionId);
if (x.style.display === "none") {
//exclude non data sections (like debug)...
print(fName+': issuing setData(populateSection)');
x.style.display = "block";
config.document.getElementById(buttonName).value="Hide";
let cb=function(){populateSection(sectionId);};
setData(cb);
} else {
x.style.display = "none";
config.document.getElementById(buttonName).value="Show";
}
}
function generateButtonBU(divName,title,buttonName,callback,
callbackParameters){
let debug=true;
if (debug) print("generateButtonBU");
let tb=config.document.createElement('table');
tb.className="t2";
let r1=tb.insertRow();
th=config.document.createElement('th');
r1.appendChild(th);
th.innerHTML=title;
//*!*
let c2=r1.insertCell();
let i1=config.document.createElement("input");
i1.type="button";
i1.value=buttonName;
i1.style.fontSize="20px";
i1.onclick=function(){callback(callbackParameters);}
c2.appendChild(i1);
let c1=r1.insertCell();
c1.setAttribute("colspan","1");
c1.id=callbackParameters.submitReportId;
let el=config.document.getElementById(divName);
if (debug) print("generateButton: element["+divName+"]: "+el);
el.appendChild(tb);
}
function generateButton(divName,caption,label,callbackLabel,callback){
let debug=true;
if (debug) print("generateButtonX");
let tb=config.document.createElement('table');
tb.className="t2";
let r1=tb.insertRow();
th=config.document.createElement('th');
r1.appendChild(th);
th.innerHTML=caption;
//*!*
let c2=r1.insertCell();
let i1=config.document.createElement("input");
i1.type="button";
i1.value=label;
i1.style.fontSize="20px";
i1.onclick=callback;
i1.id='button_'+callbackLabel;
c2.appendChild(i1);
let c1=r1.insertCell();
c1.setAttribute("colspan","1");
//this is only for saveReview?
c1.id=divName+'_reportField';
//c1.id=config.submitReportId;
let el=config.document.getElementById(divName);
if (debug) print("generateButton: element["+divName+"]: "+el);
el.appendChild(tb);
}
function generateSubQuery(input, setup, readonlyFlag){
let fName="[generateSubQuery]";
if (setup.isReview) return;
if (!(setup.queryName in config.formConfig.additionalData)){
print(fName+': no additionalData entry (probably a subquery)');
return;
}
let additionalData=config.formConfig.additionalData[setup.queryName];
if (!("showFlag" in additionalData))
return;
print(fName);
let expId=setup.getInputId(additionalData.showFlag);
if (expId!=input.id) {
print(fName+": ignoring field "+input.id+"/"+expId);
return;
}
print(fName+": Setting onChange to "+input.id);
if (!readonlyFlag)
input.onchange=function(){setListVisibility(input,setup,readonlyFlag)};
}
//>>populate fields
//
//
//split to field generation and field population
//
function addFieldRow(tb,field,setup,additionalData){
let fName="[addFieldRow/"+setup.queryName+':'+field.name+']';
let vName=field.name;
let vType=field.type;
let isLookup=("lookup" in field);
print(fName+": ["+vName+"/"+vType+'/'+isLookup+"]");
let row=tb.insertRow();
let cell=config.document.createElement('th');
row.appendChild(cell);
let text = config.document.createTextNode(field.shortCaption);
cell.appendChild(text);
let cell1=row.insertCell();
let input=null;
cell1.colSpan="3";
let readonlyFlag=setup.readonlyFlag(vName);
print(fName+' inputType '+field.inputType);
//set the html input object
while (1){
if (readonlyFlag){
input=config.document.createElement('label');
input.innerText='Loading';
break;
}
//lookup
if (isLookup){
input = config.document.createElement("select");
break;
}
//date
if (vType=="date"){
input = config.document.createElement("input");
input.type="date";
break;
}
//string
if (vType=="string"){
//we have to make sure UNDEF is carried to below
//since we are adapting file to either show
//current file or allow user to select a file
//
//TODO change this so one can always select file
//but also show the selected file
if(vName.search("reviewComment")>-1){
input = config.document.createElement("textarea");
input.cols="65";
input.rows="5";
break;
}
if (field.inputType=="textarea"){
input = config.document.createElement("textarea");
input.cols="65";
input.rows="5";
break;
}
input=config.document.createElement('input');
input.type="text";
if (vName.search('_file_')<0) break;
cell1.setAttribute('colspan',"1");
let cell2=row.insertCell();
cell2.setAttribute('colspan',"2");
let input1=config.document.createElement('input');
input1.type="file";
input1.id=setup.getInputId(vName)+'_file_';
cell2.appendChild(input1);
break;
}
if (vType=="float"){
input = config.document.createElement("input");
input.type="text";
break;
}
if (vType=="boolean"){
input = config.document.createElement("input");
input.type="checkbox";
print("Creating checkbox");
break;
}
break;
}
input.id=setup.getInputId(vName);
cell1.appendChild(input);
print(fName+': adding element '+input.id);
print(fName+': listing element '+config.document.getElementById(input.id));
//connect associated list
generateSubQuery(input,setup,readonlyFlag);
if (readonlyFlag) {
print(fName+': exiting(readonlyFlag)');
return;
}
if (!isLookup) {
print(fName+': exiting (not lookup)');
return;
}
let lookup=field["lookup"];
//get all values from config.formConfig.lookup[X]
let lObject=config.formConfig.lookup[lookup.queryName];
//debug
print(fName+": query: "+lookup.queryName);
print(fName+": ElementId: "+input.id);
print(fName+": No of options: " +lObject.LUT.length);
print(fName+": Element: "+input);
//set the lut value (input is text label) for readonly
input.style.textAlign="center";
//input.style.textAlignLast="center";
//clear existing fields from input
for(let i = input.options.length; i >= 0; i--) {
input.remove(i);
}
//create option -1
let opt = config.document.createElement("option");
opt.text = "