33 lines
828 B
TypeScript
33 lines
828 B
TypeScript
import { BaseModel } from '../BaseModel';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { FormGenerator } from '../interfaces/FormGenerator';
|
|
import { Serializable } from '../interfaces/Serializable';
|
|
|
|
export class Page extends BaseModel implements Serializable<Page>, FormGenerator<FormGroup>{
|
|
public title: string;
|
|
public id: string;
|
|
public ordinal: number;
|
|
|
|
constructor(ordinal?: number) {
|
|
super();
|
|
if (isNaN(ordinal)) this.ordinal = 0;
|
|
else this.ordinal = ordinal;
|
|
this.id = "page_" + this.ordinal;
|
|
}
|
|
|
|
fromJSONObject(item: any): Page {
|
|
this.title = item.title;
|
|
this.id = item.id;
|
|
this.ordinal = item.ordinal;
|
|
return this;
|
|
}
|
|
|
|
buildForm(): FormGroup {
|
|
let formGroup = this.formBuilder.group({
|
|
title: [this.title],
|
|
id: [this.id],
|
|
ordinal: [this.ordinal]
|
|
});
|
|
return formGroup;
|
|
}
|
|
} |