+ *ngVar="(collectionRD$ | async) as collectionRD">
@@ -8,8 +8,8 @@
[name]="collection.name">
-
@@ -35,17 +35,17 @@
-
+
-
+
{{'collection.page.browse.recent.head' | translate}}
diff --git a/src/app/+collection-page/collection-page.component.ts b/src/app/+collection-page/collection-page.component.ts
index 2dee8e0cb4..ec94ed4404 100644
--- a/src/app/+collection-page/collection-page.component.ts
+++ b/src/app/+collection-page/collection-page.component.ts
@@ -18,6 +18,7 @@ import { Item } from '../core/shared/item.model';
import { fadeIn, fadeInOut } from '../shared/animations/fade';
import { hasValue, isNotEmpty } from '../shared/empty.util';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
+import { filter, flatMap, map } from 'rxjs/operators';
@Component({
selector: 'ds-collection-page',
@@ -30,9 +31,9 @@ import { PaginationComponentOptions } from '../shared/pagination/pagination-comp
]
})
export class CollectionPageComponent implements OnInit, OnDestroy {
- collectionRDObs: Observable>;
- itemRDObs: Observable>>;
- logoRDObs: Observable>;
+ collectionRD$: Observable>;
+ itemRD$: Observable>>;
+ logoRD$: Observable>;
paginationConfig: PaginationComponentOptions;
sortConfig: SortOptions;
private subs: Subscription[] = [];
@@ -44,55 +45,44 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
private metadata: MetadataService,
private route: ActivatedRoute
) {
- // this.route.snapshot.data.subscribe((c) => console.log(c));
this.paginationConfig = new PaginationComponentOptions();
this.paginationConfig.id = 'collection-page-pagination';
this.paginationConfig.pageSize = 5;
this.paginationConfig.currentPage = 1;
- this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
+ this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
}
ngOnInit(): void {
- this.route.data.subscribe((data) => {
- console.log('data.collection', data.collection.state, data.collection)
- })
+ this.collectionRD$ = this.route.data.map((data) => data.collection);
+ this.logoRD$ = this.collectionRD$.pipe(
+ map((rd: RemoteData) => rd.payload),
+ filter((collection: Collection) => hasValue(collection)),
+ flatMap((collection: Collection) => collection.logo)
+ );
this.subs.push(
- Observable.combineLatest(
- this.route.params,
- this.route.queryParams,
- (params, queryParams, ) => {
- return Object.assign({}, params, queryParams);
- })
- .subscribe((params) => {
- this.collectionId = params.id;
- this.collectionRDObs = this.collectionDataService.findById(this.collectionId);
- this.metadata.processRemoteData(this.collectionRDObs);
- this.subs.push(this.collectionRDObs
- .map((rd: RemoteData) => rd.payload)
- .filter((collection: Collection) => hasValue(collection))
- .subscribe((collection: Collection) => this.logoRDObs = collection.logo));
-
- const page = +params.page || this.paginationConfig.currentPage;
- const pageSize = +params.pageSize || this.paginationConfig.pageSize;
- const sortDirection = +params.page || this.sortConfig.direction;
- const pagination = Object.assign({},
- this.paginationConfig,
- { currentPage: page, pageSize: pageSize }
- );
- const sort = Object.assign({},
- this.sortConfig,
- { direction: sortDirection, field: params.sortField }
- );
- this.updatePage({
- pagination: pagination,
- sort: sort
- });
- }));
+ this.route.queryParams.subscribe((params) => {
+ this.metadata.processRemoteData(this.collectionRD$);
+ const page = +params.page || this.paginationConfig.currentPage;
+ const pageSize = +params.pageSize || this.paginationConfig.pageSize;
+ const sortDirection = +params.page || this.sortConfig.direction;
+ const pagination = Object.assign({},
+ this.paginationConfig,
+ { currentPage: page, pageSize: pageSize }
+ );
+ const sort = Object.assign({},
+ this.sortConfig,
+ { direction: sortDirection, field: params.sortField }
+ );
+ this.updatePage({
+ pagination: pagination,
+ sort: sort
+ });
+ }));
}
updatePage(searchOptions) {
- this.itemRDObs = this.itemDataService.findAll({
+ this.itemRD$ = this.itemDataService.findAll({
scopeID: this.collectionId,
currentPage: searchOptions.pagination.currentPage,
elementsPerPage: searchOptions.pagination.pageSize,
diff --git a/src/app/+collection-page/collection-page-resolver.service.ts b/src/app/+collection-page/collection-page.resolver.ts
similarity index 54%
rename from src/app/+collection-page/collection-page-resolver.service.ts
rename to src/app/+collection-page/collection-page.resolver.ts
index 76007da146..3204b8d5c3 100644
--- a/src/app/+collection-page/collection-page-resolver.service.ts
+++ b/src/app/+collection-page/collection-page.resolver.ts
@@ -1,20 +1,20 @@
import { Injectable } from '@angular/core';
-import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
+import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Collection } from '../core/shared/collection.model';
import { Observable } from 'rxjs/Observable';
import { CollectionDataService } from '../core/data/collection-data.service';
import { RemoteData } from '../core/data/remote-data';
-import { filter, first, takeUntil } from 'rxjs/operators';
+import { getSucceededRemoteData } from '../core/shared/operators';
@Injectable()
-export class CollectionPageResolverService implements Resolve> {
- constructor(private collectionService: CollectionDataService, private router: Router) {
+export class CollectionPageResolver implements Resolve> {
+ constructor(private collectionService: CollectionDataService) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable> {
+
return this.collectionService.findById(route.params.id).pipe(
- filter((rd: RemoteData) => rd.hasSucceeded),
- first()
+ getSucceededRemoteData()
);
}
}
diff --git a/src/app/+community-page/community-page-routing.module.ts b/src/app/+community-page/community-page-routing.module.ts
index 6fd5cc8cb5..4cc927d341 100644
--- a/src/app/+community-page/community-page-routing.module.ts
+++ b/src/app/+community-page/community-page-routing.module.ts
@@ -2,12 +2,23 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommunityPageComponent } from './community-page.component';
+import { CommunityPageResolver } from './community-page.resolver';
@NgModule({
imports: [
RouterModule.forChild([
- { path: ':id', component: CommunityPageComponent, pathMatch: 'full' }
+ {
+ path: ':id',
+ component: CommunityPageComponent,
+ pathMatch: 'full',
+ resolve: {
+ community: CommunityPageResolver
+ }
+ }
])
+ ],
+ providers: [
+ CommunityPageResolver,
]
})
export class CommunityPageRoutingModule {
diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html
index 976e1091e5..637e37af0c 100644
--- a/src/app/+community-page/community-page.component.html
+++ b/src/app/+community-page/community-page.component.html
@@ -1,11 +1,11 @@
-