2023-10-20 17:01:09 +02:00
|
|
|
import { UntypedFormBuilder } from '@angular/forms';
|
|
|
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
2023-10-20 17:01:09 +02:00
|
|
|
import { Guid } from '@common/types/guid';
|
|
|
|
import { BaseEntity } from './base-entity.model';
|
2019-12-11 15:51:03 +01:00
|
|
|
|
2023-10-20 17:01:09 +02:00
|
|
|
export abstract class BaseEditorModel implements IEditorModel {
|
|
|
|
id: Guid;
|
|
|
|
isActive: IsActive;
|
|
|
|
hash: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
2019-12-11 15:51:03 +01:00
|
|
|
|
|
|
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
2023-10-20 17:01:09 +02:00
|
|
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
|
|
|
|
|
|
|
public fromModel(item: Partial<BaseEntity>): BaseEditorModel {
|
|
|
|
if (item) {
|
|
|
|
this.id = item.id;
|
|
|
|
this.isActive = item.isActive;
|
|
|
|
this.hash = item.hash;
|
|
|
|
if (item.createdAt) { this.createdAt = item.createdAt; }
|
|
|
|
if (item.updatedAt) { this.updatedAt = item.updatedAt; }
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface IEditorModel {
|
|
|
|
validationErrorModel: ValidationErrorModel;
|
2019-12-11 15:51:03 +01:00
|
|
|
}
|