diff --git a/client/src/app/shared/models/agenda/item.ts b/client/src/app/shared/models/agenda/item.ts index b93ab3b6b..ee198f070 100644 --- a/client/src/app/shared/models/agenda/item.ts +++ b/client/src/app/shared/models/agenda/item.ts @@ -12,7 +12,6 @@ interface ContentObject { * @ignore */ export class Item extends BaseModel { - protected _collectionString: string; public id: number; public item_number: string; public title: string; @@ -29,11 +28,7 @@ export class Item extends BaseModel { public parent_id: number; public constructor(input?: any) { - super(); - this._collectionString = 'agenda/item'; - if (input) { - this.deserialize(input); - } + super('agenda/item', input); } public getSpeakers(): User[] { diff --git a/client/src/app/shared/models/agenda/speaker.ts b/client/src/app/shared/models/agenda/speaker.ts index e37d0e093..c1e53d0a8 100644 --- a/client/src/app/shared/models/agenda/speaker.ts +++ b/client/src/app/shared/models/agenda/speaker.ts @@ -1,4 +1,4 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * Representation of a speaker in an agenda item @@ -6,7 +6,7 @@ import { Deserializable } from '../deserializable.model'; * Part of the 'speakers' list. * @ignore */ -export class Speaker implements Deserializable { +export class Speaker extends Deserializer { public id: number; public user_id: number; public begin_time: string; // TODO this is a time object @@ -20,12 +20,6 @@ export class Speaker implements Deserializable { * @param input */ public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/assignments/assignment-user.ts b/client/src/app/shared/models/assignments/assignment-user.ts index 2ad7a82e5..092f86c32 100644 --- a/client/src/app/shared/models/assignments/assignment-user.ts +++ b/client/src/app/shared/models/assignments/assignment-user.ts @@ -1,10 +1,10 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * Content of the 'assignment_related_users' property * @ignore */ -export class AssignmentUser implements Deserializable { +export class AssignmentUser extends Deserializer { public id: number; public user_id: number; public elected: boolean; @@ -16,12 +16,6 @@ export class AssignmentUser implements Deserializable { * @param input */ public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/assignments/assignment.ts b/client/src/app/shared/models/assignments/assignment.ts index d90616936..8d7b4a91f 100644 --- a/client/src/app/shared/models/assignments/assignment.ts +++ b/client/src/app/shared/models/assignments/assignment.ts @@ -9,7 +9,6 @@ import { User } from '../users/user'; * @ignore */ export class Assignment extends BaseModel { - protected _collectionString: string; public id: number; public title: string; public description: string; @@ -22,14 +21,7 @@ export class Assignment extends BaseModel { public tags_id: number[]; public constructor(input?: any) { - super(); - this._collectionString = 'assignments/assignment'; - this.assignment_related_users = []; // TODO Array - this.polls = Array(); // TODO Array - - if (input) { - this.deserialize(input); - } + super('assignments/assignment', input); } public getAssignmentReleatedUsers(): BaseModel | BaseModel[] { @@ -47,15 +39,15 @@ export class Assignment extends BaseModel { public deserialize(input: any): void { Object.assign(this, input); + this.assignment_related_users = []; if (input.assignment_related_users instanceof Array) { - this.assignment_related_users = []; input.assignment_related_users.forEach(assignmentUserData => { this.assignment_related_users.push(new AssignmentUser(assignmentUserData)); }); } + this.polls = []; if (input.polls instanceof Array) { - this.polls = []; input.polls.forEach(pollData => { this.polls.push(new Poll(pollData)); }); diff --git a/client/src/app/shared/models/assignments/poll-option.ts b/client/src/app/shared/models/assignments/poll-option.ts index 308b0088a..5329f73ad 100644 --- a/client/src/app/shared/models/assignments/poll-option.ts +++ b/client/src/app/shared/models/assignments/poll-option.ts @@ -1,4 +1,4 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * Representation of a poll option @@ -6,7 +6,7 @@ import { Deserializable } from '../deserializable.model'; * part of the 'polls-options'-array in poll * @ignore */ -export class PollOption implements Deserializable { +export class PollOption extends Deserializer { public id: number; public candidate_id: number; public is_elected: boolean; @@ -19,12 +19,6 @@ export class PollOption implements Deserializable { * @param input */ public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/assignments/poll.ts b/client/src/app/shared/models/assignments/poll.ts index 8f402a99a..1375cd4a3 100644 --- a/client/src/app/shared/models/assignments/poll.ts +++ b/client/src/app/shared/models/assignments/poll.ts @@ -1,11 +1,11 @@ import { PollOption } from './poll-option'; -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * Content of the 'polls' property of assignments * @ignore */ -export class Poll implements Deserializable { +export class Poll extends Deserializer { public id: number; public pollmethod: string; public description: string; @@ -22,17 +22,14 @@ export class Poll implements Deserializable { * @param input */ public constructor(input?: any) { - this.options = [new PollOption()]; - if (input) { - this.deserialize(input); - } + super(input); } public deserialize(input: any): void { Object.assign(this, input); + this.options = []; if (input.options instanceof Array) { - this.options = []; input.options.forEach(pollOptionData => { this.options.push(new PollOption(pollOptionData)); }); diff --git a/client/src/app/shared/models/base.model.ts b/client/src/app/shared/models/base.model.ts index 6f0522d42..19d4f8131 100644 --- a/client/src/app/shared/models/base.model.ts +++ b/client/src/app/shared/models/base.model.ts @@ -24,7 +24,7 @@ export abstract class BaseModel extends OpenSlidesComponent implements Deseriali * * Has a getter but no setter. */ - protected abstract _collectionString: string; + protected _collectionString: string; /** * force children of BaseModel to have an id @@ -34,8 +34,13 @@ export abstract class BaseModel extends OpenSlidesComponent implements Deseriali /** * constructor that calls super from parent class */ - protected constructor() { + protected constructor(collectionString: string, input?: any) { super(); + this._collectionString = collectionString; + + if (input) { + this.deserialize(input); + } } /** diff --git a/client/src/app/shared/models/core/chat-message.ts b/client/src/app/shared/models/core/chat-message.ts index 60080a8f0..ae334cf38 100644 --- a/client/src/app/shared/models/core/chat-message.ts +++ b/client/src/app/shared/models/core/chat-message.ts @@ -6,18 +6,13 @@ import { User } from '../users/user'; * @ignore */ export class ChatMessage extends BaseModel { - protected _collectionString: string; public id: number; public message: string; public timestamp: string; // TODO: Type for timestamp public user_id: number; public constructor(input?: any) { - super(); - this._collectionString = 'core/chat-message'; - if (input) { - this.deserialize(input); - } + super('core/chat-message', input); } public getUser(): User { diff --git a/client/src/app/shared/models/core/config.ts b/client/src/app/shared/models/core/config.ts index c85275442..70fbd561d 100644 --- a/client/src/app/shared/models/core/config.ts +++ b/client/src/app/shared/models/core/config.ts @@ -5,17 +5,12 @@ import { BaseModel } from '../base.model'; * @ignore */ export class Config extends BaseModel { - protected _collectionString: string; public id: number; public key: string; public value: Object; public constructor(input?: any) { - super(); - this._collectionString = 'core/config'; - if (input) { - this.deserialize(input); - } + super('core/config', input); } } diff --git a/client/src/app/shared/models/core/countdown.ts b/client/src/app/shared/models/core/countdown.ts index d2fe0320a..134416899 100644 --- a/client/src/app/shared/models/core/countdown.ts +++ b/client/src/app/shared/models/core/countdown.ts @@ -5,7 +5,6 @@ import { BaseModel } from '../base.model'; * @ignore */ export class Countdown extends BaseModel { - protected _collectionString: string; public id: number; public description: string; public default_time: number; @@ -13,11 +12,7 @@ export class Countdown extends BaseModel { public running: boolean; public constructor(input?: any) { - super(); - this._collectionString = 'core/countdown'; - if (input) { - this.deserialize(input); - } + super('core/countdown'); } } diff --git a/client/src/app/shared/models/core/projector-message.ts b/client/src/app/shared/models/core/projector-message.ts index 782fbbd56..96f11084d 100644 --- a/client/src/app/shared/models/core/projector-message.ts +++ b/client/src/app/shared/models/core/projector-message.ts @@ -5,16 +5,11 @@ import { BaseModel } from '../base.model'; * @ignore */ export class ProjectorMessage extends BaseModel { - protected _collectionString: string; public id: number; public message: string; public constructor(input?: any) { - super(); - this._collectionString = 'core/projector-message'; - if (input) { - this.deserialize(input); - } + super('core/projector-message', input); } } diff --git a/client/src/app/shared/models/core/projector.ts b/client/src/app/shared/models/core/projector.ts index 271a708c6..48896f891 100644 --- a/client/src/app/shared/models/core/projector.ts +++ b/client/src/app/shared/models/core/projector.ts @@ -5,7 +5,6 @@ import { BaseModel } from '../base.model'; * @ignore */ export class Projector extends BaseModel { - protected _collectionString: string; public id: number; public elements: Object; public scale: number; @@ -17,11 +16,7 @@ export class Projector extends BaseModel { public projectiondefaults: Object[]; public constructor(input?: any) { - super(); - this._collectionString = 'core/projector'; - if (input) { - this.deserialize(input); - } + super('core/projector', input); } } diff --git a/client/src/app/shared/models/core/tag.ts b/client/src/app/shared/models/core/tag.ts index e8678bb15..c0e5c3554 100644 --- a/client/src/app/shared/models/core/tag.ts +++ b/client/src/app/shared/models/core/tag.ts @@ -5,16 +5,11 @@ import { BaseModel } from '../base.model'; * @ignore */ export class Tag extends BaseModel { - protected _collectionString: string; public id: number; public name: string; public constructor(input?: any) { - super(); - this._collectionString = 'core/tag'; - if (input) { - this.deserialize(input); - } + super('core/tag', input); } } diff --git a/client/src/app/shared/models/deserializer.model.ts b/client/src/app/shared/models/deserializer.model.ts new file mode 100644 index 000000000..8013ec618 --- /dev/null +++ b/client/src/app/shared/models/deserializer.model.ts @@ -0,0 +1,25 @@ +import { Deserializable } from './deserializable.model'; + +/** + * Abstract base class for a basic implementation of Deserializable. + * The constructor also gives the possibility to give data that should be serialized. + */ +export abstract class Deserializer implements Deserializable { + /** + * Basic constructor with the possibility to give data to deserialize. + * @param input If data is given, {@method deserialize} will be called with that data + */ + protected constructor(input?: any) { + if (input) { + this.deserialize(input); + } + } + + /** + * should be used to assign JSON values to the object itself. + * @param input + */ + public deserialize(input: any): void { + Object.assign(this, input); + } +} diff --git a/client/src/app/shared/models/mediafiles/file.ts b/client/src/app/shared/models/mediafiles/file.ts index 02009935b..8ac48c45d 100644 --- a/client/src/app/shared/models/mediafiles/file.ts +++ b/client/src/app/shared/models/mediafiles/file.ts @@ -1,10 +1,10 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * The name and the type of a mediaFile. * @ignore */ -export class File implements Deserializable { +export class File extends Deserializer { public name: string; public type: string; @@ -14,12 +14,6 @@ export class File implements Deserializable { * @param type The tape (jpg, png, pdf) */ public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/mediafiles/mediafile.ts b/client/src/app/shared/models/mediafiles/mediafile.ts index c7a163676..548be70cb 100644 --- a/client/src/app/shared/models/mediafiles/mediafile.ts +++ b/client/src/app/shared/models/mediafiles/mediafile.ts @@ -7,7 +7,6 @@ import { User } from '../users/user'; * @ignore */ export class Mediafile extends BaseModel { - protected _collectionString: string; public id: number; public title: string; public mediafile: File; @@ -18,11 +17,7 @@ export class Mediafile extends BaseModel { public timestamp: string; public constructor(input?: any) { - super(); - this._collectionString = 'mediafiles/mediafile'; - if (input) { - this.deserialize(input); - } + super('mediafiles/mediafile', input); } public deserialize(input: any): void { diff --git a/client/src/app/shared/models/motions/category.ts b/client/src/app/shared/models/motions/category.ts index aae765e05..46db19241 100644 --- a/client/src/app/shared/models/motions/category.ts +++ b/client/src/app/shared/models/motions/category.ts @@ -5,17 +5,12 @@ import { BaseModel } from '../base.model'; * @ignore */ export class Category extends BaseModel { - protected _collectionString: string; public id: number; public name: string; public prefix: string; public constructor(input?: any) { - super(); - this._collectionString = 'motions/category'; - if (input) { - this.deserialize(input); - } + super('motions/category', input); } public toString = (): string => { diff --git a/client/src/app/shared/models/motions/motion-block.ts b/client/src/app/shared/models/motions/motion-block.ts index 88d685131..54dccc629 100644 --- a/client/src/app/shared/models/motions/motion-block.ts +++ b/client/src/app/shared/models/motions/motion-block.ts @@ -6,17 +6,12 @@ import { Item } from '../agenda/item'; * @ignore */ export class MotionBlock extends BaseModel { - protected _collectionString: string; public id: number; public title: string; public agenda_item_id: number; public constructor(input?: any) { - super(); - this._collectionString = 'motions/motion-block'; - if (input) { - this.deserialize(input); - } + super('motions/motion-block', input); } public getAgenda(): BaseModel | BaseModel[] { diff --git a/client/src/app/shared/models/motions/motion-change-reco.ts b/client/src/app/shared/models/motions/motion-change-reco.ts index fb8f9eb4c..12325dc7f 100644 --- a/client/src/app/shared/models/motions/motion-change-reco.ts +++ b/client/src/app/shared/models/motions/motion-change-reco.ts @@ -5,7 +5,6 @@ import { BaseModel } from '../base.model'; * @ignore */ export class MotionChangeReco extends BaseModel { - protected _collectionString: string; public id: number; public motion_version_id: number; public rejected: boolean; @@ -17,11 +16,7 @@ export class MotionChangeReco extends BaseModel { public creation_time: string; public constructor(input?: any) { - super(); - this._collectionString = 'motions/motion-change-recommendation'; - if (input) { - this.deserialize(input); - } + super('motions/motion-change-recommendation', input); } } diff --git a/client/src/app/shared/models/motions/motion-comment-section.ts b/client/src/app/shared/models/motions/motion-comment-section.ts new file mode 100644 index 000000000..c4c96617c --- /dev/null +++ b/client/src/app/shared/models/motions/motion-comment-section.ts @@ -0,0 +1,18 @@ +import { BaseModel } from '../base.model'; + +/** + * Representation of a motion category. Has the nested property "File" + * @ignore + */ +export class MotionCommentSection extends BaseModel { + public id: number; + public name: string; + public read_groups_id: number[]; + public write_groups_id: number[]; + + public constructor(input?: any) { + super('motions/motion-comment-section', input); + } +} + +BaseModel.registerCollectionElement('motions/motion-comment-section', MotionCommentSection); diff --git a/client/src/app/shared/models/motions/motion-comment.ts b/client/src/app/shared/models/motions/motion-comment.ts new file mode 100644 index 000000000..78447574b --- /dev/null +++ b/client/src/app/shared/models/motions/motion-comment.ts @@ -0,0 +1,15 @@ +import { Deserializer } from '../deserializer.model'; + +/** + * Representation of a Motion Comment. + */ +export class MotionComment extends Deserializer { + public id: number; + public comment: string; + public section_id: number; + public read_groups_id: number[]; + + public constructor(input?: any) { + super(input); + } +} diff --git a/client/src/app/shared/models/motions/motion-log.ts b/client/src/app/shared/models/motions/motion-log.ts index 2e240ecbc..952f00cec 100644 --- a/client/src/app/shared/models/motions/motion-log.ts +++ b/client/src/app/shared/models/motions/motion-log.ts @@ -1,23 +1,17 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** - * Representation of a Motion Version. + * Representation of a Motion Log. * * @ignore */ -export class MotionLog implements Deserializable { +export class MotionLog extends Deserializer { public message_list: string[]; public person_id: number; public time: string; public message: string; public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/motions/motion-submitter.ts b/client/src/app/shared/models/motions/motion-submitter.ts index b1399e639..665ad00cc 100644 --- a/client/src/app/shared/models/motions/motion-submitter.ts +++ b/client/src/app/shared/models/motions/motion-submitter.ts @@ -1,23 +1,17 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; /** * Representation of a Motion Submitter. * * @ignore */ -export class MotionSubmitter implements Deserializable { +export class MotionSubmitter extends Deserializer { public id: number; public user_id: number; public motion_id: number; public weight: number; public constructor(input?: any) { - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); + super(input); } } diff --git a/client/src/app/shared/models/motions/motion-version.ts b/client/src/app/shared/models/motions/motion-version.ts deleted file mode 100644 index 6fc9ff580..000000000 --- a/client/src/app/shared/models/motions/motion-version.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Deserializable } from '../deserializable.model'; - -/** - * Representation of a Motion Version. - * - * @ignore - */ -export class MotionVersion implements Deserializable { - public id: number; - public version_number: number; - public creation_time: string; - public title: string; - public text: string; - public amendment_paragraphs: string; - public reason: string; - - public constructor(input?: any) { - this.title = ''; - this.text = ''; - this.reason = ''; - - if (input) { - this.deserialize(input); - } - } - - public deserialize(input: any): void { - Object.assign(this, input); - } -} diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts index 697b804de..4535467a9 100644 --- a/client/src/app/shared/models/motions/motion.ts +++ b/client/src/app/shared/models/motions/motion.ts @@ -6,6 +6,7 @@ import { Workflow } from './workflow'; import { User } from '../users/user'; import { Category } from './category'; import { WorkflowState } from './workflow-state'; +import { MotionComment } from './motion-comment'; /** * Representation of Motion. @@ -15,7 +16,6 @@ import { WorkflowState } from './workflow-state'; * @ignore */ export class Motion extends BaseModel { - protected _collectionString: string; public id: number; public identifier: string; public title: string; @@ -29,7 +29,7 @@ export class Motion extends BaseModel { public origin: string; public submitters: MotionSubmitter[]; public supporters_id: number[]; - public comments: Object[]; + public comments: MotionComment[]; public state_id: number; public state_extension: string; public state_required_permission_to_see: string; @@ -45,22 +45,7 @@ export class Motion extends BaseModel { public workflow: Workflow; public constructor(input?: any) { - super(); - this._collectionString = 'motions/motion'; - this.identifier = ''; - this.title = ''; - this.text = ''; - this.reason = ''; - this.modified_final_version = ''; - this.origin = ''; - this.submitters = []; - this.supporters_id = []; - this.state_required_permission_to_see = ''; - this.log_messages = []; - - if (input) { - this.deserialize(input); - } + super('motions/motion', input); this.initDataStoreValues(); } @@ -186,19 +171,26 @@ export class Motion extends BaseModel { public deserialize(input: any): void { Object.assign(this, input); + this.submitters = []; if (input.submitters instanceof Array) { - this.submitters = []; input.submitters.forEach(SubmitterData => { this.submitters.push(new MotionSubmitter(SubmitterData)); }); } + this.log_messages = []; if (input.log_messages instanceof Array) { - this.log_messages = []; input.log_messages.forEach(logData => { this.log_messages.push(new MotionLog(logData)); }); } + + this.comments = []; + if (input.comments instanceof Array) { + input.comments.forEach(commentData => { + this.comments.push(new MotionComment(commentData)); + }); + } } } diff --git a/client/src/app/shared/models/motions/workflow-state.ts b/client/src/app/shared/models/motions/workflow-state.ts index afeb16aca..99bf6f27d 100644 --- a/client/src/app/shared/models/motions/workflow-state.ts +++ b/client/src/app/shared/models/motions/workflow-state.ts @@ -1,4 +1,4 @@ -import { Deserializable } from '../deserializable.model'; +import { Deserializer } from '../deserializer.model'; import { Workflow } from './workflow'; /** @@ -7,7 +7,7 @@ import { Workflow } from './workflow'; * Part of the 'states'-array in motion/workflow * @ignore */ -export class WorkflowState implements Deserializable { +export class WorkflowState extends Deserializer { public id: number; public name: string; public action_word: string; @@ -17,8 +17,6 @@ export class WorkflowState implements Deserializable { public allow_support: boolean; public allow_create_poll: boolean; public allow_submitter_edit: boolean; - public versioning: boolean; - public leave_old_version_active: boolean; public dont_set_identifier: boolean; public show_state_extension_field: boolean; public show_recommendation_extension_field: boolean; @@ -30,9 +28,7 @@ export class WorkflowState implements Deserializable { * @param input If given, it will be deserialized */ public constructor(input?: any) { - if (input) { - this.deserialize(input); - } + super(input); } /** @@ -49,10 +45,6 @@ export class WorkflowState implements Deserializable { return nextStates; } - public deserialize(input: any): void { - Object.assign(this, input); - } - public toString = (): string => { return this.name; }; diff --git a/client/src/app/shared/models/motions/workflow.ts b/client/src/app/shared/models/motions/workflow.ts index 99b2393d8..231d4c4c8 100644 --- a/client/src/app/shared/models/motions/workflow.ts +++ b/client/src/app/shared/models/motions/workflow.ts @@ -6,18 +6,13 @@ import { WorkflowState } from './workflow-state'; * @ignore */ export class Workflow extends BaseModel { - protected _collectionString: string; public id: number; public name: string; public states: WorkflowState[]; public first_state: number; public constructor(input?: any) { - super(); - this._collectionString = 'motions/workflow'; - if (input) { - this.deserialize(input); - } + super('motions/workflow', input); } /** diff --git a/client/src/app/shared/models/topics/topic.ts b/client/src/app/shared/models/topics/topic.ts index c0db048ab..3eb0262d0 100644 --- a/client/src/app/shared/models/topics/topic.ts +++ b/client/src/app/shared/models/topics/topic.ts @@ -7,7 +7,6 @@ import { Item } from '../agenda/item'; * @ignore */ export class Topic extends BaseModel { - protected _collectionString: string; public id: number; public title: string; public text: string; @@ -15,11 +14,7 @@ export class Topic extends BaseModel { public agenda_item_id: number; public constructor(input?: any) { - super(); - this._collectionString = 'topics/topic'; - if (input) { - this.deserialize(input); - } + super('topics/topic', input); } public getAttachments(): Mediafile[] { diff --git a/client/src/app/shared/models/users/group.ts b/client/src/app/shared/models/users/group.ts index ae458cf7e..41ea9d59e 100644 --- a/client/src/app/shared/models/users/group.ts +++ b/client/src/app/shared/models/users/group.ts @@ -6,17 +6,12 @@ import { User } from './user'; * @ignore */ export class Group extends BaseModel { - protected _collectionString: string; public id: number; public name: string; public permissions: string[]; public constructor(input?: any) { - super(); - this._collectionString = 'users/group'; - if (input) { - this.deserialize(input); - } + super('users/group', input); } public get users(): User[] { diff --git a/client/src/app/shared/models/users/personal-note.ts b/client/src/app/shared/models/users/personal-note.ts index 26a607704..a13b46718 100644 --- a/client/src/app/shared/models/users/personal-note.ts +++ b/client/src/app/shared/models/users/personal-note.ts @@ -6,17 +6,12 @@ import { User } from './user'; * @ignore */ export class PersonalNote extends BaseModel { - protected _collectionString: string; public id: number; public user_id: number; public notes: Object; public constructor(input: any) { - super(); - this._collectionString = 'users/personal-note'; - if (input) { - this.deserialize(input); - } + super('users/personal-note', input); } public getUser(): User { diff --git a/client/src/app/shared/models/users/user.ts b/client/src/app/shared/models/users/user.ts index bdd94d95d..4467b7292 100644 --- a/client/src/app/shared/models/users/user.ts +++ b/client/src/app/shared/models/users/user.ts @@ -6,7 +6,6 @@ import { Group } from './group'; * @ignore */ export class User extends BaseModel { - protected _collectionString: string; public id: number; public username: string; public title: string; @@ -25,12 +24,7 @@ export class User extends BaseModel { public default_password: string; public constructor(input?: any) { - super(); - this._collectionString = 'users/user'; - - if (input) { - this.deserialize(input); - } + super('users/user', input); } public get groups(): Group[] { diff --git a/client/src/app/site/start/start.component.ts b/client/src/app/site/start/start.component.ts index 552f95c65..a4175184c 100644 --- a/client/src/app/site/start/start.component.ts +++ b/client/src/app/site/start/start.component.ts @@ -94,11 +94,11 @@ export class StartComponent extends BaseComponent implements OnInit { console.log('the user: ', user1fromStore); console.log('remove a single user:'); - // this.DS.remove(User, 100); + this.DS.remove('users/user', 100); console.log('remove more users'); - // this.DS.remove(User, 200, 201, 202); + this.DS.remove('users/user', 200, 201, 202); console.log('remove an array of users'); - // this.DS.remove(User, ...[321, 363, 399]); + this.DS.remove('users/user', ...[321, 363, 399]); console.log('test filter: '); console.log(this.DS.filter(User, user => user.id === 1));