forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DSpace#2888 from alexandrevryghem/w2p-112970_added…
…-missing-breadcrumbs_contribute-main Added missing/incomplete breadcrumbs on create community/collection/item pages
- Loading branch information
Showing
15 changed files
with
324 additions
and
22 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
17 changes: 17 additions & 0 deletions
17
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,17 @@ | ||
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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
import { | ||
ActivatedRouteSnapshot, | ||
Resolve, | ||
RouterStateSnapshot, | ||
} from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
import { BreadcrumbConfig } from '../../../breadcrumbs/breadcrumb/breadcrumb-config.model'; | ||
import { IdentifiableDataService } from '../../data/base/identifiable-data.service'; | ||
import { | ||
getFirstCompletedRemoteData, | ||
getRemoteDataPayload, | ||
} from '../../shared/operators'; | ||
import { SubmissionObject } from '../models/submission-object.model'; | ||
import { SubmissionParentBreadcrumbsService } from '../submission-parent-breadcrumb.service'; | ||
import { SUBMISSION_LINKS_TO_FOLLOW } from './submission-links-to-follow'; | ||
|
||
/** | ||
* 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>)), | ||
); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
combineLatest, | ||
Observable, | ||
of as observableOf, | ||
switchMap, | ||
} from 'rxjs'; | ||
|
||
import { getDSORoute } from '../../app-routing-paths'; | ||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; | ||
import { hasValue } from '../../shared/empty.util'; | ||
import { SubmissionService } from '../../submission/submission.service'; | ||
import { BreadcrumbsProviderService } from '../breadcrumbs/breadcrumbsProviderService'; | ||
import { DSOBreadcrumbsService } from '../breadcrumbs/dso-breadcrumbs.service'; | ||
import { DSONameService } from '../breadcrumbs/dso-name.service'; | ||
import { CollectionDataService } from '../data/collection-data.service'; | ||
import { RemoteData } from '../data/remote-data'; | ||
import { Collection } from '../shared/collection.model'; | ||
import { | ||
getFirstCompletedRemoteData, | ||
getRemoteDataPayload, | ||
} from '../shared/operators'; | ||
import { SubmissionObject } from './models/submission-object.model'; | ||
|
||
/** | ||
* Service to calculate the parent {@link DSpaceObject} breadcrumbs for a {@link SubmissionObject} | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
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.