From 3bdb61a62cebbec542d1cae697848699464b31d0 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Tue, 4 Jan 2022 22:08:53 +0100 Subject: [PATCH] Fixed #656 - show banner if transaction, category, account, chart or template is successfully saved --- .../budgetmaster/accounts/AccountController.java | 1 + .../budgetmaster/categories/CategoryController.java | 5 ++++- .../budgetmaster/charts/ChartController.java | 4 ++-- .../budgetmaster/templates/TemplateController.java | 4 +++- .../transactions/TransactionController.java | 8 +++++--- src/main/resources/languages/base_de.properties | 10 ++++++++++ src/main/resources/languages/base_en.properties | 10 ++++++++++ 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java b/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java index d4942b683..f9d8a0c4a 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java @@ -174,6 +174,7 @@ public class AccountController extends BaseController return "redirect:/settings/database/import/step2"; } + WebRequestUtils.putNotification(webRequest, new Notification(Localization.getString("notification.account.save.success", account.getName()), NotificationType.SUCCESS)); return "redirect:/accounts"; } diff --git a/src/main/java/de/deadlocker8/budgetmaster/categories/CategoryController.java b/src/main/java/de/deadlocker8/budgetmaster/categories/CategoryController.java index d775978b9..44ccd4aa9 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/categories/CategoryController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/categories/CategoryController.java @@ -112,7 +112,8 @@ public class CategoryController extends BaseController } @PostMapping(value = "/newCategory") - public String post(Model model, @ModelAttribute("NewCategory") Category category, BindingResult bindingResult, + public String post(WebRequest request, + Model model, @ModelAttribute("NewCategory") Category category, BindingResult bindingResult, @RequestParam(value = "iconImageID", required = false) Integer iconImageID, @RequestParam(value = "builtinIconIdentifier", required = false) String builtinIconIdentifier) { @@ -136,6 +137,8 @@ public class CategoryController extends BaseController categoryService.save(category); + WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.category.save.success", category.getName()), NotificationType.SUCCESS)); + return "redirect:/categories"; } diff --git a/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java b/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java index f987972bb..7e6eca411 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java @@ -124,7 +124,7 @@ public class ChartController extends BaseController } @PostMapping(value = "/newChart") - public String post(Model model, @ModelAttribute("NewChart") Chart chart, BindingResult bindingResult) + public String post(WebRequest request, Model model, @ModelAttribute("NewChart") Chart chart, BindingResult bindingResult) { ChartValidator userValidator = new ChartValidator(); userValidator.validate(chart, bindingResult); @@ -157,7 +157,7 @@ public class ChartController extends BaseController } chartService.getRepository().save(chart); - + WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.chart.save.success", chart.getName()), NotificationType.SUCCESS)); return "redirect:/charts/manage"; } diff --git a/src/main/java/de/deadlocker8/budgetmaster/templates/TemplateController.java b/src/main/java/de/deadlocker8/budgetmaster/templates/TemplateController.java index a60545874..955c83557 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/templates/TemplateController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/templates/TemplateController.java @@ -165,7 +165,8 @@ public class TemplateController extends BaseController } @PostMapping(value = "/newTemplate") - public String post(Model model, + public String post(WebRequest request, + Model model, @ModelAttribute("NewTemplate") Template template, BindingResult bindingResult, @RequestParam(value = "includeAccount", required = false) boolean includeAccount, @RequestParam(value = "includeTransferAccount", required = false) boolean includeTransferAccount, @@ -219,6 +220,7 @@ public class TemplateController extends BaseController template.updateIcon(iconService, iconImageID, builtinIconIdentifier, templateService); templateService.getRepository().save(template); + WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.template.save.success", template.getName()), NotificationType.SUCCESS)); return "redirect:/templates"; } diff --git a/src/main/java/de/deadlocker8/budgetmaster/transactions/TransactionController.java b/src/main/java/de/deadlocker8/budgetmaster/transactions/TransactionController.java index 46630181c..2c1f18450 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/transactions/TransactionController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/transactions/TransactionController.java @@ -132,7 +132,8 @@ public class TransactionController extends BaseController } @PostMapping(value = "/newTransaction") - public String post(Model model, @CookieValue("currentDate") String cookieDate, + public String post(WebRequest request, + Model model, @CookieValue("currentDate") String cookieDate, @ModelAttribute("NewTransaction") Transaction transaction, BindingResult bindingResult, @RequestParam(value = "isRepeating", required = false) boolean isRepeating, @RequestParam(value = "repeatingModifierNumber", required = false, defaultValue = "0") int repeatingModifierNumber, @@ -170,7 +171,7 @@ public class TransactionController extends BaseController redirectUrl = "transactions/newTransactionNormal"; } - return handleRedirect(model, transaction.getID() != null, transaction, bindingResult, date, redirectUrl); + return handleRedirect(request, model, transaction.getID() != null, transaction, bindingResult, date, redirectUrl); } private void handlePreviousType(Transaction transaction, boolean isRepeating) @@ -206,7 +207,7 @@ public class TransactionController extends BaseController return new RepeatingOption(startDate, repeatingModifier, repeatingEnd); } - private String handleRedirect(Model model, boolean isEdit, @ModelAttribute("NewTransaction") Transaction transaction, BindingResult bindingResult, DateTime date, String url) + private String handleRedirect(WebRequest request, Model model, boolean isEdit, @ModelAttribute("NewTransaction") Transaction transaction, BindingResult bindingResult, DateTime date, String url) { if(bindingResult.hasErrors()) { @@ -216,6 +217,7 @@ public class TransactionController extends BaseController } transactionService.getRepository().save(transaction); + WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.transaction.save.success", transaction.getName()), NotificationType.SUCCESS)); return "redirect:/transactions"; } diff --git a/src/main/resources/languages/base_de.properties b/src/main/resources/languages/base_de.properties index e0063406b..2d2af29a2 100644 --- a/src/main/resources/languages/base_de.properties +++ b/src/main/resources/languages/base_de.properties @@ -104,26 +104,36 @@ info.text.category.delete.move=In welche Kategorie sollen alle veknüpften Buchu notification.category.delete.success=Die Kategorie "{0}" wurde erfolgreich gelöscht. notification.category.delete.not.deletable=Die Kategorie mit der ID "{0}" ist nicht löschbar! +notification.category.save.success=Die Kategorie "{0}" wurde erfolgreich gespeichert. + info.title.account.delete=Konto löschen info.text.account.delete=Möchtest du das Konto "{0}" wirklich unwiderruflich löschen?<br>Hinweis: Diesem Konto sind {1} Buchungen zugeordnet. Beim Löschen des Kontos werden diese ebenfalls gelöscht! info.button.account.delete=Konto und Buchungen löschen notification.account.delete.success=Das Konto "{0}" wurde erfolgreich gelöscht. +notification.account.save.success=Das Konto "{0}" wurde erfolgreich gespeichert. + info.title.transaction.delete=Buchung löschen info.text.transaction.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen? info.text.transaction.repeating.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen? <br>Hinweis: Es handelt sich um eine wiederholende Buchung. Beim Löschen dieser Buchung werden alle zugehörigen Wiederholungen ebenfalls gelöscht! notification.transaction.delete.success=Die Buchung "{0}" wurde erfolgreich gelöscht. +notification.transaction.save.success=Die Buchung "{0}" wurde erfolgreich gespeichert. + info.title.chart.delete=Diagramm löschen info.text.chart.delete=Möchtest du das Diagramm "{0}" wirklich unwiderruflich löschen? notification.chart.delete.success=Das Diagramm "{0}" wurde erfolgreich gelöscht. notification.chart.delete.not.deletable=Das Diagramm mit der ID "{0}" ist nicht löschbar! +notification.chart.save.success=Das Diagramm "{0}" wurde erfolgreich gespeichert. + info.title.template.delete=Vorlage löschen info.text.template.delete=Möchtest du die Vorlage "{0}" wirklich unwiderruflich löschen? notification.template.delete.success=Die Vorlage "{0}" wurde erfolgreich gelöscht. notification.template.add.success=Die Vorlage "{0}" wurde erfolgreich angelegt. +notification.template.save.success=Die Vorlage "{0}" wurde erfolgreich gespeichert. + info.title.database.delete=Datenbank löschen info.header.text.database.delete=Soll die Datenbank wirklich unwiderruflich gelöscht werden?<br>Hinweis: Beim Löschen der Datenbank werden alle Buchungen, Kategorien, Konten, Diagramme, Vorlagen und Bilder unwiderruflich gelöscht. Alle Einstellungen bleiben erhalten. info.text.database.delete=Gib den folgenden Code zur Bestätigung ein: diff --git a/src/main/resources/languages/base_en.properties b/src/main/resources/languages/base_en.properties index f6240de85..da0b7609b 100644 --- a/src/main/resources/languages/base_en.properties +++ b/src/main/resources/languages/base_en.properties @@ -105,26 +105,36 @@ info.text.category.delete.move=In which category should all related transactions notification.category.delete.success=Successfully deleted category "{0}". notification.category.delete.not.deletable=The category with id "{0}" is undeletable. +notification.category.save.success=Successfully saved category "{0}". + info.title.account.delete=Delete Account info.text.account.delete=Do you really want to delete the account "{0}"? This can''t be undone.<br>Note: There are {1} transactions associated with this account. Deleting this account will delete all releated transactions too! info.button.account.delete=Delete Account and Transactions notification.account.delete.success=Successfully deleted account "{0}". +notification.account.save.success=Successfully saved account "{0}". + info.title.transaction.delete=Delete Entry info.text.transaction.delete=Do you really want to delete the entry "{0}"? This can''t be undone. info.text.transaction.repeating.delete=Do you really want to delete the entry "{0}"? This can''t be undone.<br>Note: This transaction is a repeating transaction. Deleting this transaction will delete all related occurrences too! notification.transaction.delete.success=Successfully deleted transaction "{0}". +notification.transaction.save.success=Successfully saved transaction "{0}". + info.title.chart.delete=Delete Chart info.text.chart.delete=Do you really want to delete the chart "{0}"? notification.chart.delete.success=Successfully deleted chart "{0}". notification.chart.delete.not.deletable=The chart with id "{0}" is undeletable. +notification.chart.save.success=Successfully saved chart "{0}". + info.title.template.delete=Delete Template info.text.template.delete=Do you really want to delete the template "{0}"? notification.template.delete.success=Successfully deleted template "{0}". notification.template.add.success=Successfully added new template "{0}". +notification.template.save.success=Successfully saved template "{0}". + info.title.database.delete=Delete Database info.header.text.database.delete=Do you really want to delete the database? This can''t be undone.<br>Note: Deleting the database will delete all transactions, categories, accounts, charts, templates and images permanently. All settings will be preserved. info.text.database.delete=Please enter the following code for verification: -- GitLab