Добавлено управление выбором даты через календарь в компонент фильтрации по диапазону дат
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user