mirror of https://github.com/zulip/zulip.git
settings_acount: Standardize type passed to update custom fields.
This commit is contained in:
parent
caf919fca2
commit
adf3280f1e
|
@ -186,22 +186,17 @@ function settings_change_error(message_html, xhr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_custom_profile_field(field, method) {
|
function update_custom_profile_field(field, method) {
|
||||||
let field_id;
|
let data;
|
||||||
if (method === channel.del) {
|
if (method === channel.del) {
|
||||||
field_id = field;
|
data = JSON.stringify([field.id]);
|
||||||
} else {
|
} else {
|
||||||
field_id = field.id;
|
data = JSON.stringify([field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const $spinner_element = $(
|
const $spinner_element = $(
|
||||||
`.custom_user_field[data-field-id="${CSS.escape(field_id)}"] .custom-field-status`,
|
`.custom_user_field[data-field-id="${CSS.escape(field.id.toString())}"] .custom-field-status`,
|
||||||
).expectOne();
|
).expectOne();
|
||||||
settings_ui.do_settings_change(
|
settings_ui.do_settings_change(method, "/json/users/me/profile_data", {data}, $spinner_element);
|
||||||
method,
|
|
||||||
"/json/users/me/profile_data",
|
|
||||||
{data: JSON.stringify([field])},
|
|
||||||
$spinner_element,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_user_custom_profile_fields(fields, method) {
|
function update_user_custom_profile_fields(fields, method) {
|
||||||
|
@ -217,7 +212,7 @@ function update_user_custom_profile_fields(fields, method) {
|
||||||
function update_user_type_field(field, pills) {
|
function update_user_type_field(field, pills) {
|
||||||
const user_ids = user_pill.get_user_ids(pills);
|
const user_ids = user_pill.get_user_ids(pills);
|
||||||
if (user_ids.length < 1) {
|
if (user_ids.length < 1) {
|
||||||
update_user_custom_profile_fields([field.id], channel.del);
|
update_user_custom_profile_fields([{id: field.id}], channel.del);
|
||||||
} else {
|
} else {
|
||||||
update_user_custom_profile_fields([{id: field.id, value: user_ids}], channel.patch);
|
update_user_custom_profile_fields([{id: field.id, value: user_ids}], channel.patch);
|
||||||
}
|
}
|
||||||
|
@ -685,7 +680,7 @@ export function set_up() {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const $field = $(e.target).closest(".custom_user_field").expectOne();
|
const $field = $(e.target).closest(".custom_user_field").expectOne();
|
||||||
const field_id = Number.parseInt($field.attr("data-field-id"), 10);
|
const field_id = Number.parseInt($field.attr("data-field-id"), 10);
|
||||||
update_user_custom_profile_fields([field_id], channel.del);
|
update_user_custom_profile_fields([{id: field_id}], channel.del);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#profile-settings").on("change", ".custom_user_field_value", function (e) {
|
$("#profile-settings").on("change", ".custom_user_field_value", function (e) {
|
||||||
|
@ -699,7 +694,7 @@ export function set_up() {
|
||||||
fields.push({id: field_id, value});
|
fields.push({id: field_id, value});
|
||||||
update_user_custom_profile_fields(fields, channel.patch);
|
update_user_custom_profile_fields(fields, channel.patch);
|
||||||
} else {
|
} else {
|
||||||
fields.push(field_id);
|
fields.push({id: field_id});
|
||||||
update_user_custom_profile_fields(fields, channel.del);
|
update_user_custom_profile_fields(fields, channel.del);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue