Skip to content
Snippets Groups Projects
Commit de2499b1 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

55558: Small conflict fixes - intermediate

parent addea8bf
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CollectionDataService } from '../core/data/collection-data.service';
import { ItemDataService } from '../core/data/item-data.service';
import { PaginatedList } from '../core/data/paginated-list';
import { RemoteData } from '../core/data/remote-data';
......@@ -44,7 +45,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
constructor(
private collectionDataService: CollectionDataService,
private searchService: SearchService,
private itemDataService: ItemDataService,
private metadata: MetadataService,
private route: ActivatedRoute
) {
......@@ -52,7 +53,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
this.paginationConfig.id = 'collection-page-pagination';
this.paginationConfig.pageSize = 5;
this.paginationConfig.currentPage = 1;
this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
}
ngOnInit(): void {
......@@ -67,26 +68,30 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
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: this.sortConfig
sort: sort
});
}));
}
updatePage(searchOptions) {
this.itemRD$ = this.searchService.search(
new PaginatedSearchOptions({
scope: this.collectionId,
pagination: searchOptions.pagination,
sort: searchOptions.sort,
dsoType: DSpaceObjectType.ITEM
})).pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
this.itemRD$ = this.itemDataService.findAll({
scopeID: this.collectionId,
currentPage: searchOptions.pagination.currentPage,
elementsPerPage: searchOptions.pagination.pageSize,
sort: searchOptions.sort
});
}
ngOnDestroy(): void {
......
<div class="container" *ngVar="(itemRD$ | async) as itemRD">
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
<div *ngIf="itemRD?.payload as entity">
<div *ngIf="itemRD?.payload as item">
<ds-item-page-title-field [item]="item"></ds-item-page-title-field>
<div class="simple-view-link my-3">
<a class="btn btn-outline-primary" [routerLink]="['/items/' + item.id]">
......
......@@ -42,6 +42,10 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit {
/*** AoT inheritance fix, will hopefully be resolved in the near future **/
ngOnInit(): void {
super.ngOnInit();
}
initialize(params) {
super.initialize(params);
this.metadata$ = this.itemRD$
.map((rd: RemoteData<Item>) => rd.payload)
.filter((item: Item) => hasValue(item))
......
......@@ -37,24 +37,28 @@ export class PublicationPageFieldsComponent extends EntityPageFieldsComponent im
ngOnInit(): void {
super.ngOnInit();
this.authors$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isAuthorOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.projects$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isProjectOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.orgUnits$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isOrgUnitOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.journalIssues$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isJournalIssueOfPublication'),
relationsToItems(this.item.id, this.ids)
);
if (this.resolvedRelsAndTypes$) {
this.authors$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isAuthorOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.projects$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isProjectOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.orgUnits$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isOrgUnitOfPublication'),
relationsToItems(this.item.id, this.ids)
);
this.journalIssues$ = this.resolvedRelsAndTypes$.pipe(
filterRelationsByTypeLabel('isJournalIssueOfPublication'),
relationsToItems(this.item.id, this.ids)
);
}
}
}
......@@ -73,28 +73,31 @@ export class EntityPageFieldsComponent implements OnInit {
) {}
ngOnInit(): void {
const relsCurrentPage$ = this.item.relationships.pipe(
filter((rd: RemoteData<PaginatedList<Relationship>>) => rd.hasSucceeded),
getRemoteDataPayload(),
map((pl: PaginatedList<Relationship>) => pl.page),
distinctUntilChanged(compareArraysUsingIds())
);
const relationships$ = this.item.relationships;
if (relationships$) {
const relsCurrentPage$ = relationships$.pipe(
filter((rd: RemoteData<PaginatedList<Relationship>>) => rd.hasSucceeded),
getRemoteDataPayload(),
map((pl: PaginatedList<Relationship>) => pl.page),
distinctUntilChanged(compareArraysUsingIds())
);
const relTypesCurrentPage$ = relsCurrentPage$.pipe(
flatMap((rels: Relationship[]) =>
Observable.zip(
...rels.map((rel: Relationship) => rel.relationshipType),
(...arr: Array<RemoteData<RelationshipType>>) =>
arr.map((d: RemoteData<RelationshipType>) => d.payload)
)
),
distinctUntilChanged(compareArraysUsingIds())
);
const relTypesCurrentPage$ = relsCurrentPage$.pipe(
flatMap((rels: Relationship[]) =>
Observable.zip(
...rels.map((rel: Relationship) => rel.relationshipType),
(...arr: Array<RemoteData<RelationshipType>>) =>
arr.map((d: RemoteData<RelationshipType>) => d.payload)
)
),
distinctUntilChanged(compareArraysUsingIds())
);
this.resolvedRelsAndTypes$ = Observable.combineLatest(
relsCurrentPage$,
relTypesCurrentPage$
);
this.resolvedRelsAndTypes$ = Observable.combineLatest(
relsCurrentPage$,
relTypesCurrentPage$
);
}
}
}
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
......@@ -12,6 +12,9 @@ import { MetadataService } from '../../core/metadata/metadata.service';
import { fadeInOut } from '../../shared/animations/fade';
import { hasValue } from '../../shared/empty.util';
import * as viewMode from '../../shared/view-mode';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subscription } from 'rxjs/Subscription';
/**
* This component renders a simple item page.
......@@ -35,6 +38,8 @@ export class ItemPageComponent implements OnInit {
thumbnail$: Observable<Bitstream>;
ElementViewMode = viewMode.ElementViewMode;
constructor(
private route: ActivatedRoute,
private items: ItemDataService,
......@@ -42,6 +47,13 @@ export class ItemPageComponent implements OnInit {
) { }
ngOnInit(): void {
this.sub = this.route.params.subscribe((params) => {
this.initialize(params);
});
}
initialize(params) {
this.itemRD$ = this.route.data.map((data) => data.item);
this.metadataService.processRemoteData(this.itemRD$);
this.thumbnail$ = this.itemRD$
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment