Skip to content

Commit 71f153a

Browse files
[DSC-1864] post alignment fixes
1 parent 6fdb6d2 commit 71f153a

10 files changed

Lines changed: 128 additions & 73 deletions

File tree

src/app/core/submission/submission-rest.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('SubmissionRestService test suite', () => {
2626
const resourceEndpoint = 'workspaceitems';
2727
const resourceScope = '260';
2828
const body = { test: new FormFieldMetadataValueObject('test') };
29-
const resourceHref = resourceEndpointURL + '/' + resourceEndpoint + '/' + resourceScope + '?embed=item,sections,collection';
29+
const resourceHref = resourceEndpointURL + '/' + resourceEndpoint + '/' + resourceScope + '?embed=item,sections,collection&projection=full';
3030
const timestampResponse = 1545994811992;
3131

3232
function initTestService() {

src/app/core/submission/submission-rest.service.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ export class SubmissionRestService {
6969
* The identifier for the object
7070
* @param collectionId
7171
* The owning collection for the object
72+
* @param projections
7273
*/
73-
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string): string {
74+
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string, projections: string[] = []): string {
7475
let url = isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
75-
url = new URLCombiner(url, '?embed=item,sections,collection').toString();
76+
url = new URLCombiner(url, '?embed=item,sections,collection&projection=full').toString();
77+
78+
projections.forEach((projection) => {
79+
url = new URLCombiner(url, '&projection=' + projection).toString();
80+
});
81+
7682
if (collectionId) {
7783
url = new URLCombiner(url, `&owningCollection=${collectionId}`).toString();
7884
}
85+
7986
return url;
8087
}
8188

@@ -108,13 +115,14 @@ export class SubmissionRestService {
108115
* The endpoint link name
109116
* @param id
110117
* The submission Object to retrieve
118+
* @param projections
111119
* @return Observable<SubmitDataResponseDefinitionObject>
112120
* server response
113121
*/
114-
public getDataById(linkName: string, id: string): Observable<SubmitDataResponseDefinitionObject> {
122+
public getDataById(linkName: string, id: string, projections: string[] = []): Observable<SubmitDataResponseDefinitionObject> {
115123
const requestId = this.requestService.generateRequestId();
116124
return this.halService.getEndpoint(linkName).pipe(
117-
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id)),
125+
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id, null, projections)),
118126
filter((href: string) => isNotEmpty(href)),
119127
distinctUntilChanged(),
120128
map((endpointURL: string) => new SubmissionRequest(requestId, endpointURL)),

src/app/item-page/edit-item-page/item-relationships/edit-item-relationships.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ export class EditItemRelationshipsService {
185185
isProvidedItemTypeLeftType(relationshipType: RelationshipType, itemType: ItemType, item: Item): Observable<boolean> {
186186
return this.getRelationshipLeftAndRightType(relationshipType).pipe(
187187
map(([leftType, rightType]: [ItemType, ItemType]) => {
188-
if (leftType.id === itemType.id) {
188+
if (leftType?.id === itemType.id) {
189189
return true;
190190
}
191191

192-
if (rightType.id === itemType.id) {
192+
if (rightType?.id === itemType.id) {
193193
return false;
194194
}
195195

@@ -209,7 +209,7 @@ export class EditItemRelationshipsService {
209209
shouldDisplayBothRelationshipSides(relationshipType: RelationshipType, itemType: ItemType): Observable<boolean> {
210210
return this.getRelationshipLeftAndRightType(relationshipType).pipe(
211211
map(([leftType, rightType]: [ItemType, ItemType]) => {
212-
return leftType.id === itemType.id && rightType.id === itemType.id && relationshipType.leftwardType !== relationshipType.rightwardType;
212+
return leftType?.id === itemType.id && rightType?.id === itemType.id && relationshipType.leftwardType !== relationshipType.rightwardType;
213213
}),
214214
);
215215
}

src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
414414

415415
this.relatedEntityType$ = this.relationshipLeftAndRightType$.pipe(
416416
map(([leftType, rightType]: [ItemType, ItemType]) => {
417-
if (leftType.uuid !== this.itemType.uuid) {
417+
if (leftType?.uuid !== this.itemType.uuid) {
418418
return leftType;
419419
} else {
420420
return rightType;

src/app/shared/auth-nav-menu/user-menu/user-menu.component.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313
a.ds-menu-item {
1414
display: block;
15-
color: var(--ds-expandable-navbar-link-color);
15+
color: var(--ds-user-menu-dropdown-link-color);
1616
&:hover {
17-
color: var(--ds-expandable-navbar-link-color-hover);
1817
background-color: var(--ds-user-menu-dropdown-link-background-hover);
1918
}
2019
}
Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
<h2 class="comcol-browse-label h5">{{'browse.comcol.head' | translate}}</h2>
2-
<nav class="comcol-browse mb-4" aria-label="Browse Community or Collection">
3-
<div class="d-none d-sm-block">
1+
<ng-container *ngIf="(allOptions$ | async) as options">
2+
<ng-container *ngIf="options.length > 1">
3+
<h2 class="comcol-browse-label h5">{{'browse.comcol.head' | translate}}</h2>
4+
<nav class="comcol-browse mb-4" aria-label="Browse Community or Collection">
5+
<div class="d-none d-sm-block">
46

5-
<div class="list-group list-group-horizontal" role="tablist">
6-
<a *ngFor="let option of allOptions"
7-
[attr.aria-current]="(currentOptionId$ | async) === option.id"
8-
class="list-group-item"
9-
role="tab"
10-
[routerLink]="option.routerLink"
11-
[queryParams]="option.params"
12-
[class.active]="(currentOptionId$ | async) === option.id">{{ option.label | translate }}</a>
13-
</div>
14-
</div>
7+
<div class="list-group list-group-horizontal" role="tablist">
8+
<a *ngFor="let option of allOptions"
9+
[attr.aria-current]="(currentOptionId$ | async) === option.id"
10+
class="list-group-item"
11+
role="tab"
12+
[routerLink]="option.routerLink"
13+
[queryParams]="option.params"
14+
[class.active]="(currentOptionId$ | async) === option.id">{{ option.label | translate }}</a>
15+
</div>
16+
</div>
1517

16-
<div class="d-block d-sm-none">
17-
<select name="browse-type"
18-
class="form-control"
19-
aria-label="Browse Community or Collection"
20-
(ngModelChange)="onSelectChange($event)" [ngModel]="currentOptionId$ | async">
21-
<option *ngFor="let option of allOptions"
22-
[ngValue]="option.id"
23-
[attr.selected]="(currentOptionId$ | async) === option.id ? 'selected' : null">{{ option.label | translate }}</option>
24-
</select>
25-
</div>
26-
</nav>
18+
<div class="d-block d-sm-none">
19+
<select name="browse-type"
20+
class="form-control"
21+
aria-label="Browse Community or Collection"
22+
(ngModelChange)="onSelectChange($event)" [ngModel]="currentOptionId$ | async">
23+
<option *ngFor="let option of allOptions"
24+
[ngValue]="option.id"
25+
[attr.selected]="(currentOptionId$ | async) === option.id ? 'selected' : null">{{ option.label | translate }}</option>
26+
</select>
27+
</div>
28+
</nav>
29+
</ng-container>
30+
</ng-container>
Lines changed: 78 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import { Component, Input, OnInit } from '@angular/core';
2-
import { Observable } from 'rxjs';
3-
import { map } from 'rxjs/operators';
42
import { ActivatedRoute, Params, Router } from '@angular/router';
3+
4+
import { Observable, of as obeservableOf } from 'rxjs';
5+
import { map, switchMap } from 'rxjs/operators';
6+
57
import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths';
68
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
7-
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
8-
import { PaginatedList } from '../../../core/data/paginated-list.model';
9-
import { BrowseDefinition } from '../../../core/shared/browse-definition.model';
9+
import { CollectionDataService } from '../../../core/data/collection-data.service';
10+
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
1011
import { RemoteData } from '../../../core/data/remote-data';
11-
import { BrowseService } from '../../../core/browse/browse.service';
12+
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
13+
import {
14+
getFinishedRemoteData,
15+
getFirstSucceededRemoteDataPayload,
16+
getRemoteDataPayload
17+
} from '../../../core/shared/operators';
1218

1319
export interface ComColPageNavOption {
1420
id: string;
@@ -31,47 +37,43 @@ export class ComcolPageBrowseByComponent implements OnInit {
3137
* The ID of the Community or Collection
3238
*/
3339
@Input() id: string;
40+
3441
@Input() contentType: string;
3542

3643
allOptions: ComColPageNavOption[];
3744

45+
allOptions$: Observable<ComColPageNavOption[]>;
46+
3847
currentOptionId$: Observable<string>;
3948

4049
constructor(
4150
private route: ActivatedRoute,
4251
private router: Router,
43-
private browseService: BrowseService
44-
) {
52+
private configurationService: ConfigurationDataService,
53+
private collectionService: CollectionDataService) {
4554
}
4655

4756
ngOnInit(): void {
48-
this.browseService.getBrowseDefinitions()
49-
.pipe(getFirstCompletedRemoteData<PaginatedList<BrowseDefinition>>())
50-
.subscribe((browseDefListRD: RemoteData<PaginatedList<BrowseDefinition>>) => {
51-
if (browseDefListRD.hasSucceeded) {
52-
this.allOptions = browseDefListRD.payload.page
53-
.map((config: BrowseDefinition) => ({
54-
id: config.id,
55-
label: `browse.comcol.by.${config.id}`,
56-
routerLink: `/browse/${config.id}`,
57-
params: { scope: this.id }
58-
}));
59-
60-
if (this.contentType === 'collection') {
61-
this.allOptions = [{
62-
id: this.id,
63-
label: 'collection.page.browse.recent.head',
64-
routerLink: getCollectionPageRoute(this.id)
65-
}, ...this.allOptions];
66-
} else if (this.contentType === 'community') {
67-
this.allOptions = [{
68-
id: this.id,
69-
label: 'community.all-lists.head',
70-
routerLink: getCommunityPageRoute(this.id)
71-
}, ...this.allOptions];
72-
}
57+
this.allOptions$ = this.calculateBrowseProperty().pipe(
58+
switchMap ( (browseProperty) => this.configurationService.findByPropertyName( browseProperty) ),
59+
getFinishedRemoteData(),
60+
switchMap( (remoteData) => this.searchForBaseBrowseCollectionPropertyIfDataNotFound(remoteData)),
61+
getFinishedRemoteData(),
62+
getRemoteDataPayload(),
63+
map ( (configProperty) => {
64+
let options = [this.getFirstOptionByContentType()];
65+
if (configProperty) {
66+
options = [...options, ...configProperty.values.map((configValue: string) => ({
67+
id: configValue,
68+
label: `browse.comcol.by.${configValue}`,
69+
routerLink: `/browse/${configValue}`,
70+
params: { scope: this.id }
71+
}))];
7372
}
74-
});
73+
this.allOptions = options;
74+
return options;
75+
})
76+
);
7577

7678
this.currentOptionId$ = this.route.params.pipe(
7779
map((params: Params) => params.id)
@@ -84,4 +86,46 @@ export class ComcolPageBrowseByComponent implements OnInit {
8486

8587
this.router.navigate([selectedOption.routerLink], { queryParams: selectedOption.params });
8688
}
89+
90+
calculateBrowseProperty(): Observable<string> {
91+
if ( this.contentType === 'collection' ) {
92+
return this.collectionService.findById(this.id).pipe(
93+
getFirstSucceededRemoteDataPayload(),
94+
map( (collection) => collection.firstMetadataValue('dspace.entity.type') ),
95+
map ( (entityType) => entityType ? 'browse.collection.' + entityType : 'browse.collection' )
96+
);
97+
}
98+
return obeservableOf('browse.' + this.contentType);
99+
}
100+
101+
/**
102+
* Search for the base browse.collection property if the current content type is
103+
* a collection and no remoteData was found.
104+
* @param remoteData the remote data coming from the previous search
105+
*/
106+
searchForBaseBrowseCollectionPropertyIfDataNotFound(remoteData: RemoteData<ConfigurationProperty>): Observable<RemoteData<ConfigurationProperty>> {
107+
if (remoteData.hasFailed && remoteData.statusCode === 404 && this.contentType === 'collection') {
108+
return this.configurationService.findByPropertyName('browse.collection')
109+
.pipe(getFinishedRemoteData());
110+
} else {
111+
return obeservableOf(remoteData);
112+
}
113+
}
114+
115+
getFirstOptionByContentType(): ComColPageNavOption {
116+
if (this.contentType === 'collection') {
117+
return {
118+
id: this.id,
119+
label: 'collection.page.browse.recent.head',
120+
routerLink: getCollectionPageRoute(this.id)
121+
};
122+
} else if (this.contentType === 'community') {
123+
return {
124+
id: this.id,
125+
label: 'community.all-lists.head',
126+
routerLink: getCommunityPageRoute(this.id)
127+
};
128+
}
129+
return null;
130+
}
87131
}

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
219219
*/
220220
onChange(event: Event) {
221221
if (!this.previousValue && !isEmpty(this.currentValue)) {
222-
if (this.model.securityConfigLevel && this.model.securityConfigLevel.length > 0) {
222+
if (this.model.securityConfigLevel && this.model.securityConfigLevel?.length > 0) {
223223
this.model.securityLevel = this.model.securityConfigLevel[this.model.securityConfigLevel.length - 1];
224224
}
225225
}

src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/modal/dynamic-relation-group-modal.components.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
319319
}
320320

321321
private initSecurityLevelConfig(chipModel: DynamicInputModel, modelGroup: DynamicFormGroupModel) {
322-
if (this.model.name === chipModel.name && this.model.securityConfigLevel.length > 1) {
322+
if (this.model.name === chipModel.name && this.model.securityConfigLevel?.length > 1) {
323323
(chipModel as any).securityConfigLevel = this.model.securityConfigLevel;
324324
(chipModel as any).toggleSecurityVisibility = true;
325325

@@ -336,7 +336,7 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
336336
}
337337
});
338338
}
339-
if (this.model.securityConfigLevel.length === 1) {
339+
if (this.model.securityConfigLevel?.length === 1) {
340340
modelGroup.group.forEach((item: any) => {
341341
item.securityConfigLevel = this.model.securityConfigLevel;
342342
item.toggleSecurityVisibility = false;

src/app/submission/submission.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ export class SubmissionService {
717717
* observable of RemoteData<SubmissionObject>
718718
*/
719719
retrieveSubmission(submissionId, projections: string[] = []): Observable<RemoteData<SubmissionObject>> {
720-
return this.restService.getDataById(this.getSubmissionObjectLinkName(), submissionId).pipe(
720+
return this.restService.getDataById(this.getSubmissionObjectLinkName(), submissionId, projections).pipe(
721721
find((submissionObjects: SubmissionObject[]) => isNotUndefined(submissionObjects)),
722722
map((submissionObjects: SubmissionObject[]) => createSuccessfulRemoteDataObject(
723723
submissionObjects[0])),

0 commit comments

Comments
 (0)