Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

custom_profile_fields: Display deleted options in confirmation modal.

Yogesh Sirsat8d04e2b4c396
diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js
index d11a906ca3d..b2d49db4deb 100644
--- a/static/js/settings_profile_fields.js
+++ b/static/js/settings_profile_fields.js
@@ -310,17 +310,20 @@ function show_modal_for_deleting_options(field, deleted_values, update_profile_f
let users_count_with_deleted_option_selected = 0;
for (const user_id of active_user_ids) {
const field_value = people.get_custom_profile_data(user_id, field.id);
- if (field_value && deleted_values.has(field_value.value)) {
+ if (field_value && deleted_values[field_value.value]) {
users_count_with_deleted_option_selected += 1;
}
}
+ const deleted_options_count = Object.keys(deleted_values).length;
const html_body = render_confirm_delete_profile_field_option({
count: users_count_with_deleted_option_selected,
field_name: field.name,
+ deleted_options_count,
+ deleted_values,
});
let modal_heading_text = "Delete this option?";
- if (Object.keys(deleted_values).length !== 1) {
+ if (deleted_options_count !== 1) {
modal_heading_text = "Delete these options?";
}
confirm_dialog.launch({
@@ -466,13 +469,15 @@ function open_edit_form_modal(e) {
}
if (field.type === field_types.SELECT.id) {
- const old_values = new Set(Object.keys(field_data));
const new_values = new Set(Object.keys(new_field_data));
- const deleted_values = new Set(
- [...old_values].filter((value) => !new_values.has(value)),
- );
+ const deleted_values = {};
+ for (const [value, option] of Object.entries(field_data)) {
+ if (!new_values.has(value)) {
+ deleted_values[value] = option.text;
+ }
+ }
- if (deleted_values.size !== 0) {
+ if (Object.keys(deleted_values).length !== 0) {
const edit_select_field_modal_callback = () =>
show_modal_for_deleting_options(field, deleted_values, update_profile_field);
dialog_widget.close_modal(edit_select_field_modal_callback);
diff --git a/static/templates/confirm_dialog/confirm_delete_profile_field_option.hbs b/static/templates/confirm_dialog/confirm_delete_profile_field_option.hbs
index e43192e678d..7f194e528a8 100644
--- a/static/templates/confirm_dialog/confirm_delete_profile_field_option.hbs
+++ b/static/templates/confirm_dialog/confirm_delete_profile_field_option.hbs
@@ -1,12 +1,28 @@
-{{#if (eq count 1)}}
- {{#tr}}
- This will clear the <z-field-name></z-field-name> profile field for 1 user.
- {{#*inline "z-field-name"}}<strong>{{field_name}}</strong>{{/inline}}
- {{/tr}}
-{{else}}
- {{#tr}}
- This will clear the <z-field-name></z-field-name> profile field for <z-count></z-count> users.
- {{#*inline "z-count"}}{{count}}{{/inline}}
- {{#*inline "z-field-name"}}<strong>{{field_name}}</strong>{{/inline}}
- {{/tr}}
-{{/if}}
+<p>
+ {{#if (eq count 1)}}
+ {{#tr}}
+ This will clear the <z-field-name></z-field-name> profile field for 1 user.
+ {{#*inline "z-field-name"}}<strong>{{field_name}}</strong>{{/inline}}
+ {{/tr}}
+ {{else}}
+ {{#tr}}
+ This will clear the <z-field-name></z-field-name> profile field for <z-count></z-count> users.
+ {{#*inline "z-count"}}{{count}}{{/inline}}
+ {{#*inline "z-field-name"}}<strong>{{field_name}}</strong>{{/inline}}
+ {{/tr}}
+ {{/if}}
+</p>
+<p>
+ <div>
+ {{#if (eq deleted_options_count 1)}}
+ {{#tr}}Deleted option:{{/tr}}
+ {{else}}
+ {{#tr}}Deleted options:{{/tr}}
+ {{/if}}
+ </div>
+ <ul>
+ {{#each deleted_values}}
+ <li>{{this}}</li>
+ {{/each}}
+ </ul>
+</p>