settings: Add common user-or-bot-settings-section class.

This class is added so that we can avoid duplicating code
and use common functions for users and bots tables.

This commit also updates the name of the function
handling clear button in search input so that it
can be used for bots as well in further commits.
This commit is contained in:
Maneesh Shukla 2025-08-20 23:06:00 +05:30 committed by Tim Abbott
parent 8e4e58a8de
commit 1d9da3aecd
4 changed files with 9 additions and 9 deletions

View File

@ -470,7 +470,7 @@ function human_info(person: User): {
}
function set_text_search_value($table: JQuery, value: string): void {
$table.closest(".user-settings-section").find(".search").val(value);
$table.closest(".user-or-bot-settings-section").find(".search").val(value);
}
let bot_list_widget: ListWidgetType<number, BotInfo>;
@ -550,8 +550,8 @@ function active_create_table(active_users: number[]): void {
$("#admin_users_table").show();
}
function handle_clear_button_for_users($tbody: JQuery): void {
const $container = $tbody.closest(".user-settings-section");
function handle_clear_button_for_table_search_input($tbody: JQuery): void {
const $container = $tbody.closest(".user-or-bot-settings-section");
$container.on("click", ".clear-filter", (e) => {
e.stopPropagation();
e.preventDefault();
@ -783,7 +783,7 @@ function handle_filter_change($tbody: JQuery, section: UserSettingsSection): voi
// can't use that, because we're also filtering on Role with our
// custom predicate.
$tbody
.closest(".user-settings-section")
.closest(".user-or-bot-settings-section")
.find<HTMLInputElement>(".search")
.on("input.list_widget_filter", function (this: HTMLInputElement) {
add_value_to_filters(section, "text_search", this.value.toLocaleLowerCase());
@ -797,7 +797,7 @@ function active_handle_events(): void {
handle_deactivation($tbody);
handle_reactivation($tbody);
handle_edit_form($tbody);
handle_clear_button_for_users($tbody);
handle_clear_button_for_table_search_input($tbody);
}
function deactivated_handle_events(): void {
@ -807,7 +807,7 @@ function deactivated_handle_events(): void {
handle_deactivation($tbody);
handle_reactivation($tbody);
handle_edit_form($tbody);
handle_clear_button_for_users($tbody);
handle_clear_button_for_table_search_input($tbody);
}
function bots_handle_events(): void {

View File

@ -1,4 +1,4 @@
<div id="admin-active-users-list" class="user-settings-section" data-user-settings-section="active">
<div id="admin-active-users-list" class="user-settings-section user-or-bot-settings-section" data-user-settings-section="active">
<div class="settings_panel_list_header">
<h3>{{t "Users"}}</h3>

View File

@ -1,4 +1,4 @@
<div id="admin-bot-list" class="settings-section" data-name="bot-list-admin">
<div id="admin-bot-list" class="settings-section user-or-bot-settings-section" data-name="bot-list-admin">
<div class="bot-settings-tip banner-wrapper" id="admin-bot-settings-tip">
</div>
<div class="clear-float"></div>

View File

@ -1,4 +1,4 @@
<div id="admin-deactivated-users-list" class="user-settings-section" data-user-settings-section="deactivated">
<div id="admin-deactivated-users-list" class="user-settings-section user-or-bot-settings-section" data-user-settings-section="deactivated">
<div class="clear-float"></div>
<div class="settings_panel_list_header">