diff --git a/corehq/apps/app_manager/suite_xml/features/case_tiles.py b/corehq/apps/app_manager/suite_xml/features/case_tiles.py index 95eca8f9213a..81d58213c907 100644 --- a/corehq/apps/app_manager/suite_xml/features/case_tiles.py +++ b/corehq/apps/app_manager/suite_xml/features/case_tiles.py @@ -16,7 +16,6 @@ module_uses_inline_search, ) - TILE_DIR = Path(__file__).parent.parent / "case_tile_templates" @@ -27,7 +26,7 @@ class CaseTileTemplates(models.TextChoices): ONE_TWO_ONE_ONE = ("one_two_one_one", _("Title row, second row with two cells, third and " "fourth rows, and map")) ONE_3X_TWO_4X_ONE_2X = ("one_3X_two_4X_one_2X", _("Three upper rows, four rows with two cells, two lower rows " - "and map")) + "and map")) ONE_TWO_TWO = ("one_two_two", _("Title row, second row with two cells, third row with two cells")) ICON_TEXT_GRID = ("icon_text_grid", _("2 x 3 grid of image and text")) @@ -88,11 +87,14 @@ def build_case_tile_detail(self): for column_info in self.detail_column_infos: # column_info is an instance of DetailColumnInfo named tuple. - style = Style(grid_x=column_info.column.grid_x, grid_y=column_info.column.grid_y, - grid_height=column_info.column.height, grid_width=column_info.column.width, - horz_align=column_info.column.horizontal_align, - vert_align=column_info.column.vertical_align, - font_size=column_info.column.font_size) + style = None + if any(field is not None for field in [column_info.column.grid_x, column_info.column.grid_y, + column_info.column.height, column_info.column.width]): + style = Style(grid_x=column_info.column.grid_x, grid_y=column_info.column.grid_y, + grid_height=column_info.column.height, grid_width=column_info.column.width, + horz_align=column_info.column.horizontal_align, + vert_align=column_info.column.vertical_align, + font_size=column_info.column.font_size) fields = get_column_generator( self.app, self.module, self.detail, detail_type=self.detail_type, diff --git a/corehq/apps/app_manager/tests/test_suite_custom_case_tiles.py b/corehq/apps/app_manager/tests/test_suite_custom_case_tiles.py index ed0b88304637..f429ce39acbe 100644 --- a/corehq/apps/app_manager/tests/test_suite_custom_case_tiles.py +++ b/corehq/apps/app_manager/tests/test_suite_custom_case_tiles.py @@ -92,3 +92,39 @@ def test_custom_case_tile_address(self, *args): app.create_suite(), "./detail[@id='m0_case_short']/field[1]" ) + + def test_custom_case_tile_empty_style(self, *args): + app = Application.new_app('domain', 'Untitled Application') + + module = app.add_module(Module.new_module('Untitled Module', None)) + module.case_type = 'patient' + module.case_details.short.case_tile_template = "custom" + module.case_details.short.columns = [ + DetailColumn( + header={'en': 'a'}, + model='case', + field='a', + format='plain' + ), + ] + + self.assertXmlPartialEqual( + """ + + +
+ + + +
+ +
+
+ """, + app.create_suite(), + "./detail[@id='m0_case_short']/field[1]" + )