2022-01-29 02:30:11 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
const $form = $('#user-list-search-form');
|
|
|
|
if (!$form.length) return;
|
|
|
|
|
|
|
|
$form.find(`button[name=sort][value=${searchForm.SortType}]`).addClass('active');
|
|
|
|
|
|
|
|
if (searchForm.StatusFilterMap) {
|
|
|
|
for (const [k, v] of Object.entries(searchForm.StatusFilterMap)) {
|
|
|
|
if (!v) continue;
|
2024-03-17 22:25:16 +05:30
|
|
|
$form.find(`input[name="status_filter[${k}]"][value=${v}]`).checked = true;
|
2021-10-12 23:41:35 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-20 14:58:27 +05:30
|
|
|
$form.find(`input[type=radio]`).on('click', () => {
|
|
|
|
$form.trigger('submit');
|
2021-10-12 23:41:35 +05:30
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2023-04-20 14:58:27 +05:30
|
|
|
$form.find('.j-reset-status-filter').on('click', () => {
|
2021-10-12 23:41:35 +05:30
|
|
|
$form.find(`input[type=radio]`).each((_, e) => {
|
|
|
|
const $e = $(e);
|
|
|
|
if ($e.attr('name').startsWith('status_filter[')) {
|
2024-03-17 22:25:16 +05:30
|
|
|
$e.checked = false;
|
2021-10-12 23:41:35 +05:30
|
|
|
}
|
|
|
|
});
|
2023-04-20 14:58:27 +05:30
|
|
|
$form.trigger('submit');
|
2021-10-12 23:41:35 +05:30
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|