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 { Observable } from 'rxjs/internal/Observable';
import { Item } from '../../../core/shared/item.model';
@@ -11,10 +11,7 @@ import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
import { first, map } from 'rxjs/operators';
import { RemoteData } from '../../../core/data/remote-data';
@Component({
selector: 'ds-abstract-item-update',
template: ``,
})
@Injectable()
/**
* 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
*/
protected item: Item;
item: Item;
/**
* The current values and updates for all this item's fields
* Should be initialized in the initializeUpdates method of the child component
*/
protected updates$: Observable<FieldUpdates>;
updates$: Observable<FieldUpdates>;
/**
* The current url of this page
*/
protected url: string;
url: string;
/**
* Prefix for this component's notification translate keys
* Should be initialized in the initializeNotificationsPrefix method of the child component
*/
protected notificationsPrefix;
notificationsPrefix;
/**
* The time span for being able to undo discarding changes
*/
protected discardTimeOut: number;
discardTimeOut: number;
constructor(
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 { ItemDataService } from '../../../core/data/item-data.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
*/
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
*/
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() {
this.isValid().pipe(first()).subscribe((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(
first(),
switchMap((metadata: MetadatumViewModel[]) => {
@@ -105,7 +105,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
(rd: RemoteData<Item>) => {
this.item = rd.payload;
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'));
}
)
@@ -124,4 +124,8 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
take(1),
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 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() {