feat: Hide future months from month range filter and table columns

Compare against current YYYY-MM to exclude future months from the
from/to selectors, default selection, and table column display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 13:29:48 +02:00
parent f712198319
commit 77743019b0
2 changed files with 60 additions and 8 deletions

View File

@@ -923,6 +923,8 @@
}
// Month range filter
var maxMonthIdx;
function applyMonthFilter() {
var fromIdx = parseInt(document.getElementById('fromMonth').value);
var toIdx = parseInt(document.getElementById('toMonth').value);
@@ -940,17 +942,41 @@
var fromSelect = document.getElementById('fromMonth');
var toSelect = document.getElementById('toMonth');
fromSelect.value = 0;
toSelect.value = fromSelect.options.length - 1;
toSelect.value = maxMonthIdx;
applyMonthFilter();
}
// Set defaults (last 5 months) and apply on load
// Remove future months from selects, set defaults, apply on load
(function() {
var now = new Date();
var currentMonth = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0');
maxMonthIdx = sortedMonths.length - 1;
for (var i = 0; i < sortedMonths.length; i++) {
if (sortedMonths[i] > currentMonth) {
maxMonthIdx = i - 1;
break;
}
}
var fromSelect = document.getElementById('fromMonth');
var toSelect = document.getElementById('toMonth');
var defaultFrom = Math.max(0, fromSelect.options.length - 5);
// Remove future month options
for (var i = fromSelect.options.length - 1; i > maxMonthIdx; i--) {
fromSelect.remove(i);
toSelect.remove(i);
}
// Hide future month columns permanently
document.querySelectorAll('[data-month-idx]').forEach(function(el) {
if (parseInt(el.getAttribute('data-month-idx')) > maxMonthIdx) {
el.classList.add('month-hidden');
}
});
var defaultFrom = Math.max(0, maxMonthIdx - 4);
fromSelect.value = defaultFrom;
toSelect.value = fromSelect.options.length - 1;
toSelect.value = maxMonthIdx;
applyMonthFilter();
})();
</script>