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

#764 - add new input field for account end date

parent ba977de6
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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
......
......@@ -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
......
......@@ -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',
});
}
});
......@@ -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/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment