Skip to content

Commit 82c6caf

Browse files
Port #1291 to dtq-dev-9-base: UFAL/Updated components to display dc.description instead of dc.description.abstract (#1291) (#1501)
The search result list and grid elements read the item description from dc.description.abstract. LINDAT items carry their description in dc.description, so both views rendered nothing where the description belongs. Both templates now read dc.description in the guard and in the binding (4 substitutions across the two files). The trade-off is deliberate and was made in #1291: an item that only has dc.description.abstract now shows no description in these two views. The two new negative specs pin exactly that, so the trade-off cannot be undone by accident. - item-search-result-grid-element.component.html / .spec.ts: the @if guard and the [innerHTML] binding switch key; mockItemWithAbstractOnly is added and passed as a new 5th argument to getEntityGridElementTestComponent. That parameter is optional, so the six entity-group grid specs that call the helper with four arguments (journal, journal-issue, journal-volume, org-unit, person, project) keep compiling unchanged. - item-search-result-list-element.component.html / .spec.ts: same key switch plus a mockItemWithAbstractOnly and a negative describe block. v9 notes: the source hunks are *ngIf; both templates on this branch have already been migrated to @if, so the guards were adapted in place - same condition, same two metadata keys per file. The list spec uses `of` where the source uses `observableOf`, and the new mocks follow this branch's trailing-comma style. The custom theme's item-search-result-list-element reuses the base templateUrl, so no theme override needed changing; the grid element has no theme override. Card PB-05 (tranche T3). Source: 3a95a85 (dtq-dev PR #1291) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8e8fb9d commit 82c6caf

4 files changed

Lines changed: 77 additions & 12 deletions

File tree

src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ <h4 class="card-title" [innerHTML]="dsoTitle"></h4>
4141
</p>
4242
</ds-truncatable-part>
4343
}
44-
@if (dso.hasMetadata('dc.description.abstract')) {
44+
@if (dso.hasMetadata('dc.description')) {
4545
<ds-truncatable-part [id]="dso.id" [minLines]="3">
4646
<p class="item-abstract card-text">
47-
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
47+
<span [innerHTML]="firstMetadataValue('dc.description')"></span>
4848
</p>
4949
</ds-truncatable-part>
5050
}

src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,33 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
7373
value: '2015-06-26',
7474
},
7575
],
76-
'dc.description.abstract': [
76+
'dc.description': [
7777
{
7878
language: 'en_US',
7979
value: 'This is an abstract',
8080
},
8181
],
8282
},
8383
});
84+
const mockItemWithAbstractOnly: ItemSearchResult = new ItemSearchResult();
85+
mockItemWithAbstractOnly.hitHighlights = {};
86+
mockItemWithAbstractOnly.indexableObject = Object.assign(new Item(), {
87+
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
88+
metadata: {
89+
'dc.title': [
90+
{
91+
language: 'en_US',
92+
value: dcTitle,
93+
},
94+
],
95+
'dc.description.abstract': [
96+
{
97+
language: 'en_US',
98+
value: 'Legacy abstract only',
99+
},
100+
],
101+
},
102+
});
84103
const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), {
85104
hitHighlights: {
86105
'person.familyName': [{
@@ -116,7 +135,7 @@ const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), {
116135
value: '2015-06-26',
117136
},
118137
],
119-
'dc.description.abstract': [
138+
'dc.description': [
120139
{
121140
language: 'en_US',
122141
value: 'This is the abstract',
@@ -170,7 +189,7 @@ const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), {
170189
value: '2015-06-26',
171190
},
172191
],
173-
'dc.description.abstract': [
192+
'dc.description': [
174193
{
175194
language: 'en_US',
176195
value: 'This is the abstract',
@@ -204,7 +223,7 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
204223
},
205224
});
206225

207-
describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract']));
226+
describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'], mockItemWithAbstractOnly));
208227

209228
/**
210229
* Create test cases for a grid component of an entity.
@@ -215,7 +234,13 @@ describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearc
215234
* For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's
216235
* present when the author metadata is available.
217236
*/
218-
export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) {
237+
export function getEntityGridElementTestComponent(
238+
component,
239+
searchResultWithMetadata: ItemSearchResult,
240+
searchResultWithoutMetadata: ItemSearchResult,
241+
fieldsToCheck: string[],
242+
searchResultWithAbstractOnly?: ItemSearchResult,
243+
) {
219244
return () => {
220245
let comp;
221246
let fixture;
@@ -269,6 +294,20 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
269294
comp = fixture.componentInstance;
270295
}));
271296

297+
if (searchResultWithAbstractOnly) {
298+
describe('when the item has only dc.description.abstract metadata', () => {
299+
beforeEach(() => {
300+
comp.object = searchResultWithAbstractOnly;
301+
fixture.detectChanges();
302+
});
303+
304+
it('should not show abstract field', () => {
305+
const abstractField = fixture.debugElement.query(By.css('.item-abstract'));
306+
expect(abstractField).toBeNull();
307+
});
308+
});
309+
}
310+
272311
fieldsToCheck.forEach((field) => {
273312
describe(`when the item has "${field}" metadata`, () => {
274313
beforeEach(() => {

src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
}
6262
</ds-truncatable-part>
6363
</span>
64-
@if (dso.firstMetadataValue('dc.description.abstract')) {
64+
@if (dso.firstMetadataValue('dc.description')) {
6565
<div class="item-list-abstract">
6666
<ds-truncatable-part [id]="dso.id" [minLines]="3"><span
67-
[innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
67+
[innerHTML]="firstMetadataValue('dc.description')"></span>
6868
</ds-truncatable-part>
6969
</div>
7070
}

src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul
6868
value: '2015-06-26',
6969
},
7070
],
71-
'dc.description.abstract': [
71+
'dc.description': [
7272
{
7373
language: 'en_US',
7474
value: 'This is the abstract',
@@ -77,6 +77,20 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul
7777
},
7878
}),
7979
});
80+
const mockItemWithAbstractOnly: ItemSearchResult = Object.assign(new ItemSearchResult(), {
81+
indexableObject:
82+
Object.assign(new Item(), {
83+
bundles: of({}),
84+
metadata: {
85+
'dc.description.abstract': [
86+
{
87+
language: 'en_US',
88+
value: 'Legacy abstract only',
89+
},
90+
],
91+
},
92+
}),
93+
});
8094
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
8195
indexableObject:
8296
Object.assign(new Item(), {
@@ -119,7 +133,7 @@ const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), {
119133
value: '2015-06-26',
120134
},
121135
],
122-
'dc.description.abstract': [
136+
'dc.description': [
123137
{
124138
language: 'en_US',
125139
value: 'This is the abstract',
@@ -173,7 +187,7 @@ const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), {
173187
value: '2015-06-26',
174188
},
175189
],
176-
'dc.description.abstract': [
190+
'dc.description': [
177191
{
178192
language: 'en_US',
179193
value: 'This is the abstract',
@@ -349,6 +363,18 @@ describe('ItemSearchResultListElementComponent', () => {
349363
});
350364
});
351365

366+
describe('When the item has only dc.description.abstract metadata', () => {
367+
beforeEach(() => {
368+
publicationListElementComponent.object = mockItemWithAbstractOnly;
369+
fixture.detectChanges();
370+
});
371+
372+
it('should not show the abstract span', () => {
373+
const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract'));
374+
expect(abstractField).toBeNull();
375+
});
376+
});
377+
352378
describe('When the item has title', () => {
353379
beforeEach(() => {
354380
publicationListElementComponent.object = mockItemWithMetadata;

0 commit comments

Comments
 (0)