Skip to content

Commit 789a147

Browse files
authored
Merge pull request DSpace#1825 from atmire/w2p-94060_Issue-1720_MyDSpace-support-entities
MyDSpace support for entity type specific list views
2 parents b26da89 + d064c26 commit 789a147

23 files changed

Lines changed: 200 additions & 96 deletions

File tree

src/app/core/data/base/base-data.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { ObjectCacheService } from '../../cache/object-cache.service';
2525
import { HALDataService } from './hal-data-service.interface';
2626
import { getFirstCompletedRemoteData } from '../../shared/operators';
2727

28+
export const EMBED_SEPARATOR = '%2F';
2829
/**
2930
* Common functionality for data services.
3031
* Specific functionality that not all services would need
@@ -202,7 +203,7 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
202203
let nestEmbed = embedString;
203204
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
204205
if (hasValue(linkToFollow) && linkToFollow.shouldEmbed) {
205-
nestEmbed = nestEmbed + '/' + String(linkToFollow.name);
206+
nestEmbed = nestEmbed + EMBED_SEPARATOR + String(linkToFollow.name);
206207
// Add the nested embeds size if given in the FollowLinkConfig.FindListOptions
207208
if (hasValue(linkToFollow.findListOptions) && hasValue(linkToFollow.findListOptions.elementsPerPage)) {
208209
const nestedEmbedSize = 'embed.size=' + nestEmbed.split('=')[1] + '=' + linkToFollow.findListOptions.elementsPerPage;

src/app/core/data/base/find-all-data.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
2222
import { HALEndpointService } from '../../shared/hal-endpoint.service';
2323
import { ObjectCacheService } from '../../cache/object-cache.service';
2424
import { Observable, of as observableOf } from 'rxjs';
25+
import { EMBED_SEPARATOR } from './base-data.service';
2526

2627
/**
2728
* Tests whether calls to `FindAllData` methods are correctly patched through in a concrete data service that implements it
@@ -276,15 +277,15 @@ describe('FindAllDataImpl', () => {
276277
});
277278

278279
it('should include nested linksToFollow 3lvl', () => {
279-
const expected = `${endpoint}?embed=owningCollection/itemtemplate/relationships`;
280+
const expected = `${endpoint}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
280281

281282
(service as any).getFindAllHref({}, null, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships')))).subscribe((value) => {
282283
expect(value).toBe(expected);
283284
});
284285
});
285286

286287
it('should include nested linksToFollow 2lvl and nested embed\'s size', () => {
287-
const expected = `${endpoint}?embed.size=owningCollection/itemtemplate=4&embed=owningCollection/itemtemplate`;
288+
const expected = `${endpoint}?embed.size=owningCollection${EMBED_SEPARATOR}itemtemplate=4&embed=owningCollection${EMBED_SEPARATOR}itemtemplate`;
288289
const config: FindListOptions = Object.assign(new FindListOptions(), {
289290
elementsPerPage: 4,
290291
});

src/app/core/data/base/identifiable-data.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
1919
import { HALEndpointService } from '../../shared/hal-endpoint.service';
2020
import { ObjectCacheService } from '../../cache/object-cache.service';
2121
import { IdentifiableDataService } from './identifiable-data.service';
22+
import { EMBED_SEPARATOR } from './base-data.service';
2223

2324
const endpoint = 'https://rest.api/core';
2425

@@ -137,7 +138,7 @@ describe('IdentifiableDataService', () => {
137138
});
138139

139140
it('should include nested linksToFollow 3lvl', () => {
140-
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection/itemtemplate/relationships`;
141+
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
141142
const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships'))));
142143
expect(result).toEqual(expected);
143144
});

src/app/core/data/dso-redirect.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { GetRequest, IdentifierType } from './request.models';
99
import { RequestService } from './request.service';
1010
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
1111
import { Item } from '../shared/item.model';
12+
import { EMBED_SEPARATOR } from './base/base-data.service';
1213

1314
describe('DsoRedirectService', () => {
1415
let scheduler: TestScheduler;
@@ -174,7 +175,7 @@ describe('DsoRedirectService', () => {
174175
});
175176

176177
it('should include nested linksToFollow 3lvl', () => {
177-
const expected = `${requestUUIDURL}&embed=owningCollection/itemtemplate/relationships`;
178+
const expected = `${requestUUIDURL}&embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
178179
const result = (service as any).dataService.getIDHref(
179180
pidLink,
180181
dsoUUID,

src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
77
</ds-thumbnail>
88
</a>
9+
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
10+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
11+
</ds-thumbnail>
12+
</span>
913
</div>
1014
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
1115
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>

src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
77
</ds-thumbnail>
88
</a>
9+
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
10+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
11+
</ds-thumbnail>
12+
</span>
913
</div>
1014
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
1115
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>

src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
66
</ds-thumbnail>
77
</a>
8+
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out">
9+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
10+
</ds-thumbnail>
11+
</span>
812
</div>
913
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
1014
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
<div class="row">
2-
<div *ngIf="showThumbnails" class="col-3 col-md-2">
3-
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
4-
rel="noopener noreferrer"
5-
[routerLink]="[itemPageRoute]" class="dont-break-out">
6-
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
7-
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
8-
[alt]="'thumbnail.orgunit.alt'"
9-
[placeholder]="'thumbnail.orgunit.placeholder'">
10-
</ds-thumbnail>
11-
</a>
12-
</div>
13-
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
14-
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
15-
<ds-truncatable [id]="dso.id">
16-
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
17-
rel="noopener noreferrer"
18-
[routerLink]="[itemPageRoute]" class="lead"
19-
[innerHTML]="dsoTitle"></a>
20-
<span *ngIf="linkType == linkTypes.None"
21-
class="lead"
22-
[innerHTML]="dsoTitle"></span>
23-
<span class="text-muted">
2+
<div *ngIf="showThumbnails" class="col-3 col-md-2">
3+
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
4+
rel="noopener noreferrer"
5+
[routerLink]="[itemPageRoute]" class="dont-break-out">
6+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
7+
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
8+
[alt]="'thumbnail.orgunit.alt'"
9+
[placeholder]="'thumbnail.orgunit.placeholder'">
10+
</ds-thumbnail>
11+
</a>
12+
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
13+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
14+
[defaultImage]="'assets/images/orgunit-placeholder.svg'"
15+
[alt]="'thumbnail.orgunit.alt'"
16+
[placeholder]="'thumbnail.orgunit.placeholder'">
17+
</ds-thumbnail>
18+
</span>
19+
</div>
20+
<div [ngClass]="showThumbnails ? 'col-9' : 'col-md-12'">
21+
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
22+
<ds-truncatable [id]="dso.id">
23+
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
24+
rel="noopener noreferrer"
25+
[routerLink]="[itemPageRoute]" class="lead"
26+
[innerHTML]="dsoTitle || ('orgunit.listelement.no-title' | translate)"></a>
27+
<span *ngIf="linkType == linkTypes.None"
28+
class="lead"
29+
[innerHTML]="dsoTitle || ('orgunit.listelement.no-title' | translate)"></span>
30+
<span class="text-muted">
2431
<span *ngIf="dso.allMetadata(['dc.description']).length > 0"
2532
class="item-list-org-unit-description">
2633
<ds-truncatable-part [id]="dso.id" [minLines]="3"><span
27-
[innerHTML]="firstMetadataValue('dc.description')"></span>
34+
[innerHTML]="firstMetadataValue('dc.description')"></span>
2835
</ds-truncatable-part>
2936
</span>
3037
</span>
31-
</ds-truncatable>
32-
</div>
38+
</ds-truncatable>
39+
</div>
3340
</div>

src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared
1010
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
1111
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
1212
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
13+
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
14+
import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock';
1315

1416
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
1517
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
@@ -66,6 +68,13 @@ const enviromentNoThumbs = {
6668
describe('OrgUnitSearchResultListElementComponent', () => {
6769
beforeEach(waitForAsync(() => {
6870
TestBed.configureTestingModule({
71+
imports: [TranslateModule.forRoot({
72+
loader: {
73+
provide: TranslateLoader,
74+
useClass: TranslateLoaderMock
75+
}
76+
}
77+
)],
6978
declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe],
7079
providers: [
7180
{ provide: TruncatableService, useValue: {} },
@@ -129,6 +138,13 @@ describe('OrgUnitSearchResultListElementComponent', () => {
129138

130139
beforeEach(waitForAsync(() => {
131140
TestBed.configureTestingModule({
141+
imports: [TranslateModule.forRoot({
142+
loader: {
143+
provide: TranslateLoader,
144+
useClass: TranslateLoaderMock
145+
}
146+
}
147+
)],
132148
declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe],
133149
providers: [
134150
{provide: TruncatableService, useValue: {}},

src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@
99
[placeholder]="'thumbnail.person.placeholder'">
1010
</ds-thumbnail>
1111
</a>
12+
<span *ngIf="linkType == linkTypes.None" class="dont-break-out">
13+
<ds-thumbnail [thumbnail]="dso?.thumbnail | async"
14+
[defaultImage]="'assets/images/person-placeholder.svg'"
15+
[alt]="'thumbnail.person.alt'"
16+
[placeholder]="'thumbnail.person.placeholder'">
17+
</ds-thumbnail>
18+
</span>
1219
</div>
1320
<div [ngClass]="showThumbnails ? 'col-9 col-md-10' : 'col-12'">
1421
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
1522
<ds-truncatable [id]="dso.id">
1623
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'"
1724
rel="noopener noreferrer"
1825
[routerLink]="[itemPageRoute]" class="lead"
19-
[innerHTML]="dsoTitle"></a>
26+
[innerHTML]="dsoTitle || ('person.listelement.no-title' | translate)"></a>
2027
<span *ngIf="linkType == linkTypes.None"
2128
class="lead"
22-
[innerHTML]="dsoTitle"></span>
29+
[innerHTML]="dsoTitle || ('person.listelement.no-title' | translate)"></span>
2330
<span class="text-muted">
2431
<ds-truncatable-part [id]="dso.id" [minLines]="1">
2532
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"

0 commit comments

Comments
 (0)