Добавлено управление выбором даты через календарь в компонент фильтрации по диапазону дат
This commit is contained in:
@@ -365,6 +365,50 @@ class DateCarousel {
|
|||||||
this.boundClearDate = this.clearDate.bind(this);
|
this.boundClearDate = this.clearDate.bind(this);
|
||||||
clearBtn.addEventListener('click', this.boundClearDate);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,6 +32,14 @@
|
|||||||
title="Завтра">
|
title="Завтра">
|
||||||
Завтра
|
Завтра
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-primary ms-1 calendar-picker-btn"
|
||||||
|
title="Выбрать дату">
|
||||||
|
<i class="bi bi-calendar3"></i>
|
||||||
|
</button>
|
||||||
|
<input type="date" class="calendar-picker-input"
|
||||||
|
data-min-input="{{ field_after.id_for_label }}"
|
||||||
|
data-max-input="{{ field_before.id_for_label }}"
|
||||||
|
style="position: absolute; opacity: 0; pointer-events: none;">
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary ms-1 clear-date-btn"
|
<button type="button" class="btn btn-sm btn-outline-secondary ms-1 clear-date-btn"
|
||||||
data-min-input="{{ field_after.id_for_label }}"
|
data-min-input="{{ field_after.id_for_label }}"
|
||||||
data-max-input="{{ field_before.id_for_label }}"
|
data-max-input="{{ field_before.id_for_label }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user