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:
@@ -923,6 +923,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Month range filter
|
// Month range filter
|
||||||
|
var maxMonthIdx;
|
||||||
|
|
||||||
function applyMonthFilter() {
|
function applyMonthFilter() {
|
||||||
var fromIdx = parseInt(document.getElementById('fromMonth').value);
|
var fromIdx = parseInt(document.getElementById('fromMonth').value);
|
||||||
var toIdx = parseInt(document.getElementById('toMonth').value);
|
var toIdx = parseInt(document.getElementById('toMonth').value);
|
||||||
@@ -940,17 +942,41 @@
|
|||||||
var fromSelect = document.getElementById('fromMonth');
|
var fromSelect = document.getElementById('fromMonth');
|
||||||
var toSelect = document.getElementById('toMonth');
|
var toSelect = document.getElementById('toMonth');
|
||||||
fromSelect.value = 0;
|
fromSelect.value = 0;
|
||||||
toSelect.value = fromSelect.options.length - 1;
|
toSelect.value = maxMonthIdx;
|
||||||
applyMonthFilter();
|
applyMonthFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults (last 5 months) and apply on load
|
// Remove future months from selects, set defaults, apply on load
|
||||||
(function() {
|
(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 fromSelect = document.getElementById('fromMonth');
|
||||||
var toSelect = document.getElementById('toMonth');
|
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;
|
fromSelect.value = defaultFrom;
|
||||||
toSelect.value = fromSelect.options.length - 1;
|
toSelect.value = maxMonthIdx;
|
||||||
applyMonthFilter();
|
applyMonthFilter();
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -904,6 +904,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Month range filter
|
// Month range filter
|
||||||
|
var maxMonthIdx;
|
||||||
|
|
||||||
function applyMonthFilter() {
|
function applyMonthFilter() {
|
||||||
var fromIdx = parseInt(document.getElementById('fromMonth').value);
|
var fromIdx = parseInt(document.getElementById('fromMonth').value);
|
||||||
var toIdx = parseInt(document.getElementById('toMonth').value);
|
var toIdx = parseInt(document.getElementById('toMonth').value);
|
||||||
@@ -921,17 +923,41 @@
|
|||||||
var fromSelect = document.getElementById('fromMonth');
|
var fromSelect = document.getElementById('fromMonth');
|
||||||
var toSelect = document.getElementById('toMonth');
|
var toSelect = document.getElementById('toMonth');
|
||||||
fromSelect.value = 0;
|
fromSelect.value = 0;
|
||||||
toSelect.value = fromSelect.options.length - 1;
|
toSelect.value = maxMonthIdx;
|
||||||
applyMonthFilter();
|
applyMonthFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults (last 5 months) and apply on load
|
// Remove future months from selects, set defaults, apply on load
|
||||||
(function() {
|
(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 fromSelect = document.getElementById('fromMonth');
|
||||||
var toSelect = document.getElementById('toMonth');
|
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;
|
fromSelect.value = defaultFrom;
|
||||||
toSelect.value = fromSelect.options.length - 1;
|
toSelect.value = maxMonthIdx;
|
||||||
applyMonthFilter();
|
applyMonthFilter();
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user