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

fixed warning that at least one account must be set to visibility "full access"

parent b9a44a99
No related branches found
No related tags found
No related merge requests found
......@@ -134,9 +134,8 @@ public class AccountController extends BaseController
bindingResult.addError(new FieldError("NewAccount", "name", "", false, new String[]{"warning.duplicate.account.name"}, null, null));
}
List<Account> activatedAccounts = accountService.getRepository().findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS);
boolean newAccountStateWouldLeaveNoFullAccessAccounts = activatedAccounts.size() == 1 && account.getAccountState() != AccountState.FULL_ACCESS;
if(!isNewAccount && newAccountStateWouldLeaveNoFullAccessAccounts)
boolean isAccountStateAllowed = isAccountStateAllowed(account);
if(!isNewAccount && !isAccountStateAllowed)
{
final String warningMessage = Localization.getString("warning.account.edit.state", Localization.getString(AccountState.FULL_ACCESS.getLocalizationKey()));
WebRequestUtils.putNotification(webRequest, new Notification(warningMessage, NotificationType.WARNING));
......@@ -169,4 +168,24 @@ public class AccountController extends BaseController
return "redirect:/accounts";
}
private boolean isAccountStateAllowed(Account account)
{
List<Account> activatedAccounts = accountService.getRepository().findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS);
if(activatedAccounts.size() > 1)
{
return true;
}
final Account lastActivatedAccount = activatedAccounts.get(0);
final boolean currentAccountIsLastActivated = lastActivatedAccount.getID().equals(account.getID());
if(currentAccountIsLastActivated)
{
return account.getAccountState() == AccountState.FULL_ACCESS;
}
else
{
return true;
}
}
}
\ No newline at end of file
......@@ -151,7 +151,7 @@ delete.image.error.not.existing=Fehler: Bild mit ID {0} existiert nicht
# 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!s
warning.account.edit.state=Für mindestens ein Konto muss die Sichtbarkeit auf "{0}" gesetzt sein!
warning.empty.category.name=Bitte gib einen Namen ein.
warning.empty.account.name=Bitte gib einen Namen ein.
warning.duplicate.account.name=Es existiert bereits ein Konto mit diesem Namen.
......@@ -238,8 +238,8 @@ settings.backup.auto.time.short={0} Uhr
settings.backup.auto.strategy=Strategie
settings.backup.auto.strategy.none=Keine
settings.backup.auto.strategy.local=Kopien im Dateisystem
settings.backup.auto.strategy.git.local=Lokales git repository
settings.backup.auto.strategy.git.remote=Entferntes git repository
settings.backup.auto.strategy.git.local=Lokales git Repository
settings.backup.auto.strategy.git.remote=Entferntes git Repository
settings.backup.auto.strategy.git.remote.help=Einrichtungshilfe
settings.backup.auto.strategy.git.remote.help.url=https://github.com/deadlocker8/BudgetMaster/wiki/Automatic-backup
settings.backup.auto.files.to.keep=Anzahl aufzubewahrender Backups (0 für unbegrenzt)
......
......@@ -151,7 +151,7 @@ delete.image.error.not.existing=Error: Image with ID {0} does not exist
# 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}"!
warning.account.edit.state=At least one account must have set it''s visibility to "{0}"!
warning.empty.category.name=Please insert a name.
warning.empty.account.name=Please insert a name.
warning.duplicate.account.name=An account with this name is already existing.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment