Revised the JavaScript MonthTab class in the period chooser to avoid nested template literals, for readability.

This commit is contained in:
依瑪貓 2023-04-03 21:19:48 +08:00
parent f7efacad75
commit 8286c0c6d8

View File

@ -181,7 +181,8 @@ class MonthTab extends TabPlane {
}); });
monthChooser.addEventListener(tempusDominus.Namespace.events.change, (e) => { monthChooser.addEventListener(tempusDominus.Namespace.events.change, (e) => {
const date = e.detail.date; const date = e.detail.date;
const period = `${date.year}-${`0${date.month + 1}`.slice(-2)}`; const zeroPaddedMonth = `0${date.month + 1}`.slice(-2)
const period = `${date.year}-${zeroPaddedMonth}`;
window.location = chooser.modal.dataset.urlTemplate window.location = chooser.modal.dataset.urlTemplate
.replaceAll("PERIOD", period); .replaceAll("PERIOD", period);
}); });