|
@@ -1982,8 +1982,8 @@ config.blob;
|
|
config.blobInterval;
|
|
config.blobInterval;
|
|
|
|
|
|
function checkBlob(){
|
|
function checkBlob(){
|
|
- print("Blob: "+config.blob);
|
|
|
|
- if (blob) {
|
|
|
|
|
|
+ print("checkBlob: "+config.blob);
|
|
|
|
+ if (config.blob) {
|
|
clearInterval(config.blobInterval);
|
|
clearInterval(config.blobInterval);
|
|
config.a.href = config.window.URL.createObjectURL(config.blob);
|
|
config.a.href = config.window.URL.createObjectURL(config.blob);
|
|
print("HREF: "+config.a.href);
|
|
print("HREF: "+config.a.href);
|
|
@@ -2003,11 +2003,11 @@ function printForm(){
|
|
|
|
|
|
let doPrint=false;
|
|
let doPrint=false;
|
|
|
|
|
|
- //let doc=new PDFDocument();
|
|
|
|
- //doc.fontSize(25).text("Some text with standard font Andrej!", 100, 100);
|
|
|
|
|
|
+ config.doc=new PDFDocument();
|
|
|
|
+ config.doc.fontSize(25).text("Some text with standard font Andrej!", 100, 100);
|
|
//doc.end();
|
|
//doc.end();
|
|
- //let stream = doc.pipe(blobStream()).on("finish",function(){
|
|
|
|
- // blob=stream.toBlob("application/pdf");});
|
|
|
|
|
|
+ let stream = config.doc.pipe(blobStream()).on("finish",function(){
|
|
|
|
+ config.blob=stream.toBlob("application/pdf");});
|
|
|
|
|
|
print("BLob: "+config.blob);
|
|
print("BLob: "+config.blob);
|
|
config.a = config.document.createElement("a");
|
|
config.a = config.document.createElement("a");
|
|
@@ -2015,7 +2015,8 @@ function printForm(){
|
|
config.a.innerHTML="Download PDF";
|
|
config.a.innerHTML="Download PDF";
|
|
config.a.style = "display: none";
|
|
config.a.style = "display: none";
|
|
config.count=0;
|
|
config.count=0;
|
|
- lobInterval=setInterval(checkBlob,1000);
|
|
|
|
|
|
+ //run until blob is set
|
|
|
|
+ config.blobInterval=setInterval(checkBlob,1000);
|
|
|
|
|
|
//pick data from crfForm list
|
|
//pick data from crfForm list
|
|
print("Printing form");
|
|
print("Printing form");
|
|
@@ -2030,6 +2031,7 @@ function printForm(){
|
|
selectRows.queryName=qName;
|
|
selectRows.queryName=qName;
|
|
selectRows.filterArray=[LABKEY.Filter.create('crfRef',config.formConfig.crfEntry['entryId'])];
|
|
selectRows.filterArray=[LABKEY.Filter.create('crfRef',config.formConfig.crfEntry['entryId'])];
|
|
selectRows.success=collectFormData;
|
|
selectRows.success=collectFormData;
|
|
|
|
+ //skip for now
|
|
LABKEY.Query.selectRows(selectRows);
|
|
LABKEY.Query.selectRows(selectRows);
|
|
//deal with additional data
|
|
//deal with additional data
|
|
}
|
|
}
|
|
@@ -2037,14 +2039,19 @@ function printForm(){
|
|
}
|
|
}
|
|
|
|
|
|
function collectFormData(data){
|
|
function collectFormData(data){
|
|
|
|
+ print(config,"Adding "+data.queryName);
|
|
|
|
+ config.doc.fontSize(25).text("Adding "+data.queryName, 100, 100);
|
|
config.formConfig.fields[data.queryName].data=data;
|
|
config.formConfig.fields[data.queryName].data=data;
|
|
for (f in config.formConfig.fields){
|
|
for (f in config.formConfig.fields){
|
|
let field=config.formConfig.fields[f];
|
|
let field=config.formConfig.fields[f];
|
|
|
|
+ //serve as monitor - if any of the fields has no data object, return in the loop.
|
|
|
|
+ //Only when all fields have a data entry one should exit
|
|
if ("data" in field) continue;
|
|
if ("data" in field) continue;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
print("All done");
|
|
print("All done");
|
|
formatFormData();
|
|
formatFormData();
|
|
|
|
+ config.doc.end();
|
|
}
|
|
}
|
|
|
|
|
|
function formatFormData(){
|
|
function formatFormData(){
|
|
@@ -2177,6 +2184,8 @@ function afterFormStatus(formConfig, data){
|
|
if (formConfig.formStatus=="Approved"){
|
|
if (formConfig.formStatus=="Approved"){
|
|
generateButton("submitDiv","Review submission",
|
|
generateButton("submitDiv","Review submission",
|
|
"Restore form for further review",onUpdateForReview);
|
|
"Restore form for further review",onUpdateForReview);
|
|
|
|
+ generateButton("submitDiv","Print form",
|
|
|
|
+ "Generate PDF",printForm);
|
|
done="TRUE";
|
|
done="TRUE";
|
|
}
|
|
}
|
|
if (done=="FALSE"){
|
|
if (done=="FALSE"){
|
|
@@ -2222,7 +2231,8 @@ function afterFormStatus(formConfig, data){
|
|
|
|
|
|
function setFormConfig(){
|
|
function setFormConfig(){
|
|
|
|
|
|
- //generateDebugSection(config);
|
|
|
|
|
|
+ //add object to store form related data
|
|
|
|
+ config.formConfig=new Object();
|
|
|
|
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
|
|
@@ -2234,7 +2244,6 @@ function setFormConfig(){
|
|
selectRows.schemaName='lists';
|
|
selectRows.schemaName='lists';
|
|
selectRows.queryName='crfEntry';
|
|
selectRows.queryName='crfEntry';
|
|
selectRows.filterArray=[LABKEY.Filter.create('entryId',getCRFref())];
|
|
selectRows.filterArray=[LABKEY.Filter.create('entryId',getCRFref())];
|
|
- config.formConfig=new Object();
|
|
|
|
//store form related data to this object
|
|
//store form related data to this object
|
|
selectRows.success=afterCRFEntry;
|
|
selectRows.success=afterCRFEntry;
|
|
LABKEY.Query.selectRows(selectRows);
|
|
LABKEY.Query.selectRows(selectRows);
|