|
@@ -1265,7 +1265,7 @@ function populateField(entry,field,setup){
|
|
|
|
|
|
//date
|
|
//date
|
|
if (vType=="date"){
|
|
if (vType=="date"){
|
|
- if (varValue==="UNDEF") varValue=new Date();
|
|
|
|
|
|
+ if (varValue=="UNDEF") varValue=new Date();
|
|
else varValue=new Date(varValue);
|
|
else varValue=new Date(varValue);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1444,14 +1444,100 @@ function generateTable(listName,divName,additionalData,setup){
|
|
input.onclick=function(){saveReview(listName,cell1.id,setup)};
|
|
input.onclick=function(){saveReview(listName,cell1.id,setup)};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function setEntryFromElement(entry,elementId, field){
|
|
|
|
+ //set value to entry from element using representation (field) from labkey
|
|
|
|
+ //
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ let fName='setEntryFromElement';
|
|
|
|
+
|
|
|
|
+ let el=config.document.getElementById(elementId);
|
|
|
|
+
|
|
|
|
+ if (!el) {
|
|
|
|
+ print(fName+" element: "+elementId+" not found");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ print(fName+" element: "+elementId);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ let vName=field.name;
|
|
|
|
+ let vType=field.type;
|
|
|
|
+
|
|
|
|
+ let eType=el.nodeName.toLowerCase();
|
|
|
|
+
|
|
|
|
+ if (eType==="select"){
|
|
|
|
+ entry[vName]=el.options[el.selectedIndex].value;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (eType==="td"){
|
|
|
|
+ entry[vName]=el.innerText;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (vType=="date"){
|
|
|
|
+ let date=el.valueAsDate;
|
|
|
|
+ if (date==="null") return;
|
|
|
|
+
|
|
|
|
+ date.setUTCHours(12);
|
|
|
|
+ entry[vName]=date.toString();
|
|
|
|
+ print(fName+" setting date to "+entry[vName]);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (vType=="string"){
|
|
|
|
+ entry[vName]=el.value;
|
|
|
|
+
|
|
|
|
+ if (vName.search('_file_')<0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ //upload file
|
|
|
|
+ let id1=elementId+'_file_';
|
|
|
|
+ let input1=config.document.getElementById(id1);
|
|
|
|
+ print(fName+' attachment field: '+input1.value);
|
|
|
|
+ //entry[vName]=el.files[0].stream();
|
|
|
|
+ let ctx=new Object();
|
|
|
|
+ ctx['dirName']='consent';
|
|
|
|
+ ctx['ID']=entry['crfRef'];
|
|
|
|
+ //should point to data container
|
|
|
|
+ ctx['project']=getContainer('data');
|
|
|
|
+ //need ID->crf!
|
|
|
|
+ //assume crfRef will get set before this
|
|
|
|
+ //element is encountered
|
|
|
|
+ uploadFile(input1,ctx);
|
|
|
|
+ let fv=el.value;
|
|
|
|
+ let suf=fv.split('.').pop();
|
|
|
|
+ entry[vName]=entry['crfRef']+'.'+suf;
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (vType=="float" || vType=="int"){
|
|
|
|
+ entry[vName]=el.value;
|
|
|
|
+
|
|
|
|
+ if (vName=="queryName") {
|
|
|
|
+ print(fName+' parsing queryName: '+el.innerText);
|
|
|
|
+ entry[vName]=config.formConfig.fields[el.innerText].queryId;
|
|
|
|
+ //use queryMap lookup
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (vType=="boolean"){
|
|
|
|
+ entry[vName]=el.checked;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
function saveReview(queryName,elementId,setup){
|
|
function saveReview(queryName,elementId,setup){
|
|
//loads any queryName
|
|
//loads any queryName
|
|
|
|
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug) print("saveReview: elementId "+elementId+" queryName "+queryName);
|
|
if (debug) print("saveReview: elementId "+elementId+" queryName "+queryName);
|
|
let useInsert=false;
|
|
let useInsert=false;
|
|
|
|
+
|
|
|
|
+ let unique=("unique" in setup);
|
|
|
|
|
|
- if (!("unique" in setup)) useInsert=true;
|
|
|
|
|
|
+ if (!unique) useInsert=true;
|
|
|
|
|
|
let fQuery=config.formConfig.dataQueries[queryName];
|
|
let fQuery=config.formConfig.dataQueries[queryName];
|
|
|
|
|
|
@@ -1486,78 +1572,13 @@ function saveReview(queryName,elementId,setup){
|
|
//need to save queryName for reviewComments
|
|
//need to save queryName for reviewComments
|
|
|
|
|
|
let eId=setup.getInputId(vName);
|
|
let eId=setup.getInputId(vName);
|
|
-
|
|
|
|
- let el=config.document.getElementById(eId);
|
|
|
|
-
|
|
|
|
- if (!el) {
|
|
|
|
- if (debug) print("saveReview element: "+eId+" not found");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (debug) print("saveReview element: "+eId);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- let eType=el.nodeName.toLowerCase();
|
|
|
|
-
|
|
|
|
- if (eType==="select"){
|
|
|
|
- entry[vName]=el.options[el.selectedIndex].value;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (eType==="td"){
|
|
|
|
- entry[vName]=el.innerText;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (vType=="date"){
|
|
|
|
- let date=el.valueAsDate;
|
|
|
|
- if (date==="null") continue;
|
|
|
|
- date.setUTCHours(12);
|
|
|
|
- entry[vName]=date.toString();
|
|
|
|
- print("Setting date to "+entry[vName]);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (vType=="string"){
|
|
|
|
- entry[vName]=el.value;
|
|
|
|
-
|
|
|
|
- if (vName.search('_file_')<0)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- //upload file
|
|
|
|
- let id1=eId+'_file_';
|
|
|
|
- let input1=config.document.getElementById(id1);
|
|
|
|
- print('Attachment field: '+input1.value);
|
|
|
|
- //entry[vName]=el.files[0].stream();
|
|
|
|
- let ctx=new Object();
|
|
|
|
- ctx['dirName']='consent';
|
|
|
|
- ctx['ID']=entry['crfRef'];
|
|
|
|
- //should point to data container
|
|
|
|
- ctx['project']=getContainer('data');
|
|
|
|
- //need ID->crf!
|
|
|
|
- //assume crfRef will get set before this
|
|
|
|
- //element is encountered
|
|
|
|
- uploadFile(input1,ctx);
|
|
|
|
- let fv=el.value;
|
|
|
|
- let suf=fv.split('.').pop();
|
|
|
|
- entry[vName]=entry['crfRef']+'.'+suf;
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if (vType=="float" || vType=="int"){
|
|
|
|
- entry[vName]=el.value;
|
|
|
|
- if (vName=="queryName") {
|
|
|
|
- print('Parsing queryName: '+el.innerText);
|
|
|
|
- entry[vName]=config.formConfig.fields[el.innerText].queryId;
|
|
|
|
- //use queryMap lookup
|
|
|
|
- }
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (vType=="boolean"){
|
|
|
|
- entry[vName]=el.checked;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ //copy values from form to entry
|
|
|
|
+ setEntryFromElement(entry,eId,field);
|
|
|
|
+ if (!unique){
|
|
|
|
+ let foo=Object();
|
|
|
|
+ //reset the field value
|
|
|
|
+ populateField(foo,field,setup);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
let qconfig=new Object();
|
|
let qconfig=new Object();
|
|
@@ -3039,7 +3060,7 @@ function setFormConfig(){
|
|
//add object to store form related data
|
|
//add object to store form related data
|
|
config.formConfig=new Object();
|
|
config.formConfig=new Object();
|
|
|
|
|
|
- config.formConfig.softwareVersion='T.15.18';
|
|
|
|
|
|
+ config.formConfig.softwareVersion='T.15.20';
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
|
|
if (debug)
|
|
if (debug)
|