mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
streams: Allow sorting of stream members.
Stream members table in Create stream and stream subscribers UI can now be sorted. Fixes #21341
This commit is contained in:
@@ -41,7 +41,7 @@ function compare_a_b(a, b) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_email(a, b) {
|
export function sort_email(a, b) {
|
||||||
const email_a = a.delivery_email;
|
const email_a = a.delivery_email;
|
||||||
const email_b = b.delivery_email;
|
const email_b = b.delivery_email;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ function sort_last_active(a, b) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_user_id(a, b) {
|
export function sort_user_id(a, b) {
|
||||||
return compare_a_b(a.user_id, b.user_id);
|
return compare_a_b(a.user_id, b.user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import * as add_subscribers_pill from "./add_subscribers_pill";
|
|||||||
import * as ListWidget from "./list_widget";
|
import * as ListWidget from "./list_widget";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
import * as settings_users from "./settings_users";
|
||||||
import * as stream_create_subscribers_data from "./stream_create_subscribers_data";
|
import * as stream_create_subscribers_data from "./stream_create_subscribers_data";
|
||||||
|
|
||||||
let pill_widget;
|
let pill_widget;
|
||||||
@@ -83,28 +84,30 @@ export function build_widgets() {
|
|||||||
|
|
||||||
all_users_list_widget = ListWidget.create($("#create_stream_subscribers"), [current_user_id], {
|
all_users_list_widget = ListWidget.create($("#create_stream_subscribers"), [current_user_id], {
|
||||||
name: "new_stream_add_users",
|
name: "new_stream_add_users",
|
||||||
|
get_item: people.get_by_user_id,
|
||||||
$parent_container: $add_people_container,
|
$parent_container: $add_people_container,
|
||||||
modifier(user_id) {
|
modifier(user) {
|
||||||
const user = people.get_by_user_id(user_id);
|
|
||||||
const item = {
|
const item = {
|
||||||
email: user.delivery_email,
|
email: user.delivery_email,
|
||||||
user_id,
|
user_id: user.user_id,
|
||||||
full_name: user.full_name,
|
full_name: user.full_name,
|
||||||
is_current_user: user_id === current_user_id,
|
is_current_user: user.user_id === current_user_id,
|
||||||
disabled: stream_create_subscribers_data.must_be_subscribed(user_id),
|
disabled: stream_create_subscribers_data.must_be_subscribed(user.user_id),
|
||||||
};
|
};
|
||||||
return render_new_stream_user(item);
|
return render_new_stream_user(item);
|
||||||
},
|
},
|
||||||
|
sort_fields: {
|
||||||
|
email: settings_users.sort_email,
|
||||||
|
id: settings_users.sort_user_id,
|
||||||
|
},
|
||||||
filter: {
|
filter: {
|
||||||
$element: $("#people_to_add .add-user-list-filter"),
|
$element: $("#people_to_add .add-user-list-filter"),
|
||||||
predicate(user_id, search_term) {
|
predicate(user, search_term) {
|
||||||
const user = people.get_by_user_id(user_id);
|
|
||||||
return people.build_person_matcher(search_term)(user);
|
return people.build_person_matcher(search_term)(user);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
$simplebar_container,
|
$simplebar_container,
|
||||||
html_selector(user_id) {
|
html_selector(user) {
|
||||||
const user = people.get_by_user_id(user_id);
|
|
||||||
return $(`#${CSS.escape("user_checkbox_" + user.user_id)}`);
|
return $(`#${CSS.escape("user_checkbox_" + user.user_id)}`);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import * as ListWidget from "./list_widget";
|
|||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as peer_data from "./peer_data";
|
import * as peer_data from "./peer_data";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
import * as settings_users from "./settings_users";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as stream_settings_containers from "./stream_settings_containers";
|
import * as stream_settings_containers from "./stream_settings_containers";
|
||||||
import * as sub_store from "./sub_store";
|
import * as sub_store from "./sub_store";
|
||||||
@@ -122,6 +123,11 @@ function make_list_widget({$parent_container, name, user_ids, user_can_remove_su
|
|||||||
return match;
|
return match;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
$parent_container: $("#stream_members_list").expectOne(),
|
||||||
|
sort_fields: {
|
||||||
|
email: settings_users.sort_email,
|
||||||
|
id: settings_users.sort_user_id,
|
||||||
|
},
|
||||||
$simplebar_container,
|
$simplebar_container,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
<div class="subscriber_list_container" data-simplebar>
|
<div class="subscriber_list_container" data-simplebar>
|
||||||
<table class="subscriber-list table table-striped">
|
<table class="subscriber-list table table-striped">
|
||||||
<thead class="table-sticky-headers">
|
<thead class="table-sticky-headers">
|
||||||
<th>{{t "Name" }}</th>
|
<th data-sort="alphabetic" data-sort-prop="full_name">{{t "Name" }}</th>
|
||||||
<th>{{t "Email" }}</th>
|
<th data-sort="email">{{t "Email" }}</th>
|
||||||
<th>{{t "User ID" }}</th>
|
<th data-sort="id">{{t "User ID" }}</th>
|
||||||
<th>{{t "Action" }}</th>
|
<th>{{t "Action" }}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="create_stream_subscribers" class="subscriber_table"></tbody>
|
<tbody id="create_stream_subscribers" class="subscriber_table"></tbody>
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
<div class="subscriber-list-box">
|
<div class="subscriber-list-box">
|
||||||
<div class="subscriber_list_container" data-simplebar>
|
<div class="subscriber_list_container" data-simplebar>
|
||||||
<div class="subscriber_list_loading_indicator"></div>
|
<div class="subscriber_list_loading_indicator"></div>
|
||||||
<table class="subscriber-list table table-striped">
|
<table id="stream_members_list" class="subscriber-list table table-striped">
|
||||||
<thead class="table-sticky-headers">
|
<thead class="table-sticky-headers">
|
||||||
<th>{{t "Name" }}</th>
|
<th data-sort="alphabetic" data-sort-prop="full_name">{{t "Name" }}</th>
|
||||||
<th>{{t "Email" }}</th>
|
<th data-sort="email">{{t "Email" }}</th>
|
||||||
<th>{{t "User ID" }}</th>
|
<th data-sort="id">{{t "User ID" }}</th>
|
||||||
{{#if can_remove_subscribers}}
|
{{#if can_remove_subscribers}}
|
||||||
<th class="actions">{{t "Actions" }}</th>
|
<th class="actions">{{t "Actions" }}</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
Reference in New Issue
Block a user