|
@@ -1,50 +1,6 @@
|
|
|
-function drawForm(par){
|
|
|
-
|
|
|
- populateSourceTable(par);
|
|
|
|
|
|
- let tableId="entryTable";
|
|
|
- generateTable("formDiv",tableId);
|
|
|
- generateRow(tableId, par,"User");
|
|
|
-
|
|
|
- populateSelectTableEntry(par,"User");
|
|
|
-
|
|
|
- generateRow(tableId, par,"Site");
|
|
|
- generateRow(tableId, par, "FormStatus");
|
|
|
- generateRow(tableId, par,"Crf");
|
|
|
-
|
|
|
- populateSelectTableEntry(par,"Site");
|
|
|
- populateSelectTableEntry(par,"FormStatus");
|
|
|
-
|
|
|
- let formTableId="selectFormTable";
|
|
|
- generateTable("selectFormDiv",formTableId);
|
|
|
- generateRow(formTableId,par,"Form");
|
|
|
-
|
|
|
- generateButtonRow(formTableId,"Add new CRF","Add", par, addNewEntry);
|
|
|
-
|
|
|
- populateSelectTableEntry(par,"Form");
|
|
|
-
|
|
|
- generateTable("startDiv","startTable");
|
|
|
- generateButtonRow("startTable","Start filling the selected form","Start", par, startForm);
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function generateQConfig(listName){
|
|
|
- let qConfig=new Object();
|
|
|
- qConfig.containerPath="TECANT/Data";
|
|
|
- qConfig.schemaName="lists";
|
|
|
- qConfig.queryName=listName;
|
|
|
- return qConfig;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-function sourceVar(crfEntryName,elementId,sourceName){
|
|
|
- let f=new Object();
|
|
|
- f.masterSelectVarName=crfEntryName;
|
|
|
- f.selectId=elementId;
|
|
|
- f.inputType="innerHTML";
|
|
|
- f.sourceSelectVarName=sourceName;
|
|
|
- return f;
|
|
|
+function print(config,msg){
|
|
|
+ config.document.getElementById(config.debugId).value+="\n"+msg;
|
|
|
}
|
|
|
|
|
|
function generateHead(config, headDivName,divName,title){
|
|
@@ -83,620 +39,4 @@ function toggleVisibility(config,divName,buttonName){
|
|
|
config.document.getElementById(buttonName).value="Show";
|
|
|
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-function populateSourceTable(par){
|
|
|
- let debug=true;
|
|
|
- if (debug){
|
|
|
- document.getElementById('formStatus').value +=
|
|
|
- "\npopulateSourceTable: Starting";
|
|
|
- }
|
|
|
- let config=generateQConfig(par.source.queryName);
|
|
|
- config.schemaName=par.source.schemaName;
|
|
|
-
|
|
|
- if (!("source" in par)) return;
|
|
|
- if (debug){
|
|
|
- print(par.config,"populateSourceTable ["+par.source.queryName+"]");
|
|
|
- }
|
|
|
-
|
|
|
- config.success=function(data){populateSourceTableData(data,par)};
|
|
|
- config.failure=function(errorTxt){print(par.config,"populateSourceData:fail")};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
-}
|
|
|
-
|
|
|
-function print(config,msg){
|
|
|
- config.document.getElementById(config.debugId).value +="\n"+msg;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function populateSourceTableData(data,par){
|
|
|
- let debug=true;
|
|
|
- if (debug){
|
|
|
- document.getElementById('formStatus').value +=
|
|
|
- "\npopulateSourceTableData: nrow: "+data.rows.length;
|
|
|
- }
|
|
|
- let entry=data.rows[0];
|
|
|
- for (let i=0;i < par.source.vars.length;i++){
|
|
|
- let srcVarName=par.source.vars[i];
|
|
|
- if (debug){
|
|
|
- document.getElementById('formStatus').value +=
|
|
|
- "\npopulateSourceTable ["+srcVarName+"]";
|
|
|
- }
|
|
|
- let row=par.vars[srcVarName];
|
|
|
- let el=document.getElementById(row.selectId);
|
|
|
- if (debug){
|
|
|
- document.getElementById('formStatus').value +=
|
|
|
- "\nElement: "+el;
|
|
|
- }
|
|
|
- el.innerHTML=entry[row.sourceSelectVarName];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function populateSelectNotLookup(config,data,parameters,rowId, entry){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let debug=true;
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print(config,"populateSelectNonLookup on "+data.queryName);
|
|
|
-
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- let varName=row.masterSelectVarName;
|
|
|
- if (debug) print(config,"var "+varName+" rows "+data.rows.length);
|
|
|
-
|
|
|
- if (debug) print(config,"Getting element "+row.selectId);
|
|
|
-
|
|
|
- let el=document.getElementById(row.selectId);
|
|
|
-
|
|
|
- if (!el) {
|
|
|
- print(config,"Element not found");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (debug) print(config,"Element "+el);
|
|
|
- if (debug) print(config,"Clearing entries");
|
|
|
-
|
|
|
-
|
|
|
- for(i = el.options.length; i >= 0; i--) {
|
|
|
- el.remove(i);
|
|
|
- }
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print(config,"Adding entries");
|
|
|
-
|
|
|
- if ("addSelect" in row){
|
|
|
- if (debug)
|
|
|
- print(config,"adding <Select>");
|
|
|
-
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = "<Select>";
|
|
|
- opt.value = -2;
|
|
|
- el.options[0] = opt;
|
|
|
- }
|
|
|
-
|
|
|
- if ("addNewFlag" in row){
|
|
|
- if (debug) print(config,"adding Add new");
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = "Add New";
|
|
|
- opt.value = row.addNewFlag;
|
|
|
- el.options[el.options.length] = opt;
|
|
|
- }
|
|
|
-
|
|
|
- for (let i=0;i< data.rows.length;i++){
|
|
|
- let valEntry=data.rows[i];
|
|
|
- if (debug)
|
|
|
- print(config,"adding "+valEntry[varName]);
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = valEntry[varName];
|
|
|
- opt.value = valEntry[varName];
|
|
|
- if (entry){
|
|
|
- if (opt.value==entry[varName])
|
|
|
- el.selectedIndex=el.options.length-1;
|
|
|
- }
|
|
|
- el.options[el.options.length] = opt;
|
|
|
- }
|
|
|
- if (entry)
|
|
|
- row.callback(parameters,rowId);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function populateSelect(data,selectedData, parameters, rowId){
|
|
|
-
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- print("populateSelect Data: "+data.queryName+" selectedData:"+selectedData.queryName);
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- let selectId=row.selectId;
|
|
|
-
|
|
|
- let varName=row.masterSelectVarName;
|
|
|
- if ("filter" in row){
|
|
|
- varName=row.filter.filterVarName;
|
|
|
- }
|
|
|
- let field=getField(selectedData,varName);
|
|
|
-
|
|
|
- let displayColumn=field.lookup.displayColumn;
|
|
|
- let keyColumn=field.lookup.keyColumn;
|
|
|
-
|
|
|
- if (debug){
|
|
|
- document.getElementById('formStatus').value+="\n Query: "+data.queryName;
|
|
|
- document.getElementById('formStatus').value+="\n ElementId: "+selectId;
|
|
|
- document.getElementById('formStatus').value+="\n keyColumn: "+keyColumn;
|
|
|
- document.getElementById('formStatus').value+="\n displayColumn: "+displayColumn;
|
|
|
-
|
|
|
- }
|
|
|
- let el = document.getElementById(selectId);
|
|
|
-
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n Element: "+el;
|
|
|
-
|
|
|
- for(i = el.options.length; i >= 0; i--) {
|
|
|
- el.remove(i);
|
|
|
- }
|
|
|
- if ("addSelect" in row){
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = "<Select>";
|
|
|
- opt.value = -1;
|
|
|
- el.options[0] = opt;
|
|
|
- }
|
|
|
-
|
|
|
- if ("addNewFlag" in row){
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = "Add New"
|
|
|
- opt.value = row.addNewFlag;
|
|
|
- el.options[el.options.length] = opt;
|
|
|
- }
|
|
|
-
|
|
|
- for (var i = 0; i < data.rows.length; i++) {
|
|
|
- let key=data.rows[i][keyColumn];
|
|
|
- let skip=true;
|
|
|
- if (row.selectAll){
|
|
|
- skip=false;
|
|
|
- }
|
|
|
- else{
|
|
|
- if (debug)
|
|
|
- print("Selecting from: "+selectedData.rows.length);
|
|
|
- for (let j=0; j< selectedData.rows.length; j++){
|
|
|
- let entry=selectedData.rows[j];
|
|
|
- if (debug)
|
|
|
- print("Comparing: "+entry[varName]+"/"+key);
|
|
|
- if (key!=entry[varName]) continue;
|
|
|
- skip=false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (skip) continue;
|
|
|
- let opt = document.createElement("option");
|
|
|
- opt.text = data.rows[i][displayColumn];
|
|
|
- opt.value = data.rows[i][keyColumn];
|
|
|
- if (debug)
|
|
|
- print("Adding: "+opt.value+" : "+opt.text);
|
|
|
-
|
|
|
- el.options[el.options.length] = opt;
|
|
|
-
|
|
|
-
|
|
|
- if ("selectedKey" in row){
|
|
|
- if (debug)
|
|
|
- print("Comparing: " + opt.value + "/" + row["selectedKey"]);
|
|
|
-
|
|
|
- if (opt.value==row["selectedKey"]){
|
|
|
- el.selectedIndex=el.options.length-1;
|
|
|
- if (debug)
|
|
|
- print("Equal; "+el.selectedIndex);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (debug)
|
|
|
- print("Running callback");
|
|
|
-
|
|
|
- row.callback(parameters,rowId);
|
|
|
-}
|
|
|
-
|
|
|
-function saveData(queryName){
|
|
|
- document.getElementById('formStatus').value+="\n saveData: "+queryName;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function populateSelectTableEntry(parameters,rowId){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let debug=true;
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n populateSelectTableEntry:"
|
|
|
- +parameters.masterQuery+"/"+row.masterSelectVarName;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let config=generateQConfig(parameters.masterQuery);
|
|
|
-
|
|
|
- if ("filter" in row){
|
|
|
-
|
|
|
- let filter=row.filter;
|
|
|
- if (debug){
|
|
|
- print("Filter:"+filter.queryName);
|
|
|
- print("FilterVar "+filter.filterVarName);
|
|
|
- }
|
|
|
- config.queryName=filter.queryName;
|
|
|
- config.filterArray=[];
|
|
|
- for (f in filter.filters){
|
|
|
- if (debug) print("Adding filter: "+f+" val "+filter.filters[f]);
|
|
|
- config.filterArray.push(LABKEY.Filter.create(f,filter.filters[f]));
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- config.queryName=parameters.masterQuery;
|
|
|
- }
|
|
|
-
|
|
|
- config.success=function(data){populateTableRow(data,parameters,rowId)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
- if (debug)
|
|
|
- print("generateSelect: End");
|
|
|
- return;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function getField(data, varName){
|
|
|
- let debug=false;
|
|
|
- if (debug) print("getField");
|
|
|
- let fields=data.metaData.fields;
|
|
|
- for (f in fields){
|
|
|
- if (debug) print("Checking "+f+": name "+fields[f].name+"/"+varName);
|
|
|
- if (fields[f].name!=varName) continue;
|
|
|
- return fields[f];
|
|
|
- }
|
|
|
- return null;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function getCaption(data, varName){
|
|
|
- let field=getField(data,varName);
|
|
|
- if (field) return field.shortCaption;
|
|
|
- return "NONE";
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function generateTable(divName,elementId){
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n generateTable";
|
|
|
- let tb=document.createElement('table');
|
|
|
- tb.className="t2";
|
|
|
- tb.id=elementId;
|
|
|
- document.getElementById(divName).appendChild(tb);
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n generateTable: Done";
|
|
|
-}
|
|
|
-
|
|
|
-function generateRow(tableId, parameters,rowId){
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n generateRow: Start";
|
|
|
- let config=generateQConfig(parameters.masterQuery);
|
|
|
- config.success=function(data){generateTableRow(data,tableId, parameters,rowId)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
- if (debug)
|
|
|
- document.getElementById('formStatus').value+="\n generateRow: End";
|
|
|
- return;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function generateTableRow(data,tableId, parameters,rowId){
|
|
|
- let tb=document.getElementById(tableId);
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- let field=getField(data,row.masterSelectVarName);
|
|
|
- let trow=tb.insertRow();
|
|
|
- let cell=document.createElement('th');
|
|
|
- trow.appendChild(cell);
|
|
|
- let text = document.createTextNode(field.shortCaption);
|
|
|
- cell.appendChild(text);
|
|
|
- cell=trow.insertCell();
|
|
|
- let input = document.createElement("select");
|
|
|
- input.id = row.selectId;
|
|
|
- input.onchange=function(){row.callback(parameters,rowId)};
|
|
|
- cell.appendChild(input);
|
|
|
-}
|
|
|
-
|
|
|
-function populateTableRow(data,parameters,rowId){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let debug=true;
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- let varName=row.masterSelectVarName;
|
|
|
- if ("filter" in row){
|
|
|
- if (row.filter.queryName==data.queryName){
|
|
|
- varName=row.filter.filterVarName;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("generateSelectVar: "+data.queryName+"/"+varName+" size "+data.rows.length);
|
|
|
-
|
|
|
- let field=getField(data,varName);
|
|
|
-
|
|
|
- if (!field) {
|
|
|
- print("Field "+varName+" not found");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!("lookup" in field)){
|
|
|
- let entry=data.rows[0];
|
|
|
- print("Field "+varName+" not a lookup");
|
|
|
- populateSelectNotLookup(data,parameters,rowId, entry);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- let config=generateQConfig(field.lookup.queryName);
|
|
|
- config.schemaName=field.lookup.schemaName;
|
|
|
- config.success=function(lookupData){populateSelect(lookupData,data,parameters,rowId)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("generateSelectVar: End");
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function generateButtonRow(tableId,caption,label,parameters,callback){
|
|
|
- let tb=document.getElementById(tableId);
|
|
|
- let trow=tb.insertRow();
|
|
|
- let cell=document.createElement('th');
|
|
|
- trow.appendChild(cell);
|
|
|
- let text = document.createTextNode(caption);
|
|
|
- cell.appendChild(text);
|
|
|
- cell=trow.insertCell();
|
|
|
- let input = document.createElement("input");
|
|
|
- input.type="button";
|
|
|
- input.value=label;
|
|
|
- input.onclick=function(){callback(parameters)};
|
|
|
- cell.appendChild(input);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function generateListAndPopulateDaughterSelect(parameters,rowId){
|
|
|
- let debug=true;
|
|
|
-
|
|
|
- if (debug){
|
|
|
- print("generateListAndPopulateDaughter");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- generateList(parameters,rowId);
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- if ("daughterSelect" in row){
|
|
|
- populateDaughterSelect(parameters,rowId,row["daughterSelect"],null);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function populateDaughterSelect(parameters,rowId,daughterRowId,entry){
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- print("populateDaughterSelect: "+rowId+" "+daughterRowId);
|
|
|
-
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- if (debug)
|
|
|
- print("row["+rowId+"]:"+row);
|
|
|
-
|
|
|
- let daughterRow=parameters.vars[daughterRowId];
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("daughterRow["+daughterRowId+"]:"+daughterRow);
|
|
|
-
|
|
|
- let el=document.getElementById(row.selectId);
|
|
|
- if (debug)
|
|
|
- print("\n Element:"+el);
|
|
|
- let varValue=el.options[el.selectedIndex].value;
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("\nAdding filter ["+row.masterSelectVarName+"]:"+varValue);
|
|
|
-
|
|
|
- let config=generateQConfig(parameters.masterQuery)
|
|
|
- config.filterArray=[];
|
|
|
- for (let i=0;i < parameters.filters.length;i++){
|
|
|
- let filterRowId=parameters.filters[i];
|
|
|
- let filterRow=parameters.vars[filterRowId];
|
|
|
- let filterValue=document.getElementById(filterRow.selectId).value;
|
|
|
- config.filterArray.push(LABKEY.Filter.create(filterRow.masterSelectVarName,filterValue));
|
|
|
- }
|
|
|
- config.success=function(data){populateSelectNotLookup(data,parameters,daughterRowId,entry)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function generateList(parameters,rowId){
|
|
|
- let row=parameters.vars[rowId];
|
|
|
- let debug=true;
|
|
|
- if (debug)
|
|
|
- print("generateList: "+parameters.masterQuery);
|
|
|
-
|
|
|
-
|
|
|
- let el=document.getElementById(row.selectId);
|
|
|
- let varValue=el.options[el.selectedIndex].value;
|
|
|
- if (debug)
|
|
|
- print("Using value "+varValue+" from "+row.selectId);
|
|
|
-
|
|
|
- let iValue=parseInt(varValue);
|
|
|
-
|
|
|
- let div=document.getElementById(parameters.addDiv);
|
|
|
- div.style.display="none";
|
|
|
-
|
|
|
- if ("addNewFlag" in row){
|
|
|
- if (debug)
|
|
|
- print("Comparing " + iValue + "/" + row.addNewFlag);
|
|
|
-
|
|
|
- if (iValue==row.addNewFlag) {
|
|
|
- addNew(parameters);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let filterArray=[];
|
|
|
- for (let i=0;i < parameters.filters.length;i++){
|
|
|
- let filterRowId=parameters.filters[i];
|
|
|
- let filterRow=parameters.vars[filterRowId];
|
|
|
- let filterValue=document.getElementById(filterRow.selectId).value;
|
|
|
- filterArray.push(LABKEY.Filter.create(filterRow.masterSelectVarName,filterValue));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (debug)
|
|
|
- print("Using iValue "+iValue);
|
|
|
- if (iValue<0) {
|
|
|
- if (debug)
|
|
|
- print("Ignoring ["+row.masterSelectVarName+ "]: "+varValue);
|
|
|
- }
|
|
|
- else{
|
|
|
- if (debug)
|
|
|
- print("Filtering ["+row.masterSelectVarName+"]: "+varValue);
|
|
|
-
|
|
|
- if (rowId==="Crf"){
|
|
|
- filterArray.push(LABKEY.Filter.create(row.masterSelectVarName,varValue));
|
|
|
- if (debug)
|
|
|
- print("Filtering ["+row.masterSelectVarName+"]: "+varValue);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- LABKEY.QueryWebPart({renderTo: parameters.dataDiv, schemaName: 'lists',
|
|
|
- queryName: parameters.masterQuery,
|
|
|
- buttonBarPosition: 'top',filters: filterArray, viewName:"sparseView",
|
|
|
- success:updateSuccess, failure:updateFailure });
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function updateSuccess(){
|
|
|
- document.getElementById('formStatus').value+="\n Update success";
|
|
|
-}
|
|
|
-
|
|
|
-function updateFailure(json){
|
|
|
- document.getElementById('formStatus').value+="\n Update failed";
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function addNewEntry(parameters){
|
|
|
- print("Add new, npar ");
|
|
|
- let entry=new Object();
|
|
|
-
|
|
|
- for (vv in parameters.vars){
|
|
|
- let f=parameters.vars[vv];
|
|
|
- print("New: Adding "+f.masterSelectVarName);
|
|
|
- setValue(entry,f);
|
|
|
- }
|
|
|
- for (f in entry){
|
|
|
- print("entry ["+f+"]="+entry[f]);
|
|
|
- }
|
|
|
- entry.entryId=Date.now();
|
|
|
- entry.Date=new Date();
|
|
|
- entry.formStatus=1;
|
|
|
- let config=generateQConfig(parameters.masterQuery);
|
|
|
- config.rows=[entry];
|
|
|
- config.success=function(data){
|
|
|
- populateDaughterSelect(parameters,"Site","Crf",data.rows[0]);
|
|
|
- selectEntry(data,parameters.vars["Crf"]);
|
|
|
- generateList(parameters,"Crf");};
|
|
|
- LABKEY.Query.insertRows(config);
|
|
|
-}
|
|
|
-
|
|
|
-function selectEntry(data,row){
|
|
|
- let entry=data.rows[0];
|
|
|
- let varName=row.masterSelectVarName;
|
|
|
- let el=document.getElementById(row.selectId);
|
|
|
- for (let i=0;i< el.options.length;i++){
|
|
|
- print("selectEntry: "+el.options[i].value+"/"+entry[varName]);
|
|
|
- if (el.options[i].value!=entry[varName]) continue;
|
|
|
- el.selectedIndex=i;
|
|
|
- return;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function setValue(entry,f){
|
|
|
- let el=document.getElementById(f.selectId);
|
|
|
- print("setValue: Element: "+el);
|
|
|
- if (f.inputType=="select"){
|
|
|
- entry[f.masterSelectVarName]=el.value;
|
|
|
- }
|
|
|
- if (f.inputType=="innerHTML"){
|
|
|
- entry[f.masterSelectVarName]=el.innerHTML;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function addNew(parameters){
|
|
|
- print("Show Add new");
|
|
|
- let div=document.getElementById(parameters.addDiv);
|
|
|
- div.style.display="block";
|
|
|
-}
|
|
|
-
|
|
|
-function startForm(parameters){
|
|
|
- let crfVar=parameters.vars["Crf"];
|
|
|
- let el=document.getElementById(crfVar.selectId);
|
|
|
- let config=generateQConfig(parameters.masterQuery);
|
|
|
- config.filterArray=[LABKEY.Filter.create(crfVar.masterSelectVarName,el.value)]
|
|
|
- config.success=function(data){findURL(data,parameters)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function findURL(data,parameters){
|
|
|
- let entry=data.rows[0];
|
|
|
-
|
|
|
- let fields=data.metaData.fields;
|
|
|
- let formVar=parameters.vars["Form"];
|
|
|
- let formVarName=formVar.masterSelectVarName;
|
|
|
- let lookup;
|
|
|
- for (f in fields){
|
|
|
- if (fields[f].name!=formVarName) continue;
|
|
|
- lookup=fields[f].lookup;
|
|
|
- break;
|
|
|
- }
|
|
|
- let config=generateQConfig(lookup.queryName);
|
|
|
- config.schemaName=lookup.schemaName;
|
|
|
- config.filterArray=[LABKEY.Filter.create(lookup.keyColumn,entry[formVarName])];
|
|
|
- config.success=function(data){finalRedirect(data,entry,parameters)};
|
|
|
- LABKEY.Query.selectRows(config);
|
|
|
-}
|
|
|
-
|
|
|
-function finalRedirect(data,entry,parameters){
|
|
|
- let formEntry=data.rows[0];
|
|
|
- let formVar=parameters.vars["Form"];
|
|
|
- let formUrl=formEntry[formVar.urlName];
|
|
|
- var params = {
|
|
|
- "name": formUrl,
|
|
|
- "userid": entry[parameters.vars["User"].masterSelectVarName],
|
|
|
- "entryId": entry[parameters.vars["Crf"].masterSelectVarName]
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var wikiURL = LABKEY.ActionURL.buildURL("wiki", "page", LABKEY.ActionURL.getContainer(), params);
|
|
|
- print("Redirecting to "+wikiURL);
|
|
|
-
|
|
|
- window.location = wikiURL;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-</script>
|
|
|
+}
|