Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
custom profile fields: Rename "CHOICE" to "SELECT" in frontend.
tushar9122cf51139cfff
diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/frontend_tests/node_tests/settings_profile_fields.jsindex 94b0463f463..2d270a8143e 100644--- a/frontend_tests/node_tests/settings_profile_fields.js+++ b/frontend_tests/node_tests/settings_profile_fields.js@@ -13,11 +13,11 @@ const loading = mock_esm("../../static/js/loading");const SHORT_TEXT_ID = 1;-const CHOICE_ID = 3;+const SELECT_ID = 3;const EXTERNAL_ACCOUNT_ID = 7;const SHORT_TEXT_NAME = "Short Text";-const CHOICE_NAME = "Choice";+const SELECT_NAME = "Select";const EXTERNAL_ACCOUNT_NAME = "External account";page_params.custom_profile_fields = {};@@ -28,9 +28,9 @@ page_params.custom_profile_field_types = {id: SHORT_TEXT_ID,name: SHORT_TEXT_NAME,},- CHOICE: {- id: CHOICE_ID,- name: CHOICE_NAME,+ SELECT: {+ id: SELECT_ID,+ name: SELECT_NAME,},EXTERNAL_ACCOUNT: {id: EXTERNAL_ACCOUNT_ID,@@ -87,7 +87,7 @@ run_test("populate_profile_fields", () => {field_data: "",},{- type: CHOICE_ID,+ type: SELECT_ID,id: 30,name: "meal",hint: "lunch",@@ -130,7 +130,7 @@ run_test("populate_profile_fields", () => {hint: "blue?",type: SHORT_TEXT_NAME,choices: [],- is_choice_field: false,+ is_select_field: false,is_external_account_field: false,},can_modify: true,@@ -141,12 +141,12 @@ run_test("populate_profile_fields", () => {id: 30,name: "meal",hint: "lunch",- type: CHOICE_NAME,+ type: SELECT_NAME,choices: [{order: 0, value: "0", text: "lunch"},{order: 1, value: "1", text: "dinner"},],- is_choice_field: true,+ is_select_field: true,is_external_account_field: false,},can_modify: true,@@ -159,7 +159,7 @@ run_test("populate_profile_fields", () => {hint: "username only",type: EXTERNAL_ACCOUNT_NAME,choices: [],- is_choice_field: false,+ is_select_field: false,is_external_account_field: true,},can_modify: true,@@ -172,7 +172,7 @@ run_test("populate_profile_fields", () => {hint: "username only",type: EXTERNAL_ACCOUNT_NAME,choices: [],- is_choice_field: false,+ is_select_field: false,is_external_account_field: true,},can_modify: true,diff --git a/static/js/popovers.js b/static/js/popovers.jsindex 021612fee6e..cf1b50a3c7d 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -194,7 +194,7 @@ function get_custom_profile_field_data(user, field, field_types, dateFormat) {profile_field.is_user_field = true;profile_field.value = field_value.value;break;- case field_types.CHOICE.id: {+ case field_types.SELECT.id: {const field_choice_dict = JSON.parse(field.field_data);profile_field.value = field_choice_dict[field_value.value].text;break;diff --git a/static/js/settings_account.js b/static/js/settings_account.jsindex 58c23f51058..5b99d6a090e 100644--- a/static/js/settings_account.js+++ b/static/js/settings_account.js@@ -133,7 +133,7 @@ export function append_custom_profile_fields(element_id, user_id) {const all_field_template_types = new Map([[all_field_types.LONG_TEXT.id, "text"],[all_field_types.SHORT_TEXT.id, "text"],- [all_field_types.CHOICE.id, "choice"],+ [all_field_types.SELECT.id, "select"],[all_field_types.USER.id, "user"],[all_field_types.DATE.id, "date"],[all_field_types.EXTERNAL_ACCOUNT.id, "text"],@@ -142,13 +142,13 @@ export function append_custom_profile_fields(element_id, user_id) {for (const field of all_custom_fields) {let field_value = people.get_custom_profile_data(user_id, field.id);- const is_choice_field = field.type === all_field_types.CHOICE.id;+ const is_select_field = field.type === all_field_types.SELECT.id;const field_choices = [];if (field_value === undefined || field_value === null) {field_value = {value: "", rendered_value: ""};}- if (is_choice_field) {+ if (is_select_field) {const field_choice_dict = JSON.parse(field.field_data);for (const choice in field_choice_dict) {if (choice) {@@ -168,7 +168,7 @@ export function append_custom_profile_fields(element_id, user_id) {is_long_text_field: field.type === all_field_types.LONG_TEXT.id,is_user_field: field.type === all_field_types.USER.id,is_date_field: field.type === all_field_types.DATE.id,- is_choice_field,+ is_select_field,field_choices,});$(element_id).append(html);diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.jsindex 24bf84507c9..5d920edcd82 100644--- a/static/js/settings_profile_fields.js+++ b/static/js/settings_profile_fields.js@@ -156,7 +156,7 @@ function set_up_create_field_form() {function read_field_data_from_form(field_type_id, field_elem) {// Only read field data if we are creating a choice field// or external account field.- if (field_type_id === field_types.CHOICE.id) {+ if (field_type_id === field_types.SELECT.id) {return read_choice_field_data_from_form(field_elem);} else if (field_type_id === field_types.EXTERNAL_ACCOUNT.id) {return read_external_account_field_data(field_elem);@@ -289,7 +289,7 @@ function open_edit_form(e) {field_data = JSON.parse(field.field_data);}- if (Number.parseInt(field.type, 10) === field_types.CHOICE.id) {+ if (Number.parseInt(field.type, 10) === field_types.SELECT.id) {set_up_choices_field_edit_form(profile_field, field_data);}@@ -384,7 +384,7 @@ export function do_populate_profile_fields(profile_fields_data) {field_data = JSON.parse(profile_field.field_data);}let choices = [];- if (profile_field.type === field_types.CHOICE.id) {+ if (profile_field.type === field_types.SELECT.id) {choices = parse_field_choices_from_field_data(field_data);}@@ -396,7 +396,7 @@ export function do_populate_profile_fields(profile_fields_data) {hint: profile_field.hint,type: field_type_id_to_string(profile_field.type),choices,- is_choice_field: profile_field.type === field_types.CHOICE.id,+ is_select_field: profile_field.type === field_types.SELECT.id,is_external_account_field:profile_field.type === field_types.EXTERNAL_ACCOUNT.id,},@@ -434,14 +434,14 @@ function set_up_choices_field() {const field_type = $("#profile_field_type").val();- if (Number.parseInt(field_type, 10) !== field_types.CHOICE.id) {+ if (Number.parseInt(field_type, 10) !== field_types.SELECT.id) {// If 'Choice' type is already selected, show choice row.$("#profile_field_choices_row").hide();}$("#profile_field_type").on("change", (e) => {const selected_field_id = Number.parseInt($(e.target).val(), 10);- if (selected_field_id === field_types.CHOICE.id) {+ if (selected_field_id === field_types.SELECT.id) {$("#profile_field_choices_row").show();} else {$("#profile_field_choices_row").hide();diff --git a/static/templates/admin_profile_field_list.hbs b/static/templates/admin_profile_field_list.hbsindex ee8cb2f215a..3ec05000b01 100644--- a/static/templates/admin_profile_field_list.hbs+++ b/static/templates/admin_profile_field_list.hbs@@ -35,7 +35,7 @@<label for="hint">{{t "Hint" }}</label><input type="text" name="hint" value="{{ hint }}" maxlength="80" /></div>- {{#if is_choice_field }}+ {{#if is_select_field }}<div class="input-group"><label for="profile_field_choices_edit">{{t "Field choices" }}</label><div class="profile-field-choices" name="profile_field_choices_edit">diff --git a/static/templates/settings/custom_user_profile_field.hbs b/static/templates/settings/custom_user_profile_field.hbsindex 7ea0c25d98e..cfa0482bfd6 100644--- a/static/templates/settings/custom_user_profile_field.hbs+++ b/static/templates/settings/custom_user_profile_field.hbs@@ -4,7 +4,7 @@<div class="field">{{#if is_long_text_field}}<textarea maxlength="500" class="custom_user_field_value">{{ field_value.value }}</textarea>- {{else if is_choice_field}}+ {{else if is_select_field}}<select class="custom_user_field_value"><option value=""></option>{{#each field_choices}}diff --git a/zerver/models.py b/zerver/models.pyindex 16ac433d9c9..548ee8962b6 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -3311,7 +3311,7 @@ class CustomProfileField(models.Model):# and value argument. i.e. SELECT require field_data, USER require# realm as argument.SELECT_FIELD_TYPE_DATA: List[ExtendedFieldElement] = [- (SELECT, ugettext_lazy("List of options"), validate_select_field, str, "CHOICE"),+ (SELECT, ugettext_lazy("List of options"), validate_select_field, str, "SELECT"),]USER_FIELD_TYPE_DATA: List[UserFieldElement] = [(USER, ugettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"),