frontend/src/app/structures/HostRecord.ts

55 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-02-08 09:36:14 +00:00
export default class HostRecord {
public value = '';
2020-02-08 19:35:07 +00:00
public type: 'paragraph'|'header1'|'header2'|'header3'|'header4'|'block_code'|'click_link'|'ul' = 'paragraph';
2020-02-08 09:36:14 +00:00
public CreatedAt: string;
public PageId: string;
public UUID: string;
public UpdatedAt: string;
public Value: any;
2020-02-08 09:36:14 +00:00
constructor(value = '') {
this.value = value;
}
load(data: any) {
this.type = data.Type;
[
'CreatedAt',
'PageId',
'UUID',
'UpdatedAt',
'Value',
].forEach(field => {
if ( field in data ) {
this[field] = data[field];
}
});
}
toSave() {
const data: any = {
Type: this.type
};
[
'CreatedAt',
'PageId',
'UUID',
'UpdatedAt',
'Value',
].forEach(field => {
if ( field in this ) {
data[field] = this[field];
}
});
if ( !data.Value ) {
data.Value = {};
}
data.Value.Value = this.value;
return data;
}
2020-02-08 09:36:14 +00:00
}