mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
59695: Arrow-navigation enabled by default + support for entries
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
[sortConfig]="sortConfig"
|
||||
[type]="startsWithType"
|
||||
[startsWithOptions]="startsWithOptions"
|
||||
[enableArrows]="startsWith"
|
||||
[enableArrows]="true"
|
||||
(prev)="goPrev()"
|
||||
(next)="goNext()"
|
||||
(pageSizeChange)="pageSizeChange($event)"
|
||||
|
@@ -168,18 +168,30 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
||||
* Navigate to the previous page
|
||||
*/
|
||||
goPrev() {
|
||||
this.items$.pipe(take(1)).subscribe((items) => {
|
||||
this.items$ = this.browseService.getPrevBrowseItems(items);
|
||||
});
|
||||
if (this.items$) {
|
||||
this.items$.pipe(take(1)).subscribe((items) => {
|
||||
this.items$ = this.browseService.getPrevBrowseItems(items);
|
||||
});
|
||||
} else if (this.browseEntries$) {
|
||||
this.browseEntries$.pipe(take(1)).subscribe((entries) => {
|
||||
this.browseEntries$ = this.browseService.getPrevBrowseEntries(entries);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the next page
|
||||
*/
|
||||
goNext() {
|
||||
this.items$.pipe(take(1)).subscribe((items) => {
|
||||
this.items$ = this.browseService.getNextBrowseItems(items);
|
||||
});
|
||||
if (this.items$) {
|
||||
this.items$.pipe(take(1)).subscribe((items) => {
|
||||
this.items$ = this.browseService.getNextBrowseItems(items);
|
||||
});
|
||||
} else if (this.browseEntries$) {
|
||||
this.browseEntries$.pipe(take(1)).subscribe((entries) => {
|
||||
this.browseEntries$ = this.browseService.getNextBrowseEntries(entries);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -41,8 +41,8 @@ describe('BrowseByTitlePageComponent', () => {
|
||||
})
|
||||
];
|
||||
|
||||
const mockItemDataService = {
|
||||
findAll: () => toRemoteData(mockItems)
|
||||
const mockBrowseService = {
|
||||
getBrowseItemsFor: () => toRemoteData(mockItems)
|
||||
};
|
||||
|
||||
const mockDsoService = {
|
||||
@@ -59,10 +59,9 @@ describe('BrowseByTitlePageComponent', () => {
|
||||
declarations: [BrowseByTitlePageComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: BrowseService, useValue: {} },
|
||||
{ provide: BrowseService, useValue: mockBrowseService },
|
||||
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
|
||||
{ provide: Router, useValue: new MockRouter() },
|
||||
{ provide: ItemDataService, useValue: mockItemDataService }
|
||||
{ provide: Router, useValue: new MockRouter() }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
@@ -25,8 +25,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
||||
public constructor(protected route: ActivatedRoute,
|
||||
protected browseService: BrowseService,
|
||||
protected dsoService: DSpaceObjectDataService,
|
||||
protected router: Router,
|
||||
protected itemDataService: ItemDataService) {
|
||||
protected router: Router) {
|
||||
super(route, browseService, dsoService, router);
|
||||
}
|
||||
|
||||
@@ -43,27 +42,12 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
||||
})
|
||||
.subscribe((params) => {
|
||||
this.metadata = params.metadata || this.defaultMetadata;
|
||||
this.updatePage(browseParamsToOptions(params, this.paginationConfig, this.sortConfig));
|
||||
this.updatePageWithItems(browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.metadata), undefined);
|
||||
this.updateParent(params.scope)
|
||||
}));
|
||||
this.startsWithOptions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current page with searchOptions
|
||||
* @param searchOptions Options to narrow down your search:
|
||||
* { pagination: PaginationComponentOptions,
|
||||
* sort: SortOptions }
|
||||
*/
|
||||
updatePage(searchOptions: BrowseEntrySearchOptions) {
|
||||
this.items$ = this.itemDataService.findAll({
|
||||
currentPage: searchOptions.pagination.currentPage,
|
||||
elementsPerPage: searchOptions.pagination.pageSize,
|
||||
sort: searchOptions.sort,
|
||||
scopeID: searchOptions.scope
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ export class BrowseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous page using the paginated list's prev link
|
||||
* Get the previous page of items using the paginated list's prev link
|
||||
* @param items
|
||||
*/
|
||||
getPrevBrowseItems(items: RemoteData<PaginatedList<Item>>): Observable<RemoteData<PaginatedList<Item>>> {
|
||||
@@ -204,7 +204,7 @@ export class BrowseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next page using the paginated list's next link
|
||||
* Get the next page of items using the paginated list's next link
|
||||
* @param items
|
||||
*/
|
||||
getNextBrowseItems(items: RemoteData<PaginatedList<Item>>): Observable<RemoteData<PaginatedList<Item>>> {
|
||||
@@ -213,6 +213,26 @@ export class BrowseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous page of browse-entries using the paginated list's prev link
|
||||
* @param entries
|
||||
*/
|
||||
getPrevBrowseEntries(entries: RemoteData<PaginatedList<BrowseEntry>>): Observable<RemoteData<PaginatedList<BrowseEntry>>> {
|
||||
return observableOf(entries.payload.prev).pipe(
|
||||
getBrowseEntriesFor(this.requestService, this.responseCache, this.rdb)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next page of browse-entries using the paginated list's next link
|
||||
* @param entries
|
||||
*/
|
||||
getNextBrowseEntries(entries: RemoteData<PaginatedList<BrowseEntry>>): Observable<RemoteData<PaginatedList<BrowseEntry>>> {
|
||||
return observableOf(entries.payload.next).pipe(
|
||||
getBrowseEntriesFor(this.requestService, this.responseCache, this.rdb)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the browse URL by providing a metadatum key and linkPath
|
||||
* @param metadatumKey
|
||||
|
Reference in New Issue
Block a user