Skip to content

Commit

Permalink
Merge branch 'DSpace:dspace-7_x' into dspace-7_x
Browse files Browse the repository at this point in the history
  • Loading branch information
oscar-escire authored Apr 22, 2024
2 parents 7f905ab + 45ab723 commit 94f6bdd
Show file tree
Hide file tree
Showing 49 changed files with 427 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<ng-template ngbNavContent>
<ds-pagination
[paginationOptions]="(paginationOptions$ | async)"
[pageInfoState]="(objectsSelected$|async)?.payload.pageInfo"
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
[objects]="(objectsSelected$|async)"
[showPaginator]="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ <h2 id="search" class="border-bottom pb-2">
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(searching$ | async)"
[paginationOptions]="config"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ <h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
<ds-pagination
*ngIf="(groups | async)?.payload?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="(groups | async)?.payload"
[collectionSize]="(groups | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ <h3>{{messagePrefix + '.headMembers' | translate}}</h3>

<ds-pagination *ngIf="(ePeopleMembersOfGroup | async)?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="(ePeopleMembersOfGroup | async)"
[collectionSize]="(ePeopleMembersOfGroup | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down Expand Up @@ -86,7 +85,6 @@ <h3 id="search" class="border-bottom pb-2">

<ds-pagination *ngIf="(ePeopleSearch | async)?.totalElements > 0"
[paginationOptions]="configSearch"
[pageInfoState]="(ePeopleSearch | async)"
[collectionSize]="(ePeopleSearch | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ <h4>{{messagePrefix + '.headSubgroups' | translate}}</h4>

<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="(subGroups$ | async)?.payload"
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down Expand Up @@ -84,7 +83,6 @@ <h4 id="search" class="border-bottom pb-2">

