custom_profile_fields: Refactor toggle `required` field.

Do not send unnecessary extra params when changing the value of
`required` field. Instead of searching realm.custom_profile_fields
for the field we are editing, we will just use the checkbox value to update
the field value, since we don't need to send other params like `name`,
`hint`, etc. to the API after API feature level 252 update.
This commit is contained in:
Shubham Padia 2024-04-16 15:55:11 +05:30 committed by Tim Abbott
parent d28d9fec0d
commit f5112446dd
1 changed files with 1 additions and 11 deletions

View File

@ -597,19 +597,9 @@ function toggle_display_in_profile_summary_profile_field(e) {
function toggle_required(e) { function toggle_required(e) {
const field_id = Number.parseInt($(e.currentTarget).attr("data-profile-field-id"), 10); const field_id = Number.parseInt($(e.currentTarget).attr("data-profile-field-id"), 10);
const field = get_profile_field(field_id);
let field_data;
if (field.field_data) {
field_data = field.field_data;
}
const data = { const data = {
name: field.name, required: $(e.currentTarget).prop("checked"),
hint: field.hint,
field_data,
display_in_profile_summary: field.display_in_profile_summary,
required: !field.required,
}; };
const $profile_field_status = $("#admin-profile-field-status").expectOne(); const $profile_field_status = $("#admin-profile-field-status").expectOne();