@Test public void selectedDisplay() { FormElement testYesNoPicker = mock(FormField.class); FormConditionalSubsection testConditionalSubsection = new FormConditionalSubsection( this.title, this.type, testYesNoPicker, true, false); FormField testFormField = mock(FormField.class); testConditionalSubsection.addElement(testFormField); Assert.assertEquals("<div class='section'>null<div class='dropdown invisible " + this.type + "'><div>null</div></div></div>", testConditionalSubsection.display( DisplayMode.Edit, new String[] { "phenotypes", "negative_phenotypes" })); Assert.assertEquals( "<div class='section value-checked'>title</div><div class='subsection " + this.type + "'>null</div>", testConditionalSubsection.display(DisplayMode.View, new String[] { "phenotypes", "negative_phenotypes" })); }
@Override public String display(DisplayMode mode, String[] fieldNames) { String displayedElements = super.display(mode, fieldNames); if (StringUtils.isBlank(displayedElements) && !this.yesSelected && !this.noSelected) { return ""; } if (DisplayMode.Edit.equals(mode)) { return "<div class='section'>" + this.titleYesNoPicker.display(mode, fieldNames) + "<div class='dropdown invisible " + this.type + "'><div>" + displayedElements + "</div></div></div>"; } else { String title = this.titleYesNoPicker.display(mode, fieldNames); return "<div class='section" + (StringUtils.isEmpty(title) ? " value-checked" : "") + "'>" + StringUtils.defaultIfEmpty(title, XMLUtils.escapeElementContent(this.title)) + "</div><div class='subsection " + this.type + "'>" + displayedElements + "</div>"; } }
FormConditionalSubsection extends FormGroup { @Override public String display(DisplayMode mode, String[] fieldNames) { String displayedElements = super.display(mode, fieldNames); if (StringUtils.isBlank(displayedElements) && !this.yesSelected && !this.noSelected) { return ""; } if (DisplayMode.Edit.equals(mode)) { return "<div class='section'>" + this.titleYesNoPicker.display(mode, fieldNames) + "<div class='dropdown invisible " + this.type + "'><div>" + displayedElements + "</div></div></div>"; } else { String title = this.titleYesNoPicker.display(mode, fieldNames); return "<div class='section" + (StringUtils.isEmpty(title) ? " value-checked" : "") + "'>" + StringUtils.defaultIfEmpty(title, XMLUtils.escapeElementContent(this.title)) + "</div><div class='subsection " + this.type + "'>" + displayedElements + "</div>"; } } }
FormConditionalSubsection extends FormGroup { @Override public String display(DisplayMode mode, String[] fieldNames) { String displayedElements = super.display(mode, fieldNames); if (StringUtils.isBlank(displayedElements) && !this.yesSelected && !this.noSelected) { return ""; } if (DisplayMode.Edit.equals(mode)) { return "<div class='section'>" + this.titleYesNoPicker.display(mode, fieldNames) + "<div class='dropdown invisible " + this.type + "'><div>" + displayedElements + "</div></div></div>"; } else { String title = this.titleYesNoPicker.display(mode, fieldNames); return "<div class='section" + (StringUtils.isEmpty(title) ? " value-checked" : "") + "'>" + StringUtils.defaultIfEmpty(title, XMLUtils.escapeElementContent(this.title)) + "</div><div class='subsection " + this.type + "'>" + displayedElements + "</div>"; } } FormConditionalSubsection(String title, String type, FormElement titleYesNoPicker, boolean yesSelected,
        boolean noSelected); }
FormConditionalSubsection extends FormGroup { @Override public String display(DisplayMode mode, String[] fieldNames) { String displayedElements = super.display(mode, fieldNames); if (StringUtils.isBlank(displayedElements) && !this.yesSelected && !this.noSelected) { return ""; } if (DisplayMode.Edit.equals(mode)) { return "<div class='section'>" + this.titleYesNoPicker.display(mode, fieldNames) + "<div class='dropdown invisible " + this.type + "'><div>" + displayedElements + "</div></div></div>"; } else { String title = this.titleYesNoPicker.display(mode, fieldNames); return "<div class='section" + (StringUtils.isEmpty(title) ? " value-checked" : "") + "'>" + StringUtils.defaultIfEmpty(title, XMLUtils.escapeElementContent(this.title)) + "</div><div class='subsection " + this.type + "'>" + displayedElements + "</div>"; } } FormConditionalSubsection(String title, String type, FormElement titleYesNoPicker, boolean yesSelected,
        boolean noSelected); @Override String display(DisplayMode mode, String[] fieldNames); }
FormConditionalSubsection extends FormGroup { @Override public String display(DisplayMode mode, String[] fieldNames) { String displayedElements = super.display(mode, fieldNames); if (StringUtils.isBlank(displayedElements) && !this.yesSelected && !this.noSelected) { return ""; } if (DisplayMode.Edit.equals(mode)) { return "<div class='section'>" + this.titleYesNoPicker.display(mode, fieldNames) + "<div class='dropdown invisible " + this.type + "'><div>" + displayedElements + "</div></div></div>"; } else { String title = this.titleYesNoPicker.display(mode, fieldNames); return "<div class='section" + (StringUtils.isEmpty(title) ? " value-checked" : "") + "'>" + StringUtils.defaultIfEmpty(title, XMLUtils.escapeElementContent(this.title)) + "</div><div class='subsection " + this.type + "'>" + displayedElements + "</div>"; } } FormConditionalSubsection(String title, String type, FormElement titleYesNoPicker, boolean yesSelected,
        boolean noSelected); @Override String display(DisplayMode mode, String[] fieldNames);  }