Selaa lähdekoodia

Adding SAE path that allows sponsor to view submitted SAE forms

Andrej Studen 1 vuosi sitten
vanhempi
commit
a072e6e85f
1 muutettua tiedostoa jossa 26 lisäystä ja 4 poistoa
  1. 26 4
      web/crfTecant/formPortal.js

+ 26 - 4
web/crfTecant/formPortal.js

@@ -71,7 +71,7 @@ formPortal.init=
 function(cb=null){
    let that=this;
    let action=function(){that.scriptsLoaded(cb);};
-   LABKEY.Utils.requiresScript(["crfTecant/runQuery.js","crfTecant/formGenerator.js"],action);
+   LABKEY.Utils.requiresScript(["crfTecant/runQuery.js","crfTecant/formGenerator.js","crfTecant/variableList.js"],action);
 }
 
 formPortal.scriptsLoaded=
@@ -213,7 +213,12 @@ function(entry,filter,settings){
 
    //only select forms where status matches the target status
    if (entry.FormStatus!=filter.formStatus){
-      return false;
+      //check for additionalStates
+      let addStates=filter.additionalVisibilityStates[filter.role];
+      this.print(fName+' addState['+filter.role+'] '+addStates);
+      if (!addStates) return false;
+      if (entry.FormStatus!=addStates) return false;
+
    }
 
    this.print(fName+' candidate '+entry.entryId);
@@ -355,6 +360,12 @@ function(){
       filter.formStatus=qForm[accessModeColumn];
 		this.print(fName+' target formStatus '+formStatus);
 
+      filter.additionalVisibilityStates=new Object();
+      let as=qForm["additionalVisibilityStates"];
+      if (as){
+         filter.additionalVisibilityStates=variableList.parseVariables(as);
+      }
+
 
 		for (let j=0;j<fEntries.length;j++){
          let entry=fEntries[j];
@@ -514,6 +525,14 @@ function(formId){
    let fName="[createForm]";
    let config=this.config;
 	let formConfig=config.formConfig;
+   let dataForms=formConfig.dataForms.rows;
+   let qForm=null;
+   for (let i=0;i<dataForms.length;i++){
+      if (dataForms[i].Key==formId){
+         qForm=dataForms[i];
+         break;
+      }
+   }
 
 	this.print(fName+" create form w/id "+formId);
 	
@@ -521,7 +540,8 @@ function(formId){
 	crfEntry.entryId=Date.now();
 	crfEntry["Date"]=new Date();
 	crfEntry["View"]="[VIEW]";
-	crfEntry.formStatus=1;//In progress
+	crfEntry.FormStatus=qForm["initialStatus"];//In progress
+   this.print(fName+" setting status to "+crfEntry.FormStatus);
 	//set other variables
 	//requires studyData as part of formConfig
 	let studyData=formConfig.studyData.rows[0];
@@ -539,13 +559,15 @@ function(formId){
    let crfStatus=new Object();
    crfStatus.entryId=crfEntry.entryId;
    crfStatus.submissionDate=new Date();
-   crfStatus.FormStatus=crfEntry.formStatus;
+   crfStatus.FormStatus=crfEntry.FormStatus;
    crfStatus.User=crfEntry.UserId;
    crfStatus.Form=crfEntry.Form;
    crfStatus.operator=config.role;
    crfStatus.action='createForm';
    let that=this;
    let cb=function(data){that.openForm(crfEntry);};
+   //this is for debug
+   //let cb=function(data){;};
    let containerPath=this.getContainer('data');
    let pass=function(data){formGenerator.insertRow('lists','crfStatus',crfStatus,cb,containerPath);};
    formGenerator.insertRow('lists','crfEntry',crfEntry,pass,this.getContainer('data'));