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:
Sahil Batra 2024-10-10 15:45:49 +05:30 committed by Tim Abbott
parent 8af4366cc0
commit 553409c1ca
1 changed files with 10 additions and 7 deletions

View File

@ -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,