2019-01-18 18:03:45 +01:00
|
|
|
|
import { FormGroup } from '@angular/forms';
|
|
|
|
|
import { Page } from '../../../../core/model/admin/dataset-profile/dataset-profile';
|
|
|
|
|
import { BaseFormModel } from '../../../../core/model/base-form-model';
|
2019-01-28 17:26:46 +01:00
|
|
|
|
import { Guid } from '../../../../common/types/guid';
|
2018-02-02 11:57:24 +01:00
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
|
export class PageEditorModel extends BaseFormModel {
|
2018-02-02 11:57:24 +01:00
|
|
|
|
public title: string;
|
|
|
|
|
public id: string;
|
|
|
|
|
public ordinal: number;
|
|
|
|
|
|
|
|
|
|
constructor(ordinal?: number) {
|
|
|
|
|
super();
|
2018-10-05 17:00:54 +02:00
|
|
|
|
if (isNaN(ordinal)) { this.ordinal = 0; } else { this.ordinal = ordinal; }
|
2019-01-28 17:26:46 +01:00
|
|
|
|
this.id = Guid.create().toString();
|
2018-02-02 11:57:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
|
fromModel(item: Page): PageEditorModel {
|
2018-02-02 11:57:24 +01:00
|
|
|
|
this.title = item.title;
|
|
|
|
|
this.id = item.id;
|
|
|
|
|
this.ordinal = item.ordinal;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildForm(): FormGroup {
|
2018-10-05 17:00:54 +02:00
|
|
|
|
const formGroup = this.formBuilder.group({
|
2018-02-02 11:57:24 +01:00
|
|
|
|
title: [this.title],
|
|
|
|
|
id: [this.id],
|
|
|
|
|
ordinal: [this.ordinal]
|
|
|
|
|
});
|
|
|
|
|
return formGroup;
|
|
|
|
|
}
|
2018-10-05 17:00:54 +02:00
|
|
|
|
}
|