|
@@ -105,6 +105,13 @@ function setAdditionalData(additionalData,entry){
|
|
|
}
|
|
|
|
|
|
function fullAccessSetup(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");
|
|
|
|
|
@@ -119,6 +126,7 @@ function fullAccessSetup(listName){
|
|
|
}
|
|
|
|
|
|
function readonlySetup(){
|
|
|
+ //see definition of setup object above
|
|
|
let debug=true;
|
|
|
if (debug) print("readonlySetup");
|
|
|
|
|
@@ -240,6 +248,7 @@ function generateSection(sectionName, sectionTitle, listName, additionalData){
|
|
|
generateReview(divReview.id,divReviewList.id,listName);
|
|
|
}
|
|
|
|
|
|
+//>>>>reviewSection associated routines
|
|
|
|
|
|
function parseResponseXML(){
|
|
|
//print(config.config,'Status:' +this.status);
|
|
@@ -464,10 +473,13 @@ 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,
|
|
|
+ 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];
|
|
|
+ 0.997020533,0.998137154,0.998856823,0.999311486,
|
|
|
+ 0.999593048,0.999977910,0.999999257];
|
|
|
let n=32;
|
|
|
let i0=n-1;
|
|
|
|
|
@@ -575,9 +587,11 @@ function generateReviewSection2(pid){
|
|
|
let listName=config.loadFileConfig.listName;
|
|
|
let id=config.loadFileConfig.id;
|
|
|
|
|
|
- print('generateReviewSection2: '+pid.participantCode+'/'+pid.visitCode);
|
|
|
+ print('generateReviewSection2: '+pid.participantCode+'/'+
|
|
|
+ pid.visitCode);
|
|
|
if (pid.participantCode=="NONE" || pid.visitCode=="NONE"){
|
|
|
- generateErrorMessage(id,listName,"ParticipantId/visitId not set");
|
|
|
+ generateErrorMessage(id,listName,
|
|
|
+ "ParticipantId/visitId not set");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -619,6 +633,8 @@ function generateReviewSection2(pid){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+///>>>>>>>>>>>>>>end of reviewSection(REPORT)
|
|
|
+
|
|
|
function generateReview(divReviewId,divReviewListId, listName){
|
|
|
let listId=config.formConfig.fields[listName].queryId;
|
|
|
|
|
@@ -664,6 +680,8 @@ function generateReview(divReviewId,divReviewListId, listName){
|
|
|
generateTable("reviewComments",divReviewId,false,new Object(),reviewSetup);
|
|
|
}
|
|
|
|
|
|
+//>>>>>>>>>>trigger visibility of additional lists
|
|
|
+
|
|
|
function setListVisibility(setup,additionalData,readonlyFlag){
|
|
|
let debug=true;
|
|
|
if (debug){
|
|
@@ -693,10 +711,14 @@ function setListVisibility(setup,additionalData,readonlyFlag){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//>>have list refresh when data is added (not optimal yet)
|
|
|
+
|
|
|
function updateListDisplay(divName,queryName,filters,readonlyFlag){
|
|
|
let debug=true;
|
|
|
|
|
|
- if (debug) print("UpdateListDisplay: Query - "+queryName+" div - "+divName);
|
|
|
+ if (debug)
|
|
|
+ print("UpdateListDisplay: Query - "+queryName
|
|
|
+ +" div - "+divName);
|
|
|
|
|
|
if (divName=="NONE") return;
|
|
|
|
|
@@ -736,6 +758,8 @@ function updateFailure(data){
|
|
|
print("Update failed");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+//TODO: this should trigger a data refresh on section, ie populateData(field)
|
|
|
function toggleVisibility(divName,buttonName){
|
|
|
|
|
|
let x = config.document.getElementById(divName);
|
|
@@ -750,7 +774,8 @@ function toggleVisibility(divName,buttonName){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function generateButtonBU(divName,title,buttonName,callback,callbackParameters){
|
|
|
+function generateButtonBU(divName,title,buttonName,callback,
|
|
|
+ callbackParameters){
|
|
|
let debug=true;
|
|
|
if (debug) print("generateButtonBU");
|
|
|
|
|
@@ -817,198 +842,248 @@ function generateButton(divName,title,buttonName,callback){
|
|
|
}
|
|
|
|
|
|
|
|
|
+//>>populate fields
|
|
|
+//
|
|
|
|
|
|
-function generateTable(listName,divName,unique,additionalData,setup){
|
|
|
+function addFieldRow(tb,entry,field,setup,additionalData){
|
|
|
|
|
|
- let debug=true;
|
|
|
+ let vName=field.name;
|
|
|
+ let vType=field.type;
|
|
|
+ let isLookup=("lookup" in field);
|
|
|
+ print("addFieldRow ["+vName+"/"+vType+'/'+isLookup+"]");
|
|
|
|
|
|
- if (debug) print("generateTable: "+listName);
|
|
|
- //these objects will contain respective data for the entry
|
|
|
+ let row=tb.insertRow();
|
|
|
+ let cell=config.document.createElement('th');
|
|
|
+ row.appendChild(cell);
|
|
|
+
|
|
|
+ let text = config.document.createTextNode(field.shortCaption);
|
|
|
+ cell.appendChild(text);
|
|
|
+ cell=row.insertCell();
|
|
|
+
|
|
|
+ let varValue="UNDEF";
|
|
|
+ if (vName in setup.filters) varValue=setup.filters[vName];
|
|
|
+ if (vName in entry) varValue=entry[vName];
|
|
|
|
|
|
- //add temp variables
|
|
|
- //this will capture the state of the data prior to updating
|
|
|
- let qconfig=new Object();
|
|
|
- //qconfig.containerPath=config.containerPath;
|
|
|
- qconfig.schemaName='lists';
|
|
|
- qconfig.queryName=listName;
|
|
|
- //apply filters on data to get right entries
|
|
|
- qconfig.filterArray=[];
|
|
|
- for (let f in setup.filters){
|
|
|
- print('Filtering on '+f+' val '+setup.filters[f]);
|
|
|
- qconfig.filterArray.push(LABKEY.Filter.create(f,setup.filters[f]));
|
|
|
- }
|
|
|
- qconfig.success=function(data){populateTable(data,divName,unique,additionalData,setup);};
|
|
|
- LABKEY.Query.selectRows(qconfig);
|
|
|
-}
|
|
|
+
|
|
|
+ //date
|
|
|
+ if (vType=="date"){
|
|
|
+ if (varValue==="UNDEF") varValue=new Date();
|
|
|
+ else varValue=new Date(varValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ let input=null;
|
|
|
+ cell.colSpan="3";
|
|
|
|
|
|
-function printTableSetup(data){
|
|
|
- let obj=data.metaData.fields;
|
|
|
- for (let f in obj){
|
|
|
- print("Data["+f+"]: "+obj[f]);
|
|
|
- for (let g in obj[f]){
|
|
|
- print("Data.metaData.fields["+f+"]["+g+"]: "+obj[f][g]);
|
|
|
+ let cellClass="input";
|
|
|
+ let cellType="text";
|
|
|
+
|
|
|
+ let readonlyFlag=setup.readonlyFlag(vName);
|
|
|
+
|
|
|
+ if (isLookup){
|
|
|
+ let lookup=field["lookup"];
|
|
|
+
|
|
|
+ //get all values from config.formConfig.lookup[X]
|
|
|
+ let lObject=config.formConfig.lookup[lookup.queryName];
|
|
|
+ varValue=lObject.LUT[varValue];
|
|
|
+ }
|
|
|
+
|
|
|
+ //set the html input object
|
|
|
+ while (1){
|
|
|
+
|
|
|
+ if (readonlyFlag){
|
|
|
+ input=config.document.createTextNode(varValue);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //lookup
|
|
|
+ if (isLookup){
|
|
|
+ input = config.document.createElement("select");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //date
|
|
|
+ if (vType=="date"){
|
|
|
+ input = config.document.createElement("input");
|
|
|
+ input.type="date";
|
|
|
+ break;
|
|
|
}
|
|
|
- if ("lookup" in obj[f]){
|
|
|
- for (h in obj[f]["lookup"]){
|
|
|
- print("Lookup["+h+"]: "+obj[f]["lookup"][h]);
|
|
|
+
|
|
|
+ //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 (varValue==null) varValue="UNDEF";
|
|
|
+ else{
|
|
|
+ if (varValue.length==0) varValue="UNDEF";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vName.search("reviewComment")>-1){
|
|
|
+ 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;
|
|
|
+
|
|
|
+ print('varValue: '+varValue);
|
|
|
+
|
|
|
+ if (varValue!="UNDEF") break;
|
|
|
+
|
|
|
+ input.type="file";
|
|
|
+ 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);
|
|
|
+ cell.appendChild(input);
|
|
|
+
|
|
|
+
|
|
|
+ if (varValue != "UNDEF"){
|
|
|
+ if (vType=="string")
|
|
|
+ input.value=varValue;
|
|
|
+ if (vType=="float")
|
|
|
+ input.value=varValue;
|
|
|
+ if (vType=="date")
|
|
|
+ input.valueAsDate=varValue;
|
|
|
+ if (vType=="boolean")
|
|
|
+ input.checked=varValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (readonlyFlag) return;
|
|
|
+
|
|
|
+ if (!isLookup) return;
|
|
|
|
|
|
|
|
|
-function populateTable(data,divName,unique,additionalData,setup){
|
|
|
- //generate and populate table with the first suitable entry
|
|
|
- let debug=true;
|
|
|
+ let lookup=field["lookup"];
|
|
|
+
|
|
|
+ //get all values from config.formConfig.lookup[X]
|
|
|
+ let lObject=config.formConfig.lookup[lookup.queryName];
|
|
|
|
|
|
- print('populateTable: '+config.formConfig.dataFields);
|
|
|
- //avoid resetting of values
|
|
|
- if (!(data.queryName in config.formConfig.dataFields))
|
|
|
- config.formConfig.dataFields[data.queryName]=data.metaData.fields;
|
|
|
- //changing to config.formConfig.dataQueries[data.QueryName].fields
|
|
|
+ //debug
|
|
|
+ print("Query: "+lookup.queryName);
|
|
|
+ print("ElementId: "+input.id);
|
|
|
+ print("No of options: " +lObject.LUT.length);
|
|
|
+ print("Element: "+input);
|
|
|
+
|
|
|
+ //set the lut value (input is text label) for readonly
|
|
|
+
|
|
|
+ //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 = "<Select>";
|
|
|
+ opt.value = -1;
|
|
|
+ input.options[0] = opt;
|
|
|
+ print( "Adding <Select>");
|
|
|
+
|
|
|
+ //set value
|
|
|
+ let fv=entry[vName];//can be undefined
|
|
|
+ if (vName in setup.filters) fv=setup.filters[vName];
|
|
|
+ input.selectedIndex=0;
|
|
|
+
|
|
|
+ //add other, label them with LUT
|
|
|
+ for (let v in lObject.LUT) {
|
|
|
+ print('populating '+v+': '+lObject.LUT[v]);
|
|
|
|
|
|
- if (debug){
|
|
|
- print("populateTable Query: "+data.queryName+" divName: "+divName+" setup: "+setup);
|
|
|
+ let opt = config.document.createElement("option");
|
|
|
+ opt.text = lObject.LUT[v];
|
|
|
+ opt.value = v;
|
|
|
+ input.options[input.options.length] = opt;
|
|
|
+ if (fv==undefined) continue;
|
|
|
+ if (fv==v) input.selectedIndex=input.options.length-1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ //add watcher for showFlag field of additionalData
|
|
|
+ if (!("showFlag" in additionalData))
|
|
|
+ return;
|
|
|
|
|
|
- if (0) printTableSetup(data);
|
|
|
+ print("\n Parsing additional data ");
|
|
|
+
|
|
|
+ let expId=setup.getInputId(additionalData.showFlag);
|
|
|
+ if (expId!=input.id) {
|
|
|
+ print("Skipping fields not flagged as showFlag:"+expId+"/"+input.id);
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ print("Setting onChange to "+input.id);
|
|
|
|
|
|
- let crfRef=getCRFref();
|
|
|
- let entry=new Object();
|
|
|
+ input.onchange=function(){setListVisibility(setup,additionalData,readonlyFlag)};
|
|
|
+ setListVisibility(setup,additionalData,readonlyFlag);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- if (debug)
|
|
|
- print("Data: nrows "+data.rows.length);
|
|
|
|
|
|
- //copy values from queryName to formConfig.entries (if it exists)
|
|
|
- if (data.rows.length > 0) config.formConfig.entries[data.queryName]=data.rows[0];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function generateTable(listName,divName,unique,additionalData,setup){
|
|
|
+
|
|
|
+ let debug=true;
|
|
|
+
|
|
|
+ if (debug) print("generateTable: "+listName);
|
|
|
|
|
|
- //this is the current data snapshot
|
|
|
- if (data.queryName in config.formConfig.entries)
|
|
|
- entry=config.formConfig.entries[data.queryName];
|
|
|
+ //assume data is set in config.formConfig.dataQueries[data.queryName].rows;
|
|
|
+
|
|
|
+
|
|
|
+ let entry=new Object();
|
|
|
+
|
|
|
+ //data snapshot
|
|
|
+ let fQuery=config.formConfig.dataQueries[listName];
|
|
|
+
|
|
|
+ //here I assume that listName was parsed during setDataLayout and setData
|
|
|
+ //so that rows was set (even if they are empty)
|
|
|
+ print("Nrows "+fQuery.rows.length);
|
|
|
|
|
|
+ if (fQuery.rows.length>0)
|
|
|
+ entry=fQuery.rows[0];
|
|
|
|
|
|
let tb=config.document.createElement('table');
|
|
|
tb.className="t2";
|
|
|
config.document.getElementById(divName).appendChild(tb);
|
|
|
|
|
|
//this are the fields (probably constant)
|
|
|
- let fields=config.formConfig.dataFields[data.queryName];
|
|
|
+ let fields=fQuery.fields;
|
|
|
+
|
|
|
for (f in fields){
|
|
|
let field=fields[f];
|
|
|
+ //each field is a new row
|
|
|
+ print("Adding field: "+f+'/'+field.name);
|
|
|
if (field.hidden) continue;
|
|
|
-
|
|
|
- let vName=field.name;
|
|
|
-
|
|
|
- if (debug) print("Field ["+vName+"]");
|
|
|
- if (vName=="crfRef") continue;
|
|
|
-
|
|
|
- let vType=field.type;
|
|
|
- if (debug) print("Field ["+vName+"/"+vType+"]");
|
|
|
- let row=tb.insertRow();
|
|
|
- let cell=config.document.createElement('th');
|
|
|
- row.appendChild(cell);
|
|
|
- let text = config.document.createTextNode(fields[f].shortCaption);
|
|
|
- cell.appendChild(text);
|
|
|
- cell=row.insertCell();
|
|
|
-
|
|
|
- let varValue="UNDEF";
|
|
|
- if (vName in setup.filters) varValue=setup.filters[vName];
|
|
|
- if (vName in entry) varValue=entry[vName];
|
|
|
- if (vType=="date"){
|
|
|
- if (varValue==="UNDEF") varValue=new Date();
|
|
|
- else varValue=new Date(varValue);
|
|
|
- }
|
|
|
- if (debug) print("value: "+varValue);
|
|
|
- let input;
|
|
|
- if (setup.readonlyFlag(vName)){
|
|
|
- input=config.document.createTextNode(varValue);
|
|
|
- cell.id=setup.getInputId(vName);
|
|
|
- }
|
|
|
- else{
|
|
|
- cell.colSpan="3";
|
|
|
-
|
|
|
- let cellClass="input";
|
|
|
- let cellType="text";
|
|
|
- if ("lookup" in field){
|
|
|
- input = config.document.createElement("select");
|
|
|
- }
|
|
|
- if (vType=="date"){
|
|
|
- input = config.document.createElement("input");
|
|
|
- input.type="date";
|
|
|
- }
|
|
|
- if (vType=="string"){
|
|
|
- if (varValue==null) varValue="UNDEF";
|
|
|
- else{
|
|
|
- if (varValue.length==0)
|
|
|
- varValue="UNDEF";
|
|
|
- }
|
|
|
- }
|
|
|
- if (vType=="string" && !("lookup" in field)){
|
|
|
- if(vName.search("reviewComment")>-1){
|
|
|
- input = config.document.createElement("textarea");
|
|
|
- input.cols="65";
|
|
|
- input.rows="5";
|
|
|
- }
|
|
|
- else{
|
|
|
- input=config.document.createElement('input');
|
|
|
- if (vName.search('_file_')>-1){
|
|
|
- print('varValue: '+varValue);
|
|
|
- if (varValue=="UNDEF")
|
|
|
- input.type="file";
|
|
|
- else
|
|
|
- input.type="text";
|
|
|
- }
|
|
|
- else{
|
|
|
- input.type="text";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (vType=="float"){
|
|
|
- input = config.document.createElement("input");
|
|
|
- input.type="text";
|
|
|
- }
|
|
|
- if (vType=="boolean"){
|
|
|
- input = config.document.createElement("input");
|
|
|
- input.type="checkbox";
|
|
|
- print("Creating checkbox");
|
|
|
- }
|
|
|
-
|
|
|
- input.id=setup.getInputId(vName);
|
|
|
- if (varValue != "UNDEF"){
|
|
|
- if (vType=="string")
|
|
|
- input.value=varValue;
|
|
|
- if (vType=="float") input.value=varValue;
|
|
|
- if (vType=="date") input.valueAsDate=varValue;
|
|
|
- if (vType=="boolean") input.checked=varValue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- cell.appendChild(input);
|
|
|
-
|
|
|
- if ("lookup" in field){
|
|
|
- let lookup=field["lookup"];
|
|
|
- let qconfig=new Object();
|
|
|
- if (debug) print("populateTable lookup: Query: "+lookup.queryName);
|
|
|
- qconfig.containerPath=config.containerPath;
|
|
|
- qconfig.schemaName=lookup.schemaName;
|
|
|
- qconfig.queryName=lookup.queryName;
|
|
|
- let parameters= new Object();
|
|
|
- parameters.elementId=setup.getInputId(vName);
|
|
|
- parameters.keyColumn=lookup.keyColumn;
|
|
|
- parameters.displayColumn=lookup.displayColumn;
|
|
|
-
|
|
|
- if (vName in setup.filters) parameters.selectedKey=setup.filters[vName];
|
|
|
- if (vName in entry) parameters.selectedKey=entry[vName];
|
|
|
-
|
|
|
- if ("showFlag" in additionalData) parameters.additionalData=additionalData;
|
|
|
- if (debug) print("Populate select for "+parameters.elementId);
|
|
|
- qconfig.success=function(data){
|
|
|
- populateSelect(data,parameters,setup,setup.readonlyFlag(vName))
|
|
|
- };
|
|
|
- LABKEY.Query.selectRows(qconfig);
|
|
|
- }
|
|
|
+ if (field.name=="crfRef") continue;
|
|
|
+ addFieldRow(tb,entry,field,setup,additionalData);
|
|
|
|
|
|
}
|
|
|
//add comment field
|
|
@@ -1032,96 +1107,25 @@ function populateTable(data,divName,unique,additionalData,setup){
|
|
|
cell1.setAttribute("colspan","2");
|
|
|
cell1.id=setup.getInputId("rerviewLastSave");
|
|
|
cell1.innerHTML="No recent update";
|
|
|
+ //saveReview is a generic name for saving content of the html page to a list entry
|
|
|
input.onclick=function(){saveReview(data.queryName,cell1.id,setup)};
|
|
|
}
|
|
|
|
|
|
-function populateSelect(data,parameters,setup,readonlyFlag){
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- print("populateSelect on "+data.queryName);
|
|
|
- let elementId=parameters.elementId;
|
|
|
- let keyColumn=parameters.keyColumn;
|
|
|
- let displayColumn=parameters.displayColumn;
|
|
|
- if (debug){
|
|
|
- print("Query: "+data.queryName);
|
|
|
- print("ElementId: "+elementId);
|
|
|
- print("keyColumn: "+keyColumn);
|
|
|
- print("displayColumn: "+displayColumn);
|
|
|
- print("No of options: " +data.rows.length);
|
|
|
-
|
|
|
- if ("selectedKey" in parameters){
|
|
|
- print("SelectedKey: "+parameters["selectedKey"]);
|
|
|
- }
|
|
|
- }
|
|
|
- let el = config.document.getElementById(elementId);
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("Element: "+el);
|
|
|
-
|
|
|
- if (!readonlyFlag){
|
|
|
- //clear options
|
|
|
- for(i = el.options.length; i >= 0; i--) {
|
|
|
- el.remove(i);
|
|
|
- }
|
|
|
-
|
|
|
- let opt = config.document.createElement("option");
|
|
|
- opt.text = "<Select>";
|
|
|
- opt.value = -1;
|
|
|
- el.options[0] = opt;
|
|
|
- if (debug) print( "Adding <Select>");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for (let i = 0; i < data.rows.length; i++) {
|
|
|
- let displayText = data.rows[i][displayColumn];
|
|
|
- let keyValue = data.rows[i][keyColumn];
|
|
|
-
|
|
|
- if (!readonlyFlag){
|
|
|
- let opt = config.document.createElement("option");
|
|
|
-
|
|
|
- opt.text = displayText;
|
|
|
- opt.value = keyValue;
|
|
|
- el.options[el.options.length] = opt;
|
|
|
-
|
|
|
- }
|
|
|
- if (debug) print("Adding: "+keyValue+" : "+displayText);
|
|
|
-
|
|
|
- let t1=checkVariable(el,keyValue,displayText,parameters,"selectedKey",readonlyFlag);
|
|
|
- if (t1) setup.keyValue=keyValue;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (!("additionalData" in parameters)) return;
|
|
|
-
|
|
|
- if (debug) print("\n Parsing additional data ");
|
|
|
-
|
|
|
- let additionalData=parameters["additionalData"];
|
|
|
-
|
|
|
- let expId=setup.getInputId(additionalData.showFlag);
|
|
|
- if (expId!=elementId) {
|
|
|
- print("Element mismatch: got :"+expId+"/"+elementId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("Setting onChange to "+el.id);
|
|
|
-
|
|
|
- el.onchange=function(){setListVisibility(setup,additionalData,readonlyFlag)};
|
|
|
- setListVisibility(setup,additionalData,readonlyFlag);
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
function checkVariable(el,varValue,displayText, parameters,varName,readonlyFlag){
|
|
|
+ //set value with a little bit of QA
|
|
|
+ //parameters should contain varName or this will return false
|
|
|
+ //compares current varValue to value in parameters[varName], if they are equal,
|
|
|
+ //sets the selectedIndex to last one
|
|
|
let debug=true;
|
|
|
if (!varName in parameters) return false;
|
|
|
- if (debug) print("Comparing: " + varValue + "/" + parameters[varName]);
|
|
|
+ print("Comparing: " + varValue + "/" + parameters[varName]);
|
|
|
|
|
|
if (varValue==parameters[varName]){
|
|
|
if (readonlyFlag) el.innerHTML=displayText;
|
|
|
else {
|
|
|
+ //last one added?
|
|
|
el.selectedIndex=el.options.length-1;
|
|
|
- if (debug) print("Equal; "+el.selectedIndex);
|
|
|
+ print("Equal; "+el.selectedIndex);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -2179,8 +2183,8 @@ function afterConfig(){
|
|
|
|
|
|
|
|
|
//here we should get data. For now, just initialize objects that will hold data
|
|
|
- config.formConfig.dataFields=new Object();
|
|
|
- config.formConfig.entries=new Object();
|
|
|
+ //config.formConfig.dataFields=new Object();
|
|
|
+ //config.formConfig.entries=new Object();
|
|
|
setDataLayout(afterDataLayout);//callback is afterDataLayout
|
|
|
}
|
|
|
|
|
@@ -2355,8 +2359,11 @@ function afterFormDatasets(data){
|
|
|
config.formConfig.queryMap=new Object();
|
|
|
|
|
|
let rows=config.formConfig.formSetup.rows;
|
|
|
+
|
|
|
+ //should skip report only rows
|
|
|
for (let i=0;i<rows.length;i++){
|
|
|
let entry=rows[i];
|
|
|
+ let reviewField=(entry['showFlag']=='REVIEW');
|
|
|
let queryId=entry['queryName'];
|
|
|
let lookupRows=config.formConfig.formDatasets.rows;
|
|
|
print('QueryID['+i+']='+queryId);
|
|
@@ -2372,11 +2379,10 @@ function afterFormDatasets(data){
|
|
|
|
|
|
//update list of dataset formConfig is observing (fields/queryMap)
|
|
|
while (1){
|
|
|
+ //review contains no data
|
|
|
+ if (reviewField) break;
|
|
|
//already in fields
|
|
|
if (qName in config.formConfig.fields) break;
|
|
|
- //review fields don't go into fields
|
|
|
- if (entry['showFlag']=='REVIEW' ) break;
|
|
|
- //add
|
|
|
config.formConfig.fields[qName]=new Object();
|
|
|
break;
|
|
|
}
|
|
@@ -2384,12 +2390,11 @@ function afterFormDatasets(data){
|
|
|
while(1){
|
|
|
//already done
|
|
|
if (queryId in config.formConfig.queryMap) break;
|
|
|
- //skip review fields
|
|
|
- if (entry['showFlag']=='REVIEW' ) break;
|
|
|
- //add
|
|
|
config.formConfig.queryMap[queryId]=qName;
|
|
|
break;
|
|
|
}
|
|
|
+ if (reviewField) continue;
|
|
|
+ //only do this for real lists
|
|
|
let field=config.formConfig.fields[qName];
|
|
|
field.title=entry['title'];
|
|
|
field.queryId=queryId;
|
|
@@ -2414,6 +2419,9 @@ function setDataLayout(cb){
|
|
|
config.formConfig.lookup=new Object();
|
|
|
for (let i=0;i<rowsSetup.length;i++){
|
|
|
let entry=rowsSetup[i];
|
|
|
+ //skip review rows
|
|
|
+ if (entry['showFlag']=='REVIEW')
|
|
|
+ continue;
|
|
|
let queryId=entry['queryName'];
|
|
|
let queryName=qMap[entry['queryName']];
|
|
|
dS[queryName]=new Object();
|
|
@@ -2506,8 +2514,8 @@ function afterDatasets(data,cb){
|
|
|
function addLookup(data,qobject,f,cb){
|
|
|
print("Adding lookup "+data.queryName+' '+qobject+' '+f);
|
|
|
let lObject=config.formConfig.lookup[data.queryName];
|
|
|
- lObject.LUT=new Object();//key to value
|
|
|
- lObject.ValToKey=new Object();//value to key
|
|
|
+ lObject.LUT=new Array();//key to value
|
|
|
+ lObject.ValToKey=new Array();//value to key
|
|
|
let key=lObject.keyColumn;
|
|
|
let val=lObject.displayColumn;
|
|
|
|
|
@@ -2545,23 +2553,25 @@ function dataLayoutSet(){
|
|
|
}
|
|
|
|
|
|
function setData(cb){
|
|
|
- //collect data and execute callback cb
|
|
|
-
|
|
|
-
|
|
|
+ //collect data and execute callback cb for queries in cb.queryList
|
|
|
for (q in config.formConfig.dataQueries){
|
|
|
- config.formConfig.dataQueries[q].collectingData="STARTED";
|
|
|
+ let fQuery=config.formConfig.dataQueries[q];
|
|
|
+ fQuery.collectingData="STARTED";
|
|
|
let selectRows=new Object();
|
|
|
selectRows.queryName=q;
|
|
|
selectRows.schemaName='lists';
|
|
|
- selectRows.filterArray=[LABKEY.Filter.create("crfRef",getCRFref())];
|
|
|
+ selectRows.filterArray=[
|
|
|
+ LABKEY.Filter.create("crfRef",getCRFref())
|
|
|
+ ];
|
|
|
selectRows.success=function(data){assembleData(data,cb);};
|
|
|
LABKEY.Query.selectRows(selectRows);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function assembleData(data,cb){
|
|
|
- config.formConfig.dataQueries[data.queryName].rows=data.rows;
|
|
|
- config.formConfig.dataQueries[data.queryName].collectingData="FINISHED";
|
|
|
+ let fQuery=config.formConfig.dataQueries[data.queryName];
|
|
|
+ fQuery.rows=data.rows;
|
|
|
+ fQuery.collectingData="FINISHED";
|
|
|
for (q in config.formConfig.dataQueries){
|
|
|
let dq=config.formConfig.dataQueries[q];
|
|
|
//print("assembleData ["+q+"]: "+dq.collectingData);
|