|
@@ -368,8 +368,201 @@ function populateSelect(data,selectedData, par, rowId){
|
|
|
row.callback(par,rowId);
|
|
|
}
|
|
|
|
|
|
-//populateSelect, populateSelectNotLookup
|
|
|
+function generateListAndPopulateDaughterSelect(par,rowId){
|
|
|
+ let debug=true;
|
|
|
+
|
|
|
+ if (debug){
|
|
|
+ print(par.config,"generateListAndPopulateDaughter");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ generateList(par,rowId);
|
|
|
+ let row=par.vars[rowId];
|
|
|
+ if ("daughterSelect" in row){
|
|
|
+ populateDaughterSelect(par,rowId,row["daughterSelect"],null);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function populateDaughterSelect(par,rowId,daughterRowId,entry){//populateSelectNotLookup
|
|
|
+ let debug=true;
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"populateDaughterSelect: "+rowId+" "+daughterRowId);
|
|
|
+
|
|
|
+ let row=par.vars[rowId];
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"row["+rowId+"]:"+row);
|
|
|
+
|
|
|
+ let daughterRow=par.vars[daughterRowId];
|
|
|
+
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"daughterRow["+daughterRowId+"]:"+daughterRow);
|
|
|
+
|
|
|
+ let el=par.config.document.getElementById(row.selectId);
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"\n Element:"+el);
|
|
|
+ let varValue=el.options[el.selectedIndex].value;
|
|
|
+
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"\nAdding filter ["+row.masterSelectVarName+"]:"+varValue);
|
|
|
+
|
|
|
+ let config=generateQConfig(par.masterQuery)
|
|
|
+ config.filterArray=[];
|
|
|
+ for (let i=0;i < par.filters.length;i++){
|
|
|
+ let filterRowId=par.filters[i];
|
|
|
+ let filterRow=par.vars[filterRowId];
|
|
|
+ let filterValue=par.config.document.getElementById(filterRow.selectId).value;
|
|
|
+ config.filterArray.push(LABKEY.Filter.create(filterRow.masterSelectVarName,filterValue));
|
|
|
+ }
|
|
|
+ config.success=function(data){populateSelectNotLookup(data,par,daughterRowId,entry)};
|
|
|
+ LABKEY.Query.selectRows(config);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function populateSelectNotLookup(data,par,rowId, entry){
|
|
|
+ //selectId
|
|
|
+ //masterSelectVarName
|
|
|
+
|
|
|
+ let debug=true;
|
|
|
+
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"populateSelectNonLookup on "+data.queryName);
|
|
|
+
|
|
|
+ let row=par.vars[rowId];
|
|
|
+ let varName=row.masterSelectVarName;
|
|
|
+ if (debug) print(par.config,"var "+varName+" rows "+data.rows.length);
|
|
|
+
|
|
|
+ if (debug) print(par.config,"Getting element "+row.selectId);
|
|
|
+
|
|
|
+ let el=par.config.document.getElementById(row.selectId);
|
|
|
+
|
|
|
+ if (!el) {
|
|
|
+ print(par.config,"Element not found");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (debug) print(par.config,"Element "+el);
|
|
|
+ if (debug) print(par.config,"Clearing entries");
|
|
|
+
|
|
|
+ //remove previous options
|
|
|
+ for(i = el.options.length; i >= 0; i--) {
|
|
|
+ el.remove(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Adding entries");
|
|
|
+
|
|
|
+ if ("addSelect" in row){
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"adding <Select>");
|
|
|
+
|
|
|
+ let opt = par.config.document.createElement("option");
|
|
|
+ opt.text = "<Select>";
|
|
|
+ opt.value = -2;
|
|
|
+ el.options[0] = opt;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("addNewFlag" in row){
|
|
|
+ if (debug) print(par.config,"adding Add new");
|
|
|
+ let opt = par.config.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(par.config,"adding "+valEntry[varName]);
|
|
|
+ let opt = par.config.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(par,rowId);
|
|
|
+}
|
|
|
|
|
|
-function generateListAndPopulateDaughterSelect(par,rowId){;}
|
|
|
-function generateList(par,rowId){;}
|
|
|
|
|
|
+function generateList(par,rowId){
|
|
|
+ let row=par.vars[rowId];
|
|
|
+ let debug=true;
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"generateList: "+par.masterQuery);
|
|
|
+
|
|
|
+ //ignore authorization, just select on select variable
|
|
|
+ let el=par.config.document.getElementById(row.selectId);
|
|
|
+ let varValue=el.options[el.selectedIndex].value;
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Using value "+varValue+" from "+row.selectId);
|
|
|
+
|
|
|
+ let iValue=parseInt(varValue);
|
|
|
+
|
|
|
+ let div=par.config.document.getElementById(par.addDiv);
|
|
|
+ div.style.display="none";
|
|
|
+ //add new crf entry
|
|
|
+ if ("addNewFlag" in row){
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Comparing " + iValue + "/" + row.addNewFlag);
|
|
|
+
|
|
|
+ if (iValue==row.addNewFlag) {
|
|
|
+ addNew(par);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //do filtering
|
|
|
+ let filterArray=[];
|
|
|
+ for (let i=0;i < par.filters.length;i++){
|
|
|
+ let filterRowId=par.filters[i];
|
|
|
+ let filterRow=par.vars[filterRowId];
|
|
|
+ let filterValue=par.config.document.getElementById(filterRow.selectId).value;
|
|
|
+ filterArray.push(LABKEY.Filter.create(filterRow.masterSelectVarName,filterValue));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //show all for system entries (Select, Add New)
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Using iValue "+iValue);
|
|
|
+ if (iValue<0) {
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Ignoring ["+row.masterSelectVarName+ "]: "+varValue);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Filtering ["+row.masterSelectVarName+"]: "+varValue);
|
|
|
+
|
|
|
+ if (rowId==="Crf"){
|
|
|
+ filterArray.push(LABKEY.Filter.create(row.masterSelectVarName,varValue));
|
|
|
+ if (debug)
|
|
|
+ print(par.config,"Filtering ["+row.masterSelectVarName+"]: "+varValue);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var config=generateQConfig(par.masterQuery);
|
|
|
+ config.renderTo=par.dataDiv;
|
|
|
+ config.buttonBarPosition='top';
|
|
|
+ config.filters=filterArray;
|
|
|
+ config.viewName="sparseView";
|
|
|
+ config.success=function(data){updateSuccess(data,par)};
|
|
|
+ config.failure=function(json){updateFailure(json,par)};
|
|
|
+
|
|
|
+ LABKEY.QueryWebPart(config);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function updateSuccess(data,par){
|
|
|
+ print(par.config,"Update success");
|
|
|
+}
|
|
|
+
|
|
|
+function updateFailure(json,par){
|
|
|
+ print(par.config,"Update failed");
|
|
|
+
|
|
|
+}
|