code.gitea.io/gitea@v1.21.7/web_src/js/features/admin/users.js (about)

     1  import $ from 'jquery';
     2  
     3  export function initAdminUserListSearchForm() {
     4    const searchForm = window.config.pageData.adminUserListSearchForm;
     5    if (!searchForm) return;
     6  
     7    const $form = $('#user-list-search-form');
     8    if (!$form.length) return;
     9  
    10    $form.find(`button[name=sort][value=${searchForm.SortType}]`).addClass('active');
    11  
    12    if (searchForm.StatusFilterMap) {
    13      for (const [k, v] of Object.entries(searchForm.StatusFilterMap)) {
    14        if (!v) continue;
    15        $form.find(`input[name="status_filter[${k}]"][value=${v}]`).prop('checked', true);
    16      }
    17    }
    18  
    19    $form.find(`input[type=radio]`).on('click', () => {
    20      $form.trigger('submit');
    21      return false;
    22    });
    23  
    24    $form.find('.j-reset-status-filter').on('click', () => {
    25      $form.find(`input[type=radio]`).each((_, e) => {
    26        const $e = $(e);
    27        if ($e.attr('name').startsWith('status_filter[')) {
    28          $e.prop('checked', false);
    29        }
    30      });
    31      $form.trigger('submit');
    32      return false;
    33    });
    34  }