diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java index 123d873c2d1e5a9a7418e6ef89b2d67326a01256..2467ddf87de316e9097a1f6b2718117a510ccd9e 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountController.java @@ -19,7 +19,9 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.WebRequest; import jakarta.servlet.http.HttpServletRequest; + import java.text.MessageFormat; +import java.time.LocalDate; import java.util.List; import java.util.Optional; @@ -39,6 +41,7 @@ public class AccountController extends BaseController public static final String FONTAWESOME_ICONS = "fontawesomeIcons"; public static final String ERROR = "error"; public static final String NOTIFICATIONS = "notifications"; + public static final String TODAY = "today"; } private static class ReturnValues @@ -148,6 +151,7 @@ public class AccountController extends BaseController model.addAttribute(ModelAttributes.ONE_ENTITY, emptyAccount); model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values()); model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS); + model.addAttribute(ModelAttributes.TODAY, LocalDate.now()); return ReturnValues.NEW_ENTITY; } @@ -163,6 +167,7 @@ public class AccountController extends BaseController model.addAttribute(ModelAttributes.ONE_ENTITY, accountOptional.get()); model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values()); model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS); + model.addAttribute(ModelAttributes.TODAY, LocalDate.now()); return ReturnValues.NEW_ENTITY; } @@ -211,6 +216,7 @@ public class AccountController extends BaseController model.addAttribute(ModelAttributes.ONE_ENTITY, account); model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values()); model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS); + model.addAttribute(ModelAttributes.TODAY, LocalDate.now()); return ReturnValues.NEW_ENTITY; } diff --git a/BudgetMasterServer/src/main/resources/languages/base_de.properties b/BudgetMasterServer/src/main/resources/languages/base_de.properties index 3566699b8d65f7cec3d2848a9771f269b7580c34..605429f0eea5a71ddbced7d35148a879bd96c561 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_de.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_de.properties @@ -354,6 +354,7 @@ account.new.icon.placeholder=Vorschau anklicken, um ein Icon auszuwählen account.new.icon.upload.choose.file=Datei auswählen account.new.icon.upload=Hochladen account.new.label.state=Sichtbarkeit +account.new.label.endDate=Enddatum account.default.name=Standardkonto account.all=Alle Konten account.tooltip.default=Als Standardkonto festlegen diff --git a/BudgetMasterServer/src/main/resources/languages/base_en.properties b/BudgetMasterServer/src/main/resources/languages/base_en.properties index f99a50312b8d27d15a60c3ccf850223a13618ca2..bf10454f4b085c08994755d01936e8281a8d4f20 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_en.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_en.properties @@ -353,6 +353,7 @@ account.new.icon.placeholder=Click preview to select an icon account.new.icon.upload.choose.file=Choose file account.new.icon.upload=Upload account.new.label.state=Visibility +account.new.label.endDate=End Date account.default.name=Default Account account.all=All Accounts account.tooltip.default=Set as default account diff --git a/BudgetMasterServer/src/main/resources/static/js/accounts.js b/BudgetMasterServer/src/main/resources/static/js/accounts.js index 8f0a9239457243eb60d8a07d3e77696ad3f9b77e..9f03f22ec8d4f8d1d6733dc9c87ac8b7512c133c 100644 --- a/BudgetMasterServer/src/main/resources/static/js/accounts.js +++ b/BudgetMasterServer/src/main/resources/static/js/accounts.js @@ -20,4 +20,35 @@ $(document).ready(function() { fetchAndShowModalContent(this.dataset.url, '#deleteModalContainerOnDemand', '#modalConfirmDelete', function(){}); }); + + if($(".datepicker").length) + { + M.Datepicker.init(document.getElementById('account-datepicker'), { + firstDay: 1, + showClearBtn: true, + defaultDate: startDate, + autoClose: true, + + i18n: { + // Strings and translations + months: monthNames, + monthsShort: monthNamesShort, + weekdays: weekDays, + weekdaysShort: weekDaysShort, + weekdaysAbbrev: weekDaysLetters, + + // Buttons + cancel: buttonCancel, + done: buttonClose, + + // Accessibility labels + labelMonthNext: '>', + labelMonthPrev: '<' + }, + + // Formats + format: 'dd.mm.yyyy', + formatSubmit: 'dd.mm.yyyy', + }); + } }); diff --git a/BudgetMasterServer/src/main/resources/templates/accounts/newAccount.ftl b/BudgetMasterServer/src/main/resources/templates/accounts/newAccount.ftl index de9e0354cc0abf733a44a2082758e6900769cd34..c4fa9196bea7402b752aac2bb4efdd7d2bafc3a3 100644 --- a/BudgetMasterServer/src/main/resources/templates/accounts/newAccount.ftl +++ b/BudgetMasterServer/src/main/resources/templates/accounts/newAccount.ftl @@ -11,6 +11,7 @@ <@header.header "BudgetMaster - ${title}"/> <@header.style "iconSelect"/> + <@header.style "datepicker"/> <#import "/spring.ftl" as s> </head> <@header.body> @@ -77,6 +78,28 @@ </#if> <@customSelectMacros.customAccountStateSelect "account-state-select-wrapper" "accountState" availableAccountStates selectedState "col s12 m12 l8 offset-l2" locale.getString("account.new.label.state") "account-state"/> + <#-- end date --> + <div class="row"> + <div class="input-field col s12 m12 l8 offset-l2"> + <#if account.getEndDate()??> + <#assign startDate = dateService.getLongDateString(account.getEndDate())/> + <#assign accountEndDate = dateService.getLongDateString(account.getEndDate())/> + <#else> + <#assign startDate = dateService.getLongDateString(today)/> + <#assign accountEndDate = ""/> + </#if> + + <i class="material-icons prefix">notifications</i> + <input id="account-datepicker" type="text" class="datepicker" name="endDate" value="${accountEndDate}"> + <label class="input-label" for="account-datepicker">${locale.getString("account.new.label.endDate")}</label> + </div> + </div> + + <script> + startDate = "${startDate}".split("."); + startDate = new Date(startDate[2], startDate[1]-1, startDate[0]); + </script> + <br> <#-- buttons --> @@ -109,6 +132,9 @@ <@iconSelectMacros.modalIconSelect idToFocusOnClose="account-name" item=account/> + <#import "../helpers/globalDatePicker.ftl" as datePicker> + <@datePicker.datePickerLocalization/> + <!-- Scripts--> <#import "../helpers/scripts.ftl" as scripts> <@scripts.scripts/>