61142: Fixed AoT build errors

This commit is contained in:
Kristof De Langhe
2019-04-08 16:16:55 +02:00
parent bbbd6959a8
commit eeb2c790c1
3 changed files with 17 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, Injectable, OnInit } from '@angular/core';
import { FieldUpdate, FieldUpdates } from '../../../core/data/object-updates/object-updates.reducer'; import { FieldUpdate, FieldUpdates } from '../../../core/data/object-updates/object-updates.reducer';
import { Observable } from 'rxjs/internal/Observable'; import { Observable } from 'rxjs/internal/Observable';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
@@ -11,10 +11,7 @@ import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
import { first, map } from 'rxjs/operators'; import { first, map } from 'rxjs/operators';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
@Component({ @Injectable()
selector: 'ds-abstract-item-update',
template: ``,
})
/** /**
* Abstract component for managing object updates of an item * Abstract component for managing object updates of an item
*/ */
@@ -22,25 +19,25 @@ export abstract class AbstractItemUpdateComponent implements OnInit {
/** /**
* The item to display the edit page for * The item to display the edit page for
*/ */
protected item: Item; item: Item;
/** /**
* The current values and updates for all this item's fields * The current values and updates for all this item's fields
* Should be initialized in the initializeUpdates method of the child component * Should be initialized in the initializeUpdates method of the child component
*/ */
protected updates$: Observable<FieldUpdates>; updates$: Observable<FieldUpdates>;
/** /**
* The current url of this page * The current url of this page
*/ */
protected url: string; url: string;
/** /**
* Prefix for this component's notification translate keys * Prefix for this component's notification translate keys
* Should be initialized in the initializeNotificationsPrefix method of the child component * Should be initialized in the initializeNotificationsPrefix method of the child component
*/ */
protected notificationsPrefix; notificationsPrefix;
/** /**
* The time span for being able to undo discarding changes * The time span for being able to undo discarding changes
*/ */
protected discardTimeOut: number; discardTimeOut: number;
constructor( constructor(
protected itemService: ItemDataService, protected itemService: ItemDataService,

View File

@@ -1,4 +1,4 @@
import { Component, Inject, Input, OnInit } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { ItemDataService } from '../../../core/data/item-data.service'; import { ItemDataService } from '../../../core/data/item-data.service';
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service'; import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
@@ -60,7 +60,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
* Initialize the values and updates of the current item's metadata fields * Initialize the values and updates of the current item's metadata fields
*/ */
public initializeUpdates(): void { public initializeUpdates(): void {
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.item.metadataAsList); this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.getMetadataAsListExcludingRelationships());
} }
/** /**
@@ -82,7 +82,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
* Sends all initial values of this item to the object updates service * Sends all initial values of this item to the object updates service
*/ */
public initializeOriginalFields() { public initializeOriginalFields() {
this.objectUpdatesService.initialize(this.url, this.item.metadataAsList, this.item.lastModified); this.objectUpdatesService.initialize(this.url, this.getMetadataAsListExcludingRelationships(), this.item.lastModified);
} }
/** /**
@@ -92,7 +92,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
public submit() { public submit() {
this.isValid().pipe(first()).subscribe((isValid) => { this.isValid().pipe(first()).subscribe((isValid) => {
if (isValid) { if (isValid) {
const metadata$: Observable<Identifiable[]> = this.objectUpdatesService.getUpdatedFields(this.url, this.item.metadataAsList) as Observable<MetadatumViewModel[]>; const metadata$: Observable<Identifiable[]> = this.objectUpdatesService.getUpdatedFields(this.url, this.getMetadataAsListExcludingRelationships()) as Observable<MetadatumViewModel[]>;
metadata$.pipe( metadata$.pipe(
first(), first(),
switchMap((metadata: MetadatumViewModel[]) => { switchMap((metadata: MetadatumViewModel[]) => {
@@ -105,7 +105,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
(rd: RemoteData<Item>) => { (rd: RemoteData<Item>) => {
this.item = rd.payload; this.item = rd.payload;
this.initializeOriginalFields(); this.initializeOriginalFields();
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.item.metadataAsList); this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.getMetadataAsListExcludingRelationships());
this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved')); this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved'));
} }
) )
@@ -124,4 +124,8 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
take(1), take(1),
map((remoteData$) => remoteData$.payload.page.map((field: MetadataField) => field.toString()))); map((remoteData$) => remoteData$.payload.page.map((field: MetadataField) => field.toString())));
} }
getMetadataAsListExcludingRelationships(): MetadatumViewModel[] {
return this.item.metadataAsList.filter((metadata: MetadatumViewModel) => !metadata.key.startsWith('relation.') && !metadata.key.startsWith('relationship.'));
}
} }

View File

@@ -68,7 +68,7 @@ describe('RelationshipService', () => {
const relatedItems = [relatedItem1, relatedItem2]; const relatedItems = [relatedItem1, relatedItem2];
const itemService = jasmine.createSpyObj('itemService', { const itemService = jasmine.createSpyObj('itemService', {
findById: (uuid) => new RemoteData(false, false, true, undefined, relatedItems.filter((item) => item.id === uuid)[0]) findById: (uuid) => new RemoteData(false, false, true, undefined, relatedItems.filter((relatedItem) => relatedItem.id === uuid)[0])
}); });
function initTestService() { function initTestService() {