mirror of https://github.com/zulip/zulip.git
settings_profile_fields: Move computations out of ListWidget code.
This commit moves the code to compute the profile field order and the number of fields shown is user card, out of the list_widget functions just to maintain the code readability and keeping code easy to understand.
This commit is contained in:
parent
8af4366cc0
commit
553409c1ca
|
@ -670,10 +670,19 @@ export function do_populate_profile_fields(profile_fields_data: CustomProfileFie
|
|||
|
||||
let display_in_profile_summary_fields_count = 0;
|
||||
|
||||
for (const profile_field of profile_fields_data) {
|
||||
order.push(profile_field.id);
|
||||
|
||||
// Keeping counts of all display_in_profile_summary profile fields,
|
||||
// to keep track of whether the limit has been reached.
|
||||
if (profile_field.display_in_profile_summary) {
|
||||
display_in_profile_summary_fields_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
ListWidget.create($profile_fields_table, profile_fields_data, {
|
||||
name: "settings_profile_fields_list",
|
||||
get_item(profile_field) {
|
||||
order.push(profile_field.id);
|
||||
return profile_field;
|
||||
},
|
||||
modifier_html(profile_field) {
|
||||
|
@ -688,12 +697,6 @@ export function do_populate_profile_fields(profile_fields_data: CustomProfileFie
|
|||
const display_in_profile_summary = profile_field.display_in_profile_summary === true;
|
||||
const required = profile_field.required;
|
||||
|
||||
// Keeping counts of all display_in_profile_summary profile fields, to keep track of
|
||||
// whether the limit has been reached.
|
||||
if (display_in_profile_summary) {
|
||||
display_in_profile_summary_fields_count += 1;
|
||||
}
|
||||
|
||||
return render_admin_profile_field_list({
|
||||
profile_field: {
|
||||
id: profile_field.id,
|
||||
|
|
Loading…
Reference in New Issue