55946: Finished edit-item-page and start of collection mapper

This commit is contained in:
Kristof De Langhe
2018-10-09 11:51:52 +02:00
parent ec96962a87
commit 05a4918ef0
15 changed files with 201 additions and 48 deletions

View File

@@ -1,12 +1,9 @@
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ItemDataService } from '../../core/data/item-data.service';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { RemoteData } from '../../core/data/remote-data';
import { Item } from '../../core/shared/item.model';
import { getSucceededRemoteData } from '../../core/shared/operators';
import { map } from 'rxjs/operators';
@Component({
selector: 'ds-edit-item-page',
@@ -23,33 +20,16 @@ import { map } from 'rxjs/operators';
*/
export class EditItemPageComponent implements OnInit {
objectKeys = Object.keys;
/**
* The item to edit
*/
itemRD$: Observable<RemoteData<Item>>;
statusData$: Observable<any>;
constructor(private route: ActivatedRoute,
private router: Router) {
constructor(private route: ActivatedRoute) {
}
ngOnInit(): void {
this.itemRD$ = this.route.data.map((data) => data.item);
this.statusData$ = this.itemRD$.pipe(
getSucceededRemoteData(),
map((itemRD: RemoteData<Item>) => itemRD.payload),
map((item: Item) => Object.assign({
id: item.id,
handle: item.handle,
lastModified: item.lastModified
}))
)
}
getItemPage(): string {
return this.router.url.substr(0, this.router.url.lastIndexOf('/'));
}
}