OpenSlides/client/src/app/shared/models/base.model.ts
Sean Engelhardt 76ce18cfd8 Add modules and lazy loading
- core modules contains core services
- shared module contains "dumb" components (directives, models)
  - used by nearly all modules
- site, it's children and projector are now feature modules
  - full lazy loading with independent routing
  - routing for children (extremely helpful for plugins (later))
2018-08-15 10:19:46 +02:00

50 lines
1.2 KiB
TypeScript

import { OpenSlidesComponent } from 'app/openslides.component';
/**
* Define that an ID might be a number or a string.
*/
export type ModelId = number | string;
/**
* Abstract parent class to set rules and functions for all models.
*/
export abstract class BaseModel extends OpenSlidesComponent {
/**
* force children of BaseModel to have a collectionString.
*
* Has a getter but no setter.
*/
protected abstract _collectionString: string;
/**
* force children of BaseModel to have an `id`
*/
abstract id: ModelId;
/**
* constructor that calls super from parent class
*/
protected constructor() {
super();
}
/**
* returns the collectionString.
*
* The server and the dataStore use it to identify the collection.
*/
get collectionString(): string {
return this._collectionString;
}
/**
* Most simple and most commonly used deserialize function.
* Inherited to children, can be overwritten for special use cases
* @param input JSON data for deserialization.
*/
deserialize(input: any): this {
Object.assign(this, input);
return this;
}
}