mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
Make "Copy from Stream" more transparent/flexible.
This change makes it so that when you are creating a stream and use "Copy from Stream", the UI will immediately check/uncheck the user checkboxes that correspond to the stream's subscribers. In concrete terms this allows Cordelia to create a new stream call "Paris" that has all the "Verona" subscribers except for Hamlet. It also makes it so that when you go to create the stream, the response is a little quicker, because we don't have to iterate the streams. Finally, it removes an odd quirk from the original design, where if you clicked on Denmark but then collapsed the streams, we wouldn't actually add the Denmark subscribers to your new stream. The current UI will still be slightly intuitive for people, as I think checkmarks don't really make sense here. What we really want are Add/Remove links (or buttons) next to each of the existing streams.
This commit is contained in:
@@ -790,6 +790,25 @@ function show_new_stream_modal() {
|
||||
$('#announce-new-stream input').prop('checked', true);
|
||||
|
||||
$("#stream_name_error").hide();
|
||||
|
||||
$("#stream-checkboxes label.checkbox").on('change', function (e) {
|
||||
var elem = $(this);
|
||||
var stream_id = elem.attr('data-stream-id');
|
||||
var checked = elem.find('input').prop('checked');
|
||||
var subscriber_ids = stream_data.get_sub_by_id(stream_id).subscribers;
|
||||
|
||||
$('#user-checkboxes label.checkbox').each(function () {
|
||||
var user_elem = $(this);
|
||||
var user_id = user_elem.attr('data-user-id');
|
||||
|
||||
if (subscriber_ids.has(user_id)) {
|
||||
user_elem.find('input').prop('checked', checked);
|
||||
}
|
||||
});
|
||||
|
||||
update_announce_stream_state();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
exports.invite_user_to_stream = function (user_email, stream_name, success, failure) {
|
||||
@@ -980,32 +999,6 @@ $(function () {
|
||||
}
|
||||
);
|
||||
|
||||
var checked_streams = _.map(
|
||||
$("#stream_creation_form input:checkbox[name=stream]:checked"),
|
||||
function (elem) {
|
||||
return $(elem).val();
|
||||
}
|
||||
);
|
||||
|
||||
var checked_stream_emails = [];
|
||||
var stream_emails = [];
|
||||
|
||||
_.each(checked_streams, function (checked_stream) {
|
||||
stream_emails = [];
|
||||
var subscriber_ids = stream_data.get_sub(checked_stream).subscribers.keys();
|
||||
_.each(subscriber_ids, function (subscriber_id) {
|
||||
stream_emails.push(people.get_person_from_user_id(subscriber_id).email);
|
||||
});
|
||||
checked_stream_emails = _.union(checked_stream_emails, stream_emails);
|
||||
});
|
||||
|
||||
// If a stream was checked and the checkboxes are not visible,
|
||||
// don't add checked streams
|
||||
if ($('#stream-checkboxes').css('display') !== 'none') {
|
||||
principals = _.union(principals, checked_stream_emails);
|
||||
}
|
||||
|
||||
|
||||
// You are always subscribed to streams you create.
|
||||
principals.push(people.my_current_email());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user