2020-02-08 09:36:14 +00:00
|
|
|
export default class HostRecord {
|
|
|
|
public value = '';
|
2020-02-09 10:40:22 +00:00
|
|
|
public type: 'paragraph'|'header1'|'header2'|'header3'|'header4'|'block_code'|'click_link'|'database_ref'|'ul'|'code_ref'|'file_ref' = 'paragraph';
|
2020-02-08 09:36:14 +00:00
|
|
|
|
2020-02-08 17:19:00 +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;
|
|
|
|
}
|
2020-02-08 17:19:00 +00:00
|
|
|
|
2020-02-09 05:09:46 +00:00
|
|
|
public isNorm() {
|
|
|
|
return ['paragraph', 'header1', 'header2', 'header3', 'header4', 'block_code', 'click_link'].includes(this.type);
|
|
|
|
}
|
|
|
|
|
2020-02-08 17:19:00 +00:00
|
|
|
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
|
|
|
}
|