argos/dmp-admin/src/app/models/DataSetProfile/Page.ts

33 lines
828 B
TypeScript
Raw Normal View History

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;
2018-01-19 10:31:05 +01:00
public id: string;
public ordinal: number;
2018-01-19 10:31:05 +01:00
constructor(ordinal?: number) {
super();
2018-01-19 10:31:05 +01:00
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;
2018-01-19 10:31:05 +01:00
this.ordinal = item.ordinal;
return this;
}
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
title: [this.title],
2018-01-19 10:31:05 +01:00
id: [this.id],
ordinal: [this.ordinal]
});
return formGroup;
}
}