mirror of https://github.com/zulip/zulip.git
stream_create: Refactor code to set default value for retention setting.
The message retention setting is only visible to owners in the stream creation form, so the jquery code to hide the custom input, set the default value for dropdown and listener to show and hide the custom input should be called only for owners.
This commit is contained in:
parent
1c1b911a42
commit
6f20d7c9ab
|
@ -317,17 +317,24 @@ export function show_new_stream_modal() {
|
|||
// Select the first visible and enabled choice for stream privacy.
|
||||
$("#make-invite-only input:visible:not([disabled])").first().prop("checked", true);
|
||||
// Make the options default to the same each time
|
||||
$("#stream_creation_form .stream-message-retention-days-input").hide();
|
||||
$("#stream_creation_form select[name=stream_message_retention_setting]").val("realm_default");
|
||||
|
||||
// Add listener to .show stream-message-retention-days-input that we've hidden above
|
||||
$("#stream_creation_form .stream_message_retention_setting").on("change", (e) => {
|
||||
if (e.target.value === "custom_period") {
|
||||
$("#stream_creation_form .stream-message-retention-days-input").show();
|
||||
} else {
|
||||
$("#stream_creation_form .stream-message-retention-days-input").hide();
|
||||
}
|
||||
});
|
||||
// The message retention setting is visible to owners only. The below block
|
||||
// sets the default state of setting if it is visible.
|
||||
if (page_params.is_owner) {
|
||||
$("#stream_creation_form .stream-message-retention-days-input").hide();
|
||||
$("#stream_creation_form select[name=stream_message_retention_setting]").val(
|
||||
"realm_default",
|
||||
);
|
||||
|
||||
// Add listener to .show stream-message-retention-days-input that we've hidden above
|
||||
$("#stream_creation_form .stream_message_retention_setting").on("change", (e) => {
|
||||
if (e.target.value === "custom_period") {
|
||||
$("#stream_creation_form .stream-message-retention-days-input").show();
|
||||
} else {
|
||||
$("#stream_creation_form .stream-message-retention-days-input").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// set default state for "announce stream" option.
|
||||
update_announce_stream_state();
|
||||
|
|
Loading…
Reference in New Issue