2021-10-12 23:41:35 +05:30
|
|
|
export function initAdminUserListSearchForm() {
|
2021-10-15 08:05:26 +05:30
|
|
|
const searchForm = window.config.pageData.adminUserListSearchForm;
|
2021-10-12 23:41:35 +05:30
|
|
|
if (!searchForm) return;
|
|
|
|
|
2024-02-13 19:43:06 +05:30
|
|
|
const form = document.querySelector('#user-list-search-form');
|
|
|
|
if (!form) return;
|
2021-10-12 23:41:35 +05:30
|
|
|
|
2024-02-13 19:43:06 +05:30
|
|
|
for (const button of form.querySelectorAll(`button[name=sort][value="${searchForm.SortType}"]`)) {
|
|
|
|
button.classList.add('active');
|
|
|
|
}
|
2021-10-12 23:41:35 +05:30
|
|
|
|
|
|
|
if (searchForm.StatusFilterMap) {
|
|
|
|
for (const [k, v] of Object.entries(searchForm.StatusFilterMap)) {
|
|
|
|
if (!v) continue;
|
2024-02-13 19:43:06 +05:30
|
|
|
for (const input of form.querySelectorAll(`input[name="status_filter[${k}]"][value="${v}"]`)) {
|
|
|
|
input.checked = true;
|
|
|
|
}
|
2021-10-12 23:41:35 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-13 19:43:06 +05:30
|
|
|
for (const radio of form.querySelectorAll('input[type=radio]')) {
|
|
|
|
radio.addEventListener('click', () => {
|
|
|
|
form.submit();
|
|
|
|
});
|
|
|
|
}
|
2021-10-12 23:41:35 +05:30
|
|
|
|
2024-02-13 19:43:06 +05:30
|
|
|
const resetButtons = form.querySelectorAll('.j-reset-status-filter');
|
|
|
|
for (const button of resetButtons) {
|
|
|
|
button.addEventListener('click', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
for (const input of form.querySelectorAll('input[type=radio]')) {
|
|
|
|
if (input.name.startsWith('status_filter[')) {
|
|
|
|
input.checked = false;
|
|
|
|
}
|
2021-10-12 23:41:35 +05:30
|
|
|
}
|
2024-02-13 19:43:06 +05:30
|
|
|
form.submit();
|
2021-10-12 23:41:35 +05:30
|
|
|
});
|
2024-02-13 19:43:06 +05:30
|
|
|
}
|
2021-10-12 23:41:35 +05:30
|
|
|
}
|