Skip to content

Commit

Permalink
✨ [#1451] -- columns never output their label
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 2, 2022
1 parent 92bb23f commit e24d346
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/openforms/formio/rendering/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class FieldSetNode(ContainerMixin, ComponentNode):
@register("columns")
class ColumnsNode(ContainerMixin, ComponentNode):
layout_modifier = "columns"
label = "" # 1451 -> never output a label
value = None # columns never have a value

def get_children(self) -> Iterator["ComponentNode"]:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def setUpTestData(cls):
def test_fieldsets_hidden_if_all_children_hidden(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][0]
assert component["type"] == "fieldset"

Expand All @@ -210,7 +209,6 @@ def test_fieldsets_hidden_if_all_children_hidden(self):
def test_fieldsets_visible_if_any_child_visible(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][1]
assert component["type"] == "fieldset"

Expand All @@ -227,7 +225,6 @@ def test_fieldsets_visible_if_any_child_visible(self):
def test_fieldset_hidden_if_marked_as_such_and_visible_children(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][2]
assert component["type"] == "fieldset"

Expand All @@ -241,7 +238,6 @@ def test_fieldset_hidden_if_marked_as_such_and_visible_children(self):
def test_columns_hidden_if_all_children_hidden(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][3]
assert component["type"] == "columns"

Expand All @@ -255,7 +251,6 @@ def test_columns_hidden_if_all_children_hidden(self):
def test_columns_visible_if_any_child_visible(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][4]
assert component["type"] == "columns"

Expand All @@ -266,13 +261,12 @@ def test_columns_visible_if_any_child_visible(self):
self.assertTrue(component_node.is_visible)
nodelist = list(component_node)
self.assertEqual(len(nodelist), 2)
self.assertEqual(nodelist[0].label, "Columns 2")
self.assertEqual(nodelist[0].component["label"], "Columns 2")
self.assertEqual(nodelist[1].label, "Input 7")

def test_column_hidden_if_marked_as_such_and_visible_children(self):
# we always need a renderer instance
renderer = Renderer(self.submission, mode=RenderModes.pdf, as_html=False)
# take
component = self.step.form_step.form_definition.configuration["components"][5]
assert component["type"] == "columns"

Expand All @@ -283,6 +277,21 @@ def test_column_hidden_if_marked_as_such_and_visible_children(self):
self.assertFalse(component_node.is_visible)
self.assertEqual(list(component_node), [])

def test_columns_never_output_label(self):
component = self.step.form_step.form_definition.configuration["components"][5]
assert component["type"] == "columns"

for render_mode in RenderModes.values:
with self.subTest(render_mode=render_mode):
renderer = Renderer(self.submission, mode=render_mode, as_html=False)

component_node = ComponentNode.build_node(
step=self.step, component=component, renderer=renderer
)

self.assertEqual(component_node.label, "")
self.assertIsNone(component_node.value)

def test_wysiwyg_component(self):
"""
WYSIWYG is only displayed in confirmation PDF and CLI rendering.
Expand Down

0 comments on commit e24d346

Please sign in to comment.