Добавлено управление выбором даты через календарь в компонент фильтрации по диапазону дат

This commit is contained in:
2025-12-29 01:36:39 +03:00
parent d66ea020f6
commit 54f362eb23
2 changed files with 52 additions and 0 deletions

View File

@@ -365,6 +365,50 @@ class DateCarousel {
this.boundClearDate = this.clearDate.bind(this);
clearBtn.addEventListener('click', this.boundClearDate);
}
// Календарный выбор даты
const calendarBtn = filterContainer.querySelector('.calendar-picker-btn');
const calendarInput = filterContainer.querySelector('.calendar-picker-input');
if (calendarBtn && calendarInput) {
calendarBtn.removeEventListener('click', this.boundOpenCalendar);
this.boundOpenCalendar = () => {
if (calendarInput.showPicker) {
calendarInput.showPicker();
} else {
calendarInput.click();
}
};
calendarBtn.addEventListener('click', this.boundOpenCalendar);
calendarInput.removeEventListener('change', this.boundCalendarSelect);
this.boundCalendarSelect = this.selectFromCalendar.bind(this);
calendarInput.addEventListener('change', this.boundCalendarSelect);
}
}
/**
* Выбор даты через календарь
*/
selectFromCalendar(event) {
const selectedDate = event.target.value;
if (!selectedDate) return;
const date = new Date(selectedDate);
date.setHours(0, 0, 0, 0);
const formattedDate = this.formatDate(date);
this.minInput.value = formattedDate;
this.maxInput.value = formattedDate;
this.centerDate = date;
this.saveCenterDate();
this.render();
this.attachTodayHandler();
const form = this.minInput.closest('form');
if (form) {
form.submit();
}
}
/**