mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
custom_profile_fields: Rename is_editable variable for clarity.
The variable is renamed to is_target_element_editable. This makes it explicit that this variable is referring to HTML structure and not a property of the field. This is a prep commit for #22883 which allows admins to restrict users from modifying field values.
This commit is contained in:
@@ -78,7 +78,7 @@ export function append_custom_profile_fields(element_id: string, user_id: number
|
|||||||
export function initialize_custom_user_type_fields(
|
export function initialize_custom_user_type_fields(
|
||||||
element_id: string,
|
element_id: string,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
is_editable: boolean,
|
is_target_element_editable: boolean,
|
||||||
pill_update_handler?: (
|
pill_update_handler?: (
|
||||||
field: {
|
field: {
|
||||||
type: number;
|
type: number;
|
||||||
@@ -104,16 +104,19 @@ export function initialize_custom_user_type_fields(
|
|||||||
for (const field of realm.custom_profile_fields) {
|
for (const field of realm.custom_profile_fields) {
|
||||||
const field_value_raw = people.get_custom_profile_data(user_id, field.id)?.value;
|
const field_value_raw = people.get_custom_profile_data(user_id, field.id)?.value;
|
||||||
|
|
||||||
// If field is not editable and field value is null, we don't expect
|
// If we are not editing the field and field value is null, we don't expect
|
||||||
// pill container for that field and proceed further
|
// pill container for that field and proceed further
|
||||||
if (field.type === field_types.USER.id && (field_value_raw !== undefined || is_editable)) {
|
if (
|
||||||
|
field.type === field_types.USER.id &&
|
||||||
|
(field_value_raw !== undefined || is_target_element_editable)
|
||||||
|
) {
|
||||||
const $pill_container = $(element_id)
|
const $pill_container = $(element_id)
|
||||||
.find(
|
.find(
|
||||||
`.custom_user_field[data-field-id="${CSS.escape(`${field.id}`)}"] .pill-container`,
|
`.custom_user_field[data-field-id="${CSS.escape(`${field.id}`)}"] .pill-container`,
|
||||||
)
|
)
|
||||||
.expectOne();
|
.expectOne();
|
||||||
const pill_config = {
|
const pill_config = {
|
||||||
exclude_inaccessible_users: is_editable,
|
exclude_inaccessible_users: is_target_element_editable,
|
||||||
};
|
};
|
||||||
const pills = user_pill.create_pills($pill_container, pill_config);
|
const pills = user_pill.create_pills($pill_container, pill_config);
|
||||||
|
|
||||||
@@ -125,7 +128,10 @@ export function initialize_custom_user_type_fields(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_editable) {
|
// We check and disable fields that this user doesn't have permission to edit.
|
||||||
|
const is_disabled = $pill_container.hasClass("disabled");
|
||||||
|
|
||||||
|
if (is_target_element_editable && !is_disabled) {
|
||||||
const $input = $pill_container.children(".input");
|
const $input = $pill_container.children(".input");
|
||||||
if (pill_update_handler) {
|
if (pill_update_handler) {
|
||||||
const update_func = (): void => {
|
const update_func = (): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user