Skip to content

Commit

Permalink
Fixed objectid replaced by string in exhibition
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed Feb 20, 2020
1 parent 03ff302 commit 33b6889
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
39 changes: 19 additions & 20 deletions src/app/model/implementations/exhibition.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {IExhibition} from '../interfaces/exhibition/exhibition.interface';
import {Room} from './room.model';
import {ObjectId} from '../interfaces/exhibition/objectid.interface';

/**
*
Expand All @@ -10,44 +9,44 @@ export class Exhibition implements IExhibition {
/** List of @type {Rooms} for this @type {Exhibition}. */
public rooms: Room[] = [];

/**
* Copies a @type {IExhibition} to a new @type {Exhibition} object.
*
* @param e IExhibition object
* @param target The target for the Proxy object.
*/
public static copyAsProxy(e: IExhibition, target: object): Exhibition {
const n = new Proxy(new Exhibition(e.id, e.key, e.name, e.description), target);
n.rooms = new Proxy([], target);
for (const r of e.rooms) {
const rc = Room.copyAsProxy(r, target);
rc._belongsTo = n;
n.rooms.push(rc);
}
return n;
}

/**
*
* @param id
* @param key
* @param name
* @param description
*/
constructor(public id: ObjectId, public key: string, public name: string, public description: string) {
constructor(public id: string, public key: string, public name: string, public description: string) {
}

/**
* Returns a short ID for this @type {Exhibition}
*/
get shortId(): string {
if (this.id != null) {
return this.id.id.substr(0, 5);
return this.id.substr(0, 5);
} else {
return 'n/a';
}
}

/**
* Copies a @type {IExhibition} to a new @type {Exhibition} object.
*
* @param e IExhibition object
* @param target The target for the Proxy object.
*/
public static copyAsProxy(e: IExhibition, target: object): Exhibition {
const n = new Proxy(new Exhibition(e.id, e.key, e.name, e.description), target);
n.rooms = new Proxy([], target);
for (const r of e.rooms) {
const rc = Room.copyAsProxy(r, target);
rc._belongsTo = n;
n.rooms.push(rc);
}
return n;
}

/**
* Adds a copyAsProxy of the provided {Room} to this {Exhibition}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {IRoom} from '../room/room.interface';
import {ObjectId} from './objectid.interface';

export interface IExhibition {
id: ObjectId;
id: string;
name: string;
key: string;
description: string;
Expand Down

0 comments on commit 33b6889

Please sign in to comment.