From 041a905fc039124a9f824489beb05853386fa640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 8 Mar 2023 11:03:52 +0800 Subject: [PATCH] Added font-awesome icons to the report chooser. --- .../report/reports/utils/option_link.py | 4 +++- .../report/reports/utils/report_chooser.py | 18 ++++++++++++------ .../report/include/action-buttons.html | 8 +++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/accounting/report/reports/utils/option_link.py b/src/accounting/report/reports/utils/option_link.py index 3c5f4c3..90da8c0 100644 --- a/src/accounting/report/reports/utils/option_link.py +++ b/src/accounting/report/reports/utils/option_link.py @@ -22,7 +22,8 @@ class OptionLink: """An option link.""" - def __init__(self, title: str, url: str, is_active: bool): + def __init__(self, title: str, url: str, is_active: bool, + fa_icon: str | None = None): """Constructs an option link. :param title: The title. @@ -32,3 +33,4 @@ class OptionLink: self.title: str = title self.url: str = url self.is_active: bool = is_active + self.fa_icon: str | None = fa_icon diff --git a/src/accounting/report/reports/utils/report_chooser.py b/src/accounting/report/reports/utils/report_chooser.py index 4f2352d..9f2acfe 100644 --- a/src/accounting/report/reports/utils/report_chooser.py +++ b/src/accounting/report/reports/utils/report_chooser.py @@ -85,7 +85,8 @@ class ReportChooser: if self.__period.is_default \ else url_for("accounting.report.journal", period=self.__period) return OptionLink(gettext("Journal"), url, - self.__active_report == ReportType.JOURNAL) + self.__active_report == ReportType.JOURNAL, + fa_icon="fa-solid fa-book") @property def __ledger(self) -> OptionLink: @@ -100,7 +101,8 @@ class ReportChooser: currency=self.__currency, account=self.__account, period=self.__period) return OptionLink(gettext("Ledger"), url, - self.__active_report == ReportType.LEDGER) + self.__active_report == ReportType.LEDGER, + fa_icon="fa-solid fa-clipboard") @property def __income_expenses(self) -> OptionLink: @@ -118,7 +120,8 @@ class ReportChooser: currency=self.__currency, account=account, period=self.__period) return OptionLink(gettext("Income and Expenses Log"), url, - self.__active_report == ReportType.INCOME_EXPENSES) + self.__active_report == ReportType.INCOME_EXPENSES, + fa_icon="fa-solid fa-money-bill-wave") @property def __trial_balance(self) -> OptionLink: @@ -132,7 +135,8 @@ class ReportChooser: else url_for("accounting.report.trial-balance", currency=self.__currency, period=self.__period) return OptionLink(gettext("Trial Balance"), url, - self.__active_report == ReportType.TRIAL_BALANCE) + self.__active_report == ReportType.TRIAL_BALANCE, + fa_icon="fa-solid fa-scale-unbalanced") @property def __income_statement(self) -> OptionLink: @@ -146,7 +150,8 @@ class ReportChooser: else url_for("accounting.report.income-statement", currency=self.__currency, period=self.__period) return OptionLink(gettext("Income Statement"), url, - self.__active_report == ReportType.INCOME_STATEMENT) + self.__active_report == ReportType.INCOME_STATEMENT, + fa_icon="fa-solid fa-file-invoice-dollar") @property def __balance_sheet(self) -> OptionLink: @@ -160,7 +165,8 @@ class ReportChooser: else url_for("accounting.report.balance-sheet", currency=self.__currency, period=self.__period) return OptionLink(gettext("Balance Sheet"), url, - self.__active_report == ReportType.BALANCE_SHEET) + self.__active_report == ReportType.BALANCE_SHEET, + fa_icon="fa-solid fa-scale-balanced") def __iter__(self) -> t.Iterator[OptionLink]: """Returns the iteration of the reports. diff --git a/src/accounting/templates/accounting/report/include/action-buttons.html b/src/accounting/templates/accounting/report/include/action-buttons.html index 968bcc3..b82af7f 100644 --- a/src/accounting/templates/accounting/report/include/action-buttons.html +++ b/src/accounting/templates/accounting/report/include/action-buttons.html @@ -54,10 +54,16 @@ First written: 2023/3/8