Skip to content
Snippets Groups Projects
Commit 154ecd34 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #615: prevent creation of new transactions for read-only accounts:

- show warning notification
- hide new transaction button on transaction overview page
- intercept hotkeys
parent 63e169a8
No related branches found
No related tags found
No related merge requests found
......@@ -115,8 +115,15 @@ public class TransactionController extends BaseController
}
@GetMapping("/newTransaction/{type}")
public String newTransaction(Model model, @CookieValue("currentDate") String cookieDate, @PathVariable String type)
public String newTransaction(WebRequest request, Model model, @CookieValue("currentDate") String cookieDate, @PathVariable String type)
{
final AccountState accountState = helpers.getCurrentAccount().getAccountState();
if(accountState != AccountState.FULL_ACCESS)
{
WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.transaction.add.warning", Localization.getString(accountState.getLocalizationKey())), NotificationType.WARNING));
return "redirect:/transactions";
}
DateTime date = dateService.getDateTimeFromCookie(cookieDate);
Transaction emptyTransaction = new Transaction();
emptyTransaction.setCategory(categoryService.findByType(CategoryType.NONE));
......
......@@ -151,6 +151,8 @@ upload.image.error.invalid.extension=Die Dateiendung "{0}" is nicht zugelassen f
delete.image.success=Erfolgreich gelöscht
delete.image.error.not.existing=Fehler: Bild mit ID {0} existiert nicht
notification.transaction.add.warning=Konto mit Sichtbarkeit "{0}" erlaubt keine neuen Buchungen!
# WARNING
warning.text.account.delete=Das Konto "{0}" kann nicht gelöscht werden, da mindestens ein Konto existieren muss. Um dieses Konto zu löschen musst du zuerst ein neues anlegen.
warning.account.edit.state=Für mindestens ein Konto muss die Sichtbarkeit auf "{0}" gesetzt sein!
......
......@@ -151,6 +151,8 @@ upload.image.error.invalid.extension=File extension "{0}" is not allowed for ima
delete.image.success=Successfully deleted
delete.image.error.not.existing=Error: Image with ID {0} does not exist
notification.transaction.add.warning=Account with visibility "{0}" does not allow new transactions!
# WARNING
warning.text.account.delete=The account "{0}" could not be deleted, because at least one account must exist at all time. You have to create a new account in order to delete this one.
warning.account.edit.state=At least one account must have set it''s visibility to "{0}"!
......
......@@ -96,12 +96,18 @@
<#macro buttons isFilterActive>
<div class="row hide-on-small-only valign-wrapper">
<#if helpers.getCurrentAccount().getAccountState().name() == 'FULL_ACCESS'>
<div class="col s6 right-align transactions-buttons-col">
<@buttonNew "new-transaction-button-list new-transaction-button-list-large"/>
<@buttonNew "new-transaction-button-list new-transaction-button-list-large" helpers.getCurrentAccount()/>
</div>
<div class="col s6 left-align">
<@buttonFilter isFilterActive/>
</div>
<#else>
<div class="col s12 center-align">
<@buttonFilter isFilterActive/>
</div>
</#if>
</div>
<div class="hide-on-med-and-up center-align">
......@@ -112,13 +118,17 @@
</div>
</div>
<div class="col s12 transactions-buttons-col">
<@buttonNew "new-transaction-button-list "/>
<@buttonNew "new-transaction-button-list " helpers.getCurrentAccount()/>
</div>
</div>
</div>
</#macro>
<#macro buttonNew listClasses>
<#macro buttonNew listClasses currentAccount>
<#if currentAccount.getAccountState().name() != 'FULL_ACCESS'>
<#return/>
</#if>
<div class="fixed-action-btn new-transaction-button">
<a class="btn-floating btn-large btn waves-effect waves-light background-blue" id="button-new-transaction">
<i class="material-icons left">add</i>${locale.getString("title.transaction.new.short")}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment