-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'alex/w2p-112970_added-missing-breadcrum…
…bs_contribute-7.4' into dspace-7_x # Conflicts: # src/app/collection-page/collection-page-routing.module.ts # src/app/community-page/community-page-routing.module.ts # src/app/core/core.module.ts # src/app/workflowitems-edit-page/workflowitems-edit-page-routing.module.ts # src/app/workspaceitems-edit-page/workspaceitems-edit-page-routing.module.ts # src/assets/i18n/en.json5
- Loading branch information
Showing
20 changed files
with
306 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/app/core/submission/resolver/submission-links-to-follow.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { followLink, FollowLinkConfig } from '../../../shared/utils/follow-link-config.model'; | ||
import { WorkflowItem } from '../models/workflowitem.model'; | ||
import { WorkspaceItem } from '../models/workspaceitem.model'; | ||
|
||
/** | ||
* The self links defined in this list are expected to be requested somewhere in the near future | ||
* Requesting them as embeds will limit the number of requests | ||
* | ||
* Needs to be in a separate file to prevent circular dependencies in webpack. | ||
*/ | ||
export const SUBMISSION_LINKS_TO_FOLLOW: FollowLinkConfig<WorkflowItem | WorkspaceItem>[] = [ | ||
followLink('item'), | ||
followLink('collection'), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/app/core/submission/resolver/submission-parent-breadcrumb.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../../shared/operators'; | ||
import { IdentifiableDataService } from '../../data/base/identifiable-data.service'; | ||
import { BreadcrumbConfig } from '../../../breadcrumbs/breadcrumb/breadcrumb-config.model'; | ||
import { SubmissionParentBreadcrumbsService } from '../submission-parent-breadcrumb.service'; | ||
import { SUBMISSION_LINKS_TO_FOLLOW } from './submission-links-to-follow'; | ||
import { SubmissionObject } from '../models/submission-object.model'; | ||
|
||
/** | ||
* This class represents a resolver that requests a specific item before the route is activated | ||
*/ | ||
export abstract class SubmissionParentBreadcrumbResolver implements Resolve<BreadcrumbConfig<SubmissionObject>> { | ||
|
||
protected constructor( | ||
protected dataService: IdentifiableDataService<any>, | ||
protected breadcrumbService: SubmissionParentBreadcrumbsService, | ||
) { | ||
} | ||
|
||
/** | ||
* Method for resolving an item based on the parameters in the current route | ||
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot | ||
* @param {RouterStateSnapshot} state The current RouterStateSnapshot | ||
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route, | ||
* or an error if something went wrong | ||
*/ | ||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<SubmissionObject>> { | ||
return this.dataService.findById(route.params.id, | ||
true, | ||
false, | ||
...SUBMISSION_LINKS_TO_FOLLOW, | ||
).pipe( | ||
getFirstCompletedRemoteData(), | ||
getRemoteDataPayload(), | ||
map((submissionObject: SubmissionObject) => ({ | ||
provider: this.breadcrumbService, | ||
key: submissionObject, | ||
} as BreadcrumbConfig<SubmissionObject>)), | ||
); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/app/core/submission/submission-parent-breadcrumb.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { BreadcrumbsProviderService } from '../breadcrumbs/breadcrumbsProviderService'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, switchMap, combineLatest, of as observableOf } from 'rxjs'; | ||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; | ||
import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../shared/operators'; | ||
import { Collection } from '../shared/collection.model'; | ||
import { DSONameService } from '../breadcrumbs/dso-name.service'; | ||
import { SubmissionObject } from './models/submission-object.model'; | ||
import { RemoteData } from '../data/remote-data'; | ||
import { DSOBreadcrumbsService } from '../breadcrumbs/dso-breadcrumbs.service'; | ||
import { getDSORoute } from '../../app-routing-paths'; | ||
import { SubmissionService } from '../../submission/submission.service'; | ||
import { CollectionDataService } from '../data/collection-data.service'; | ||
import { hasValue } from '../../shared/empty.util'; | ||
|
||
/** | ||
* Service to calculate the parent {@link DSpaceObject} breadcrumbs for a {@link SubmissionObject} | ||
*/ | ||
@Injectable() | ||
export class SubmissionParentBreadcrumbsService implements BreadcrumbsProviderService<SubmissionObject> { | ||
|
||
constructor( | ||
protected dsoNameService: DSONameService, | ||
protected dsoBreadcrumbsService: DSOBreadcrumbsService, | ||
protected submissionService: SubmissionService, | ||
protected collectionService: CollectionDataService, | ||
) { | ||
} | ||
|
||
/** | ||
* Creates the parent breadcrumb structure for {@link SubmissionObject}s. It also automatically recreates the | ||
* parent breadcrumb structure when you change a {@link SubmissionObject}'s by dispatching a | ||
* {@link ChangeSubmissionCollectionAction}. | ||
* | ||
* @param submissionObject The {@link SubmissionObject} for which the parent breadcrumb structure needs to be created | ||
*/ | ||
getBreadcrumbs(submissionObject: SubmissionObject): Observable<Breadcrumb[]> { | ||
return combineLatest([ | ||
(submissionObject.collection as Observable<RemoteData<Collection>>).pipe( | ||
getFirstCompletedRemoteData(), | ||
getRemoteDataPayload(), | ||
), | ||
this.submissionService.getSubmissionCollectionId(submissionObject.id), | ||
]).pipe( | ||
switchMap(([collection, latestCollectionId]: [Collection, string]) => { | ||
if (hasValue(latestCollectionId)) { | ||
return this.collectionService.findById(latestCollectionId).pipe( | ||
getFirstCompletedRemoteData(), | ||
getRemoteDataPayload(), | ||
); | ||
} else { | ||
return observableOf(collection); | ||
} | ||
}), | ||
switchMap((collection: Collection) => this.dsoBreadcrumbsService.getBreadcrumbs(collection, getDSORoute(collection))), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.