From 9ab4b2ef53ab413671ae63cba100f5f9fd8d268b Mon Sep 17 00:00:00 2001 From: Denis Maitak Date: Tue, 27 Jun 2023 15:45:10 +0700 Subject: [PATCH] Fix some issues with tables --- src/jira_report_generator/tables/assignees.py | 3 +++ src/jira_report_generator/tables/epics.py | 6 +++++- src/jira_report_generator/tables/statuses.py | 3 +++ src/jira_report_generator/tables/versions.py | 13 ++++++++----- src/jira_report_generator/utils/tags.py | 6 ++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/jira_report_generator/tables/assignees.py b/src/jira_report_generator/tables/assignees.py index 4d87b2a..d3d4cff 100644 --- a/src/jira_report_generator/tables/assignees.py +++ b/src/jira_report_generator/tables/assignees.py @@ -90,6 +90,9 @@ def _generate_row(name, df, components, estimate, spent, **attrs) -> TR: rows.append(row) scrollable_rows.append(scollable_row) + if not components: + return Table(rows, **table_options) + return Div( Div( Table(rows, **table_options), diff --git a/src/jira_report_generator/tables/epics.py b/src/jira_report_generator/tables/epics.py index 4357ac4..76c2732 100644 --- a/src/jira_report_generator/tables/epics.py +++ b/src/jira_report_generator/tables/epics.py @@ -8,6 +8,7 @@ def generate_epics_table(df: DataFrame, **table_options: str): rows = [] header = TR() epics = df[df["type"].apply(lambda x: x.name == "Epic")] + epics_list = list(epics.iterrows()) completed_statuses = ( Status.CLIENT_REVIEW.value, Status.COMPLETED.value, @@ -30,7 +31,7 @@ def generate_epics_table(df: DataFrame, **table_options: str): rows.append(header) - for _, epic in epics.iterrows(): + for _, epic in epics_list: row = TR(**{"data-epic-id": epic.id}) epic_tasks = df[df["parent"].apply( lambda x: x is not None and x.id == epic.id @@ -65,4 +66,7 @@ def generate_epics_table(df: DataFrame, **table_options: str): rows.append(row) + if not epics_list: + rows = [] + return Table(rows, **table_options) diff --git a/src/jira_report_generator/tables/statuses.py b/src/jira_report_generator/tables/statuses.py index a4532f0..4c5ff10 100644 --- a/src/jira_report_generator/tables/statuses.py +++ b/src/jira_report_generator/tables/statuses.py @@ -101,6 +101,9 @@ def _generate_row(name, df, components, estimate, spent, **attrs) -> TR: rows.append(footer_row) scrollable_rows.append(footer_scrollable_row) + if not components: + return Table(rows, **table_options) + return Div( Div( Table(rows, **table_options), diff --git a/src/jira_report_generator/tables/versions.py b/src/jira_report_generator/tables/versions.py index 37e3f6d..cacb8e1 100644 --- a/src/jira_report_generator/tables/versions.py +++ b/src/jira_report_generator/tables/versions.py @@ -41,11 +41,11 @@ def generate_component_columns( # generate empty columns if component_tasks.empty: - columns.append(TD()) - columns.append(TD()) - columns.append(TD()) - columns.append(TD()) - columns.append(TD()) + columns.append(TD(" ")) + columns.append(TD(" ")) + columns.append(TD(" ")) + columns.append(TD(" ")) + columns.append(TD(" ")) continue component_estimate = round( @@ -271,6 +271,9 @@ def generate_versions_table( rows.append(row) + if not components: + return Table(rows, **table_options) + return Div( Div( Table(rows, **table_options), diff --git a/src/jira_report_generator/utils/tags.py b/src/jira_report_generator/utils/tags.py index db0ecaf..53f420c 100644 --- a/src/jira_report_generator/utils/tags.py +++ b/src/jira_report_generator/utils/tags.py @@ -64,6 +64,9 @@ def __str__(self): self.value = "".join(map(str, self.rows)) return super().__str__() + def __bool__(self): + return bool(self.rows) + def append(self, row: TR): self.rows.append(row) @@ -80,5 +83,8 @@ def __str__(self): self.value = "".join(map(str, self.elements)) return super().__str__() + def __bool__(self): + return bool(self.elements) + def append(self, element): self.rows.append(element)