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,8 +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- 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 ));
436438 String id = groupName + "CheckBox" ;
437439
438440 TD (
@@ -453,7 +455,8 @@ public void writeSameCheckboxCell(RenderContext ctx, HtmlWriter out)
453455 @ Override
454456 public void writeCopyableJavaScript (RenderContext ctx , Writer out ) throws IOException
455457 {
456- 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 ));
457460 out .write ("function " + groupName + "Updated() {\n " );
458461 out .write (" if (document.getElementById('" + groupName + "CheckBox') != null && document.getElementById('" + groupName + "CheckBox').checked) {\n " );
459462 out .write (" var v = document.getElementsByName('" + getColumns ().get (0 ).getFormFieldName (ctx ) + "')[0].checked;\n " );
@@ -550,7 +553,7 @@ private JspView<LuminexRunUploadForm> addExclusionWarning(LuminexRunUploadForm f
550553
551554 private String getShowStandardCheckboxColumnName (Titration standard )
552555 {
553- String titrationCheckboxName = getTitrationTypeCheckboxName (Titration .Type .standard , standard );
556+ String titrationCheckboxName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , standard );
554557 return titrationCheckboxName + "_showcol" ;
555558 }
556559
@@ -691,19 +694,22 @@ protected RunStepHandler getRunStepHandler()
691694 return new LuminexRunStepHandler ();
692695 }
693696
694- public static String getTitrationTypeCheckboxName (Titration .Type type , Titration titration )
697+ public static String getTitrationTypeCheckboxNameAndId (Titration .Type type , Titration titration )
695698 {
696- 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 ());
697701 }
698702
699- public static String getSinglePointControlCheckboxName (String singlePointControl )
703+ public static String getSinglePointControlCheckboxNameAndId (String singlePointControl )
700704 {
701- return ColumnInfo .propNameFromName ("_singlePointControl_" + singlePointControl );
705+ // DOM ids and JS function names can't have spaces
706+ return PageConfig .makeIdFromName ("_singlePointControl_" + singlePointControl );
702707 }
703708
704- public static String getTitrationColumnCellName (String titrationName )
709+ public static String getTitrationColumnCellNameAndId (String titrationName )
705710 {
706- return ColumnInfo .propNameFromName ("_titrationcell_" + titrationName );
711+ // DOM ids and JS function names can't have spaces
712+ return PageConfig .makeIdFromName ("_titrationcell_" + titrationName );
707713 }
708714
709715 protected class LuminexRunStepHandler extends RunStepHandler
@@ -806,21 +812,21 @@ public boolean executeStep(LuminexRunUploadForm form, BindException errors) thro
806812 // add the name/value pairs for the titration well role definition section
807813 if (!titrationEntry .getValue ().isUnknown ())
808814 {
809- propertyName = getTitrationTypeCheckboxName (Titration .Type .standard , titrationEntry .getValue ());
815+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .standard , titrationEntry .getValue ());
810816 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
811817 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
812818
813- propertyName = getTitrationTypeCheckboxName (Titration .Type .qccontrol , titrationEntry .getValue ());
819+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .qccontrol , titrationEntry .getValue ());
814820 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
815821 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
816822
817- propertyName = getTitrationTypeCheckboxName (Titration .Type .othercontrol , titrationEntry .getValue ());
823+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .othercontrol , titrationEntry .getValue ());
818824 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
819825 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
820826 }
821827 else
822828 {
823- propertyName = getTitrationTypeCheckboxName (Titration .Type .unknown , titrationEntry .getValue ());
829+ propertyName = getTitrationTypeCheckboxNameAndId (Titration .Type .unknown , titrationEntry .getValue ());
824830 value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
825831 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
826832 }
@@ -845,7 +851,7 @@ public boolean executeStep(LuminexRunUploadForm form, BindException errors) thro
845851 for (String singlePointControl : form .getParser ().getSinglePointControls ())
846852 {
847853 // add the name/value pairs for the singlePointControl well role definition section
848- String propertyName = getSinglePointControlCheckboxName (singlePointControl );
854+ String propertyName = getSinglePointControlCheckboxNameAndId (singlePointControl );
849855 boolean value = getViewContext ().getRequest ().getParameter (propertyName ).equals ("true" );
850856 defaultWellRoleValues .put (propertyName , Boolean .toString (value ));
851857 }
0 commit comments