Skip to content

Commit cf265e2

Browse files
authored
Examine Management: Allow selection of all available fields in Examine search results, and fix layout issue when not all records have all fields (closes #20878 and #20879) (#20909)
* Allowed selection of all available fields in Examine search results, and fix layout issue when not all records have all fields. * Updates from code review.
1 parent fd5077d commit cf265e2

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/search/examine-management-dashboard/views/section-view-examine-searchers.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
9797
}
9898

9999
private _updateFieldFilter() {
100-
this._searchResults?.map((doc) => {
100+
const documentFields: ExposedSearchResultField[] = [];
101+
102+
this._searchResults?.forEach((doc) => {
101103
const document = doc.fields?.filter((field) => {
102104
return field.name?.toUpperCase() !== 'NODENAME';
103105
});
@@ -106,16 +108,16 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
106108
return field.name ?? '';
107109
});
108110

109-
// TODO: I don't get this code, not sure what the purpose is, it seems like a mistake: [NL]
110-
this._exposedFields = this._exposedFields
111-
? this._exposedFields.filter((field) => {
112-
return { name: field.name, exposed: field.exposed };
113-
})
114-
: newFieldNames?.map((name) => {
115-
return { name, exposed: false };
116-
});
111+
newFieldNames.forEach((name) => {
112+
if (!documentFields.find((field) => field.name === name)) {
113+
const exposed = this._exposedFields?.find((field) => field.name === name)?.exposed ?? false;
114+
documentFields.push({ name, exposed });
115+
}
116+
});
117117
}
118118
});
119+
120+
this._exposedFields = documentFields.sort((a, b) => a.name.localeCompare(b.name));
119121
}
120122

121123
async #onFieldFilterClick() {
@@ -286,11 +288,17 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
286288

287289
renderBodyCells(cellData: UmbSearchFieldPresentationModel[]) {
288290
return html`${this._exposedFields?.map((slot) => {
289-
return cellData.map((field) => {
290-
return slot.exposed && field.name == slot.name
291-
? html`<uui-table-cell clip-text>${field.values}</uui-table-cell>`
292-
: html``;
293-
});
291+
if (slot.exposed) {
292+
const field = cellData.find((field) => field.name === slot.name);
293+
if (field) {
294+
return html`<uui-table-cell clip-text>${field.values}</uui-table-cell>`;
295+
}
296+
297+
// Exposed field not found for this record, render empty cell.
298+
return html`<uui-table-cell></uui-table-cell>`;
299+
}
300+
301+
return html``;
294302
})}`;
295303
}
296304

0 commit comments

Comments
 (0)