6060import org .labkey .api .view .JspView ;
6161import org .labkey .api .view .VBox ;
6262import org .labkey .api .view .ViewServlet ;
63+ import org .labkey .api .view .template .PageConfig ;
6364import org .labkey .api .writer .HtmlWriter ;
6465import org .labkey .luminex .model .Analyte ;
6566import org .labkey .luminex .model .SinglePointControl ;
@@ -324,7 +325,7 @@ else if (analyteDefaultValue != null)
324325 }
325326
326327 Titration existingTitration = existingTitrations .get (titrationEntry .getKey ());
327- String propertyName = getTitrationTypeCheckboxName (Titration .Type .standard , titrationEntry .getValue ());
328+ String propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , titrationEntry .getValue ());
328329 // If we have an existing titration as a baseline from the run we're replacing, use its value
329330 String defVal = existingTitration == null ? defaultWellRoleValues .get (propertyName ) : Boolean .toString (existingTitration .isStandard ());
330331
@@ -359,7 +360,7 @@ else if (titrationEntry.getValue().isStandard())
359360
360361 if (!titrationEntry .getValue ().isUnknown ())
361362 {
362- propertyName = getTitrationTypeCheckboxName (Titration .Type .standard , titrationEntry .getValue ());
363+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , titrationEntry .getValue ());
363364 // If we have an existing titration as a baseline from the run we're replacing, use its value
364365 defVal = existingTitration == null ? defaultWellRoleValues .get (propertyName ) : Boolean .toString (existingTitration .isStandard ());
365366 value = setInitialTitrationInput (errorReshow , propertyName , defVal , titrationEntry .getValue ().isStandard ()) ? "true" : "" ;
@@ -369,21 +370,21 @@ else if (titrationEntry.getValue().isStandard())
369370 value = toShowStandardCheckboxColumn (errorReshow , standardTitrations , titrationEntry .getValue ()) ? "true" : "" ;
370371 view .getDataRegion ().addHiddenFormField (getShowStandardCheckboxColumnName (titrationEntry .getValue ()), value );
371372
372- propertyName = getTitrationTypeCheckboxName (Titration .Type .qccontrol , titrationEntry .getValue ());
373+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .qccontrol , titrationEntry .getValue ());
373374 // If we have an existing titration as a baseline from the run we're replacing, use its value
374375 defVal = existingTitration == null ? defaultWellRoleValues .get (propertyName ) : Boolean .toString (existingTitration .isQcControl ());
375376 value = setInitialTitrationInput (errorReshow , propertyName , defVal , titrationEntry .getValue ().isQcControl ()) ? "true" : "" ;
376377 view .getDataRegion ().addHiddenFormField (propertyName , value );
377378
378- propertyName = getTitrationTypeCheckboxName (Titration .Type .othercontrol , titrationEntry .getValue ());
379+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .othercontrol , titrationEntry .getValue ());
379380 // If we have an existing titration as a baseline from the run we're replacing, use its value
380381 defVal = existingTitration == null ? defaultWellRoleValues .get (propertyName ) : Boolean .toString (existingTitration .isOtherControl ());
381382 value = setInitialTitrationInput (errorReshow , propertyName , defVal , titrationEntry .getValue ().isOtherControl ()) ? "true" : "" ;
382383 view .getDataRegion ().addHiddenFormField (propertyName , value );
383384 }
384385 else
385386 {
386- propertyName = getTitrationTypeCheckboxName (Titration .Type .unknown , titrationEntry .getValue ());
387+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .unknown , titrationEntry .getValue ());
387388 // If we have an existing titration as a baseline from the run we're replacing, use its value
388389 defVal = existingTitration == null ? defaultWellRoleValues .get (propertyName ) : Boolean .toString (existingTitration .isUnknown ());
389390 value = setInitialTitrationInput (errorReshow , propertyName , defVal , titrationEntry .getValue ().isUnknown ()) ? "true" : "" ;
@@ -400,7 +401,7 @@ else if (titrationEntry.getValue().isStandard())
400401
401402 boolean existingSinglePointControl = existingSinglePointControls .contains (singlePointControl );
402403
403- propertyName = getSinglePointControlCheckboxName (singlePointControl );
404+ propertyName = getSinglePointControlCheckboxNameAndId (singlePointControl );
404405 // If we have an existing singlePointControl as a baseline from the run we're replacing, use its value
405406 defVal = existingSinglePointControl ? "true" : defaultWellRoleValues .get (propertyName );
406407 value = setInitialSinglePointControlInput (errorReshow , propertyName , defVal ) ? "true" : "" ;
@@ -431,9 +432,9 @@ else if (titrationEntry.getValue().isStandard())
431432 @ Override
432433 public void writeSameCheckboxCell (RenderContext ctx , HtmlWriter out )
433434 {
434- String titrationCellName = PageFlowUtil .filter (getTitrationColumnCellName (titrationEntry .getValue ().getName ()));
435- // Use propName because ids can't have spaces
436- String groupName = ColumnInfo . propNameFromName (getColumns ().get (0 ).getFormFieldName (ctx ));
435+ String titrationCellName = PageFlowUtil .filter (getTitrationColumnCellNameAndId (titrationEntry .getValue ().getName ()));
436+ // DOM ids and JS function names can't have spaces
437+ String groupName = PageConfig . makeIdFromName (getColumns ().get (0 ).getFormFieldName (ctx ));
437438 String id = groupName + "CheckBox" ;
438439
439440 TD (
@@ -454,7 +455,8 @@ public void writeSameCheckboxCell(RenderContext ctx, HtmlWriter out)
454455 @ Override
455456 public void writeCopyableJavaScript (RenderContext ctx , Writer out ) throws IOException
456457 {
457- String groupName = ColumnInfo .propNameFromName (getColumns ().get (0 ).getFormFieldName (ctx ));
458+ // DOM ids and JS function names can't have spaces
459+ String groupName = PageConfig .makeIdFromName (getColumns ().get (0 ).getFormFieldName (ctx ));
458460 out .write ("function " + groupName + "Updated() {\n " );
459461 out .write (" if (document.getElementById('" + groupName + "CheckBox') != null && document.getElementById('" + groupName + "CheckBox').checked) {\n " );
460462 out .write (" var v = document.getElementsByName('" + getColumns ().get (0 ).getFormFieldName (ctx ) + "')[0].checked;\n " );
@@ -551,7 +553,7 @@ private JspView<LuminexRunUploadForm> addExclusionWarning(LuminexRunUploadForm f
551553
552554 private String getShowStandardCheckboxColumnName (Titration standard )
553555 {
554- String titrationCheckboxName = getTitrationTypeCheckboxName (Titration .Type .standard , standard );
556+ String titrationCheckboxName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , standard );
555557 return titrationCheckboxName + "_showcol" ;
556558 }
557559
@@ -692,19 +694,22 @@ protected RunStepHandler getRunStepHandler()
692694 return new LuminexRunStepHandler ();
693695 }
694696
695- public static String getTitrationTypeCheckboxName (Titration .Type type , Titration titration )
697+ public static String getTitrationTypeCheckboxNameAndId (Titration .Type type , Titration titration )
696698 {
697- return ColumnInfo .propNameFromName ("_titrationRole_" + type + "_" + titration .getName ());
699+ // DOM ids and JS function names can't have spaces
700+ return PageConfig .makeIdFromName ("_titrationRole_" + type + "_" + titration .getName ());
698701 }
699702
700- public static String getSinglePointControlCheckboxName (String singlePointControl )
703+ public static String getSinglePointControlCheckboxNameAndId (String singlePointControl )
701704 {
702- return ColumnInfo .propNameFromName ("_singlePointControl_" + singlePointControl );
705+ // DOM ids and JS function names can't have spaces
706+ return PageConfig .makeIdFromName ("_singlePointControl_" + singlePointControl );
703707 }
704708
705- public static String getTitrationColumnCellName (String titrationName )
709+ public static String getTitrationColumnCellNameAndId (String titrationName )
706710 {
707- return ColumnInfo .propNameFromName ("_titrationcell_" + titrationName );
711+ // DOM ids and JS function names can't have spaces
712+ return PageConfig .makeIdFromName ("_titrationcell_" + titrationName );
708713 }
709714
710715 protected class LuminexRunStepHandler extends RunStepHandler
@@ -807,21 +812,21 @@ public boolean executeStep(LuminexRunUploadForm form, BindException errors) thro
807812 // add the name/value pairs for the titration well role definition section
808813 if (!titrationEntry .getValue ().isUnknown ())
809814 {
810- propertyName = getTitrationTypeCheckboxName (Titration .Type .standard , titrationEntry .getValue ());
815+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , titrationEntry .getValue ());
811816 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
812817 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
813818
814- propertyName = getTitrationTypeCheckboxName (Titration .Type .qccontrol , titrationEntry .getValue ());
819+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .qccontrol , titrationEntry .getValue ());
815820 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
816821 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
817822
818- propertyName = getTitrationTypeCheckboxName (Titration .Type .othercontrol , titrationEntry .getValue ());
823+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .othercontrol , titrationEntry .getValue ());
819824 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
820825 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
821826 }
822827 else
823828 {
824- propertyName = getTitrationTypeCheckboxName (Titration .Type .unknown , titrationEntry .getValue ());
829+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .unknown , titrationEntry .getValue ());
825830 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
826831 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
827832 }
@@ -846,7 +851,7 @@ public boolean executeStep(LuminexRunUploadForm form, BindException errors) thro
846851 for (String singlePointControl : form .getParser ().getSinglePointControls ())
847852 {
848853 // add the name/value pairs for the singlePointControl well role definition section
849- String propertyName = getSinglePointControlCheckboxName (singlePointControl );
854+ String propertyName = getSinglePointControlCheckboxNameAndId (singlePointControl );
850855 boolean value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
851856 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
852857 }
0 commit comments