Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions web_src/js/features/admin/users.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import $ from 'jquery';

export function initAdminUserListSearchForm() {
const searchForm = window.config.pageData.adminUserListSearchForm;
if (!searchForm) return;

const $form = $('#user-list-search-form');
if (!$form.length) return;
const form = document.querySelector('#user-list-search-form');
if (!form) return;

$form.find(`button[name=sort][value=${searchForm.SortType}]`).addClass('active');
for (const button of document.querySelectorAll(`button[name=sort][value="${searchForm.SortType}"]`)) {
Comment thread
yardenshoham marked this conversation as resolved.
Outdated
button.classList.add('active');
}

if (searchForm.StatusFilterMap) {
for (const [k, v] of Object.entries(searchForm.StatusFilterMap)) {
if (!v) continue;
$form.find(`input[name="status_filter[${k}]"][value=${v}]`).prop('checked', true);
for (const input of document.querySelectorAll(`input[name="status_filter[${k}]"][value="${v}"]`)) {
Comment thread
yardenshoham marked this conversation as resolved.
Outdated
input.checked = true;
}
}
}

$form.find(`input[type=radio]`).on('click', () => {
$form.trigger('submit');
return false;
});
for (const radio of form.querySelectorAll('input[type=radio]')) {
radio.addEventListener('click', () => {
form.submit();
return false;
Comment thread
yardenshoham marked this conversation as resolved.
Outdated
});
}

$form.find('.j-reset-status-filter').on('click', () => {
$form.find(`input[type=radio]`).each((_, e) => {
const $e = $(e);
if ($e.attr('name').startsWith('status_filter[')) {
$e.prop('checked', false);
const resetButtons = document.querySelectorAll('.j-reset-status-filter');
for (const button of resetButtons) {
Comment thread
yardenshoham marked this conversation as resolved.
Outdated
button.addEventListener('click', () => {
for (const input of form.querySelectorAll('input[type=radio]')) {
if (input.name.startsWith('status_filter[')) {
input.checked = false;
}
}
form.submit();
return false;
Comment thread
yardenshoham marked this conversation as resolved.
Outdated
});
$form.trigger('submit');
return false;
});
}
}