|
@@ -21,6 +21,9 @@ function drawForm(par){
|
|
|
let formTableId="selectFormTable";
|
|
|
generateTable(par,"selectFormDiv",formTableId);
|
|
|
generateRow(par,formTableId,par,"Form");
|
|
|
+
|
|
|
+ generateButtonRow(formTableId,"Add new CRF","Add", par, addNewEntry);
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -55,6 +58,18 @@ function getField(config, data, varName){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+function selectEntry(data,config, row){
|
|
|
+ let entry=data.rows[0];
|
|
|
+ let varName=row.masterSelectVarName;
|
|
|
+ let el=config.document.getElementById(row.selectId);
|
|
|
+ for (let i=0;i< el.options.length;i++){
|
|
|
+ print(config,"selectEntry: "+el.options[i].value+"/"+entry[varName]);
|
|
|
+ if (el.options[i].value!=entry[varName]) continue;
|
|
|
+ el.selectedIndex=i;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
function generateHead(config, headDivName,divName,title){
|
|
|
print(config,"generateHead");
|
|
@@ -566,3 +581,44 @@ function updateFailure(json,par){
|
|
|
print(par.config,"Update failed");
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+function generateButtonRow(tableId,caption,label,par,callback){
|
|
|
+ let tb=par.config.document.getElementById(tableId);
|
|
|
+ let trow=tb.insertRow();
|
|
|
+ let cell=par.config.document.createElement('th');
|
|
|
+ trow.appendChild(cell);
|
|
|
+ let text = par.config.document.createTextNode(caption);
|
|
|
+ cell.appendChild(text);
|
|
|
+ cell=trow.insertCell();
|
|
|
+ let input = par.config.document.createElement("input");
|
|
|
+ input.type="button";
|
|
|
+ input.value=label;
|
|
|
+ input.onclick=function(){callback(par)};
|
|
|
+ cell.appendChild(input);
|
|
|
+}
|
|
|
+
|
|
|
+//callback candidate
|
|
|
+function addNewEntry(par){
|
|
|
+ print(par.config,"Add new, npar ");
|
|
|
+ let entry=new Object();
|
|
|
+
|
|
|
+ for (vv in par.vars){
|
|
|
+ let f=par.vars[vv];
|
|
|
+ print(par.config,"New: Adding "+f.masterSelectVarName);
|
|
|
+ setValue(entry,f);
|
|
|
+ }
|
|
|
+ for (f in entry){
|
|
|
+ print(par.config,"entry ["+f+"]="+entry[f]);
|
|
|
+ }
|
|
|
+ entry.entryId=Date.now();
|
|
|
+ entry.Date=new Date();
|
|
|
+ entry.formStatus=1;//In Progress
|
|
|
+ let config=generateQConfig(par.masterQuery);
|
|
|
+ config.rows=[entry];
|
|
|
+ config.success=function(data){
|
|
|
+ populateDaughterSelect(par,"Site","Crf",data.rows[0]);
|
|
|
+ selectEntry(par.config,data,par.vars["Crf"]);
|
|
|
+ generateList(par,"Crf");};
|
|
|
+ LABKEY.Query.insertRows(config);
|
|
|
+}
|