mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 02:23:57 +00:00
settings_profile_fields: Refactor to use variables.
Fixes part of #28867. Co-authored-by: Tanmay Kumar <tnmdotkr@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
232c636248
commit
bb8bda0bf7
@@ -509,15 +509,18 @@ function open_edit_form_modal(this: HTMLElement): void {
|
|||||||
// Set initial value in edit form
|
// Set initial value in edit form
|
||||||
$profile_field_form.find("input[name=name]").val(field.name);
|
$profile_field_form.find("input[name=name]").val(field.name);
|
||||||
$profile_field_form.find("input[name=hint]").val(field.hint);
|
$profile_field_form.find("input[name=hint]").val(field.hint);
|
||||||
|
const $edit_profile_field_choices_container = $profile_field_form.find(
|
||||||
|
".edit_profile_field_choices_container",
|
||||||
|
);
|
||||||
|
|
||||||
$profile_field_form
|
$edit_profile_field_choices_container.on("input", ".choice-row input", add_choice_row);
|
||||||
.find(".edit_profile_field_choices_container")
|
$edit_profile_field_choices_container.on(
|
||||||
.on("input", ".choice-row input", add_choice_row);
|
"click",
|
||||||
$profile_field_form
|
"button.delete-choice",
|
||||||
.find(".edit_profile_field_choices_container")
|
function (this: HTMLElement) {
|
||||||
.on("click", "button.delete-choice", function (this: HTMLElement) {
|
|
||||||
delete_choice_row_for_edit(this, $profile_field_form, field);
|
delete_choice_row_for_edit(this, $profile_field_form, field);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
$("#edit-custom-profile-field-form-modal .dialog_submit_button").prop("disabled", true);
|
$("#edit-custom-profile-field-form-modal .dialog_submit_button").prop("disabled", true);
|
||||||
// Setup onInput event listeners to disable/enable submit button,
|
// Setup onInput event listeners to disable/enable submit button,
|
||||||
@@ -741,11 +744,12 @@ export function do_populate_profile_fields(profile_fields_data: CustomProfileFie
|
|||||||
|
|
||||||
function set_up_select_field(): void {
|
function set_up_select_field(): void {
|
||||||
const field_types = realm.custom_profile_field_types;
|
const field_types = realm.custom_profile_field_types;
|
||||||
|
const $profile_field_choices = $("#profile_field_choices");
|
||||||
|
|
||||||
create_choice_row($("#profile_field_choices"));
|
create_choice_row($profile_field_choices);
|
||||||
|
|
||||||
if (current_user.is_admin) {
|
if (current_user.is_admin) {
|
||||||
const choice_list = util.the($("#profile_field_choices"));
|
const choice_list = util.the($profile_field_choices);
|
||||||
SortableJS.create(choice_list, {
|
SortableJS.create(choice_list, {
|
||||||
onUpdate() {
|
onUpdate() {
|
||||||
// Do nothing on drag. We process the order on submission
|
// Do nothing on drag. We process the order on submission
|
||||||
@@ -774,8 +778,8 @@ function set_up_select_field(): void {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
$("#profile_field_choices").on("input", ".choice-row input", add_choice_row);
|
$profile_field_choices.on("input", ".choice-row input", add_choice_row);
|
||||||
$("#profile_field_choices").on("click", "button.delete-choice", function (this: HTMLElement) {
|
$profile_field_choices.on("click", "button.delete-choice", function (this: HTMLElement) {
|
||||||
delete_choice_row(this);
|
delete_choice_row(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user