<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
[paginationOptions]="configSearch"
[pageInfoState]="(searchResults$ | async)?.payload"
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ <h2 id="search" class="border-bottom pb-2">{{messagePrefix + 'search.head' | tra
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(loading$ | async)"
[paginationOptions]="config"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ <h1 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats
<ds-pagination
*ngIf="(bitstreamFormats | async)?.payload?.totalElements > 0"
[paginationOptions]="pageConfig"
[pageInfoState]="(bitstreamFormats | async)?.payload"
[collectionSize]="(bitstreamFormats | async)?.payload?.totalElements"
[hideGear]="false"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ <h2>{{'admin.registries.schema.fields.head' | translate}}</h2>
<ds-pagination
*ngIf="fields?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="fields"
[collectionSize]="fields?.totalElements"
[hideGear]="false"
[hidePagerWhenSinglePage]="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export class CollectionItemMapperComponent implements OnInit {
this.shouldUpdate$.next(false);
}
return this.itemDataService.findListByHref(collectionRD.payload._links.mappedItems.href, Object.assign(options, {
sort: this.defaultSortOptions
currentPage: options.pagination.currentPage,
elementsPerPage: options.pagination.pageSize,
sort: this.defaultSortOptions,
}),!shouldUpdate, false, followLink('owningCollection')).pipe(
getAllSucceededRemoteData()
);
Expand Down
24 changes: 22 additions & 2 deletions src/app/collection-page/collection-page-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,33 @@ import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
import { CommunityBreadcrumbResolver } from '../core/breadcrumbs/community-breadcrumb.resolver';

@NgModule({
imports: [
RouterModule.forChild([
{
path: COLLECTION_CREATE_PATH,
component: CreateCollectionPageComponent,
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard]
children: [
{
path: '',
component: CreateCollectionPageComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver,
},
data: {
breadcrumbKey: 'collection.create',
},
},
],
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard],
data: {
breadcrumbQueryParam: 'parent',
},
resolve: {
breadcrumb: CommunityBreadcrumbResolver,
},
runGuardsAndResolvers: 'always',
},
{
path: ':id',
Expand Down Expand Up @@ -94,6 +113,7 @@ import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
LinkService,
CreateCollectionPageGuard,
CollectionPageAdministratorGuard,
CommunityBreadcrumbResolver,
]
})
export class CollectionPageRoutingModule {
Expand Down
23 changes: 21 additions & 2 deletions src/app/community-page/community-page-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,33 @@ import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { ThemedCommunityPageComponent } from './themed-community-page.component';
import { MenuItemType } from '../shared/menu/menu-item-type.model';
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';

@NgModule({
imports: [
RouterModule.forChild([
{
path: COMMUNITY_CREATE_PATH,
component: CreateCommunityPageComponent,
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard]
children: [
{
path: '',
component: CreateCommunityPageComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver,
},
data: {
breadcrumbKey: 'community.create',
},
}
],
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard],
data: {
breadcrumbQueryParam: 'parent',
},
resolve: {
breadcrumb: CommunityBreadcrumbResolver,
},
runGuardsAndResolvers: 'always',
},
{
path: ':id',
Expand Down
21 changes: 21 additions & 0 deletions src/app/core/breadcrumbs/community-breadcrumb.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { CommunityDataService } from '../data/community-data.service';
import { Community } from '../shared/community.model';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { COMMUNITY_PAGE_LINKS_TO_FOLLOW } from '../../community-page/community-page.resolver';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model';
import { hasValue } from '../../shared/empty.util';

/**
* The class that resolves the BreadcrumbConfig object for a Community
Expand All @@ -17,6 +21,23 @@ export class CommunityBreadcrumbResolver extends DSOBreadcrumbResolver<Community
super(breadcrumbService, dataService);
}

/**
* Method to retrieve the breadcrumb config by the route id. It is also possible to retrieve the id through the
* query parameters. This is done by defining the name of the query parameter in the data section under the property
* breadcrumbQueryParam.
*
* @param route The current {@link ActivatedRouteSnapshot}
* @param state The current {@link RouterStateSnapshot}
* @returns BreadcrumbConfig object
*/
override resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<Community>> {
if (hasValue(route.data.breadcrumbQueryParam) && hasValue(route.queryParams[route.data.breadcrumbQueryParam])) {
return this.resolveById(route.queryParams[route.data.breadcrumbQueryParam]);
} else {
return super.resolve(route, state);
}
}

/**
* Method that returns the follow links to already resolve
* The self links defined in this list are expected to be requested somewhere in the near future
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ describe('DSOBreadcrumbResolver', () => {
uuid = '1234-65487-12354-1235';
breadcrumbUrl = '/collections/' + uuid;
currentUrl = breadcrumbUrl + '/edit';
testCollection = Object.assign(new Collection(), { uuid });
testCollection = Object.assign(new Collection(), {
uuid: uuid,
type: 'collection',
});
dsoBreadcrumbService = {};
collectionService = {
findById: (id: string) => createSuccessfulRemoteDataObject$(testCollection)
Expand Down
16 changes: 12 additions & 4 deletions src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ChildHALResource } from '../shared/child-hal-resource.model';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { hasValue } from '../../shared/empty.util';
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
import { getDSORoute } from '../../app-routing-paths';

/**
* The class that resolves the BreadcrumbConfig object for a DSpaceObject
Expand All @@ -31,15 +32,22 @@ export abstract class DSOBreadcrumbResolver<T extends ChildHALResource & DSpaceO
* @returns BreadcrumbConfig object
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<T>> {
const uuid = route.params.id;
return this.resolveById(route.params.id);
}

/**
* Method for resolving a breadcrumb by id
*
* @param uuid The uuid to resolve
* @returns BreadcrumbConfig object
*/
resolveById(uuid: string): Observable<BreadcrumbConfig<T>> {
return this.dataService.findById(uuid, true, false, ...this.followLinks).pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
map((object: T) => {
if (hasValue(object)) {
const fullPath = state.url;
const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid;
return { provider: this.breadcrumbService, key: object, url: url };
return { provider: this.breadcrumbService, key: object, url: getDSORoute(object) };
} else {
return undefined;
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ import { FlatBrowseDefinition } from './shared/flat-browse-definition.model';
import { ValueListBrowseDefinition } from './shared/value-list-browse-definition.model';
import { NonHierarchicalBrowseDefinition } from './shared/non-hierarchical-browse-definition';
import { BulkAccessConditionOptions } from './config/models/bulk-access-condition-options.model';
import { SubmissionParentBreadcrumbsService } from './submission/submission-parent-breadcrumb.service';

/**
* When not in production, endpoint responses can be mocked for testing purposes
Expand Down Expand Up @@ -245,6 +246,7 @@ const PROVIDERS = [
NotificationsService,
WorkspaceitemDataService,
WorkflowItemDataService,
SubmissionParentBreadcrumbsService,
DSpaceObjectDataService,
ConfigurationDataService,
DSOChangeAnalyzer,
Expand Down
14 changes: 14 additions & 0 deletions src/app/core/submission/resolver/submission-links-to-follow.ts
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'),
];
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { switchMap } from 'rxjs/operators';
import { RemoteData } from '../../data/remote-data';
import { getFirstCompletedRemoteData } from '../../shared/operators';
import { IdentifiableDataService } from '../../data/base/identifiable-data.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
Expand All @@ -15,7 +14,6 @@ import { IdentifiableDataService } from '../../data/base/identifiable-data.servi
export class SubmissionObjectResolver<T> implements Resolve<RemoteData<T>> {
constructor(
protected dataService: IdentifiableDataService<any>,
protected store: Store<any>,
) {
}

Expand All @@ -30,7 +28,7 @@ export class SubmissionObjectResolver<T> implements Resolve<RemoteData<T>> {
const itemRD$ = this.dataService.findById(route.params.id,
true,
false,
followLink('item'),
...SUBMISSION_LINKS_TO_FOLLOW,
).pipe(
getFirstCompletedRemoteData(),
switchMap((wfiRD: RemoteData<any>) => wfiRD.payload.item as Observable<RemoteData<T>>),
Expand Down
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>)),
);
}
}
Loading

0 comments on commit 94f6bdd

Please sign in to comment.