Browse Source

Adding option to lay out multichoice selects as a series of buttons as specialFields tagged as multiChoiceButtonRow

Andrej Studen 1 year ago
parent
commit
82b64a8e40
1 changed files with 26 additions and 12 deletions
  1. 26 12
      web/crf/crfVisitNew.js

+ 26 - 12
web/crf/crfVisitNew.js

@@ -559,16 +559,7 @@ function(tb,field,setup,additionalData){
 	      let lookup=field["lookup"];
 	      //get all values from config.formConfig.lookup[X]
 	      let lObject=crfData.getLookup(lookup.queryName);
-         if (crfSetup.getSettings("useRadioButtons")){
-            this.print('Use radio buttons');
-            //skip generating fields
-            return;
-            
-         }
-         else{
-            input = crfHTML.createSelect(lObject.LUT,null,cell1);
-         }
-
+         input = crfHTML.createSelect(lObject.LUT,null,cell1);
 			break;
 		}
 
@@ -637,7 +628,7 @@ function(tb,field,setup,additionalData){
 }
 
 crfVisit.addSpecialFieldRows=
-function(tb,specFieldSetup,setup){
+function(tb,field,specFieldSetup,setup){
    //tb is the table, specFieldSetup is a row from the table where special fields are being setup
    //the first column is fieldUID, which is a colon joined amalgation of queryName:fieldName
    let fieldUID=specFieldSetup["fieldUID"];
@@ -707,6 +698,29 @@ function(tb,specFieldSetup,setup){
       b.value="Generate ID";
 
    }
+   if (specFieldSetup['actionType']=='multiChoiceButtonRow'){
+      //need all options for the field
+      if (!("lookup" in field)) {
+         this.print(fieldUID+" only enabled for lookup fields");
+         return;
+      }
+	   let lookup=field["lookup"];
+      let lObject=crfData.getLookup(lookup.queryName);
+      let row=tb.insertRow();
+      let cell=crfHTML.createTblHeader(null,row);
+      crfHTML.createTextNode("All options",null,cell);
+      let cell1=row.insertCell();
+      cell1.colSpan="3";
+      for (let x in lObject.LUT){
+         let b=crfHTML.createButton(null,cell1);
+         b.id=fieldUID+':'+x;
+         b.value=lObject.LUT[x];
+         input=crfHTML.getElement(setup.getInputId(field.name));
+         b.onclick=function(){crfHTML.updateSelect(input,cell1,x,b.value);}
+      }
+      
+
+   }
 }
 
 crfVisit.populateFieldRow=		
@@ -974,7 +988,7 @@ function(listName,divName,additionalData,setup){
       let specialFields=crfSetup.getEntryMap('specialFields:fieldUID');
       if (fieldUID in specialFields){
          let specFieldSetup=specialFields[fieldUID];
-         this.addSpecialFieldRows(tb,specFieldSetup,setup);
+         this.addSpecialFieldRows(tb,field,specFieldSetup,setup);
       }