2020-02-08 09:36:14 +00:00
|
|
|
export default class HostRecord {
|
|
|
|
public value = '';
|
2020-11-17 04:48:59 +00:00
|
|
|
// tslint:disable-next-line:max-line-length
|
|
|
|
public type: 'paragraph'|'database_ref'|'code_ref'|'file_ref'|'markdown'|'form_input_text'|'form_input_number'|'form_input_password'|'form_input_email'|'form_input_select'|'form_input_multiselect'|'form_input_textarea' = 'paragraph';
|
2020-02-08 09:36:14 +00:00
|
|
|
|
2020-02-08 17:19:00 +00:00
|
|
|
public CreatedAt: string;
|
|
|
|
public PageId: string;
|
2020-10-14 03:28:38 +00:00
|
|
|
private privUUID: string;
|
2020-02-08 17:19:00 +00:00
|
|
|
public UpdatedAt: string;
|
|
|
|
public Value: any;
|
2020-11-17 04:48:59 +00:00
|
|
|
public AdditionalData: any;
|
2020-02-08 09:36:14 +00:00
|
|
|
|
2020-10-14 03:28:38 +00:00
|
|
|
public get UUID(): string {
|
|
|
|
return this.privUUID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public set UUID(val: string) {}
|
|
|
|
|
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() {
|
2020-02-11 05:55:59 +00:00
|
|
|
return ['paragraph', 'header1', 'header2', 'header3', 'header4', 'block_code', 'click_link', 'page_sep'].includes(this.type);
|
2020-02-09 05:09:46 +00:00
|
|
|
}
|
|
|
|
|
2020-11-17 04:48:59 +00:00
|
|
|
public isForm() {
|
|
|
|
return !!this.type?.toLowerCase()?.startsWith('form_input_');
|
|
|
|
}
|
|
|
|
|
2020-02-08 17:19:00 +00:00
|
|
|
load(data: any) {
|
|
|
|
this.type = data.Type;
|
2020-10-14 03:28:38 +00:00
|
|
|
this.privUUID = data.UUID;
|
2020-02-08 17:19:00 +00:00
|
|
|
|
|
|
|
[
|
|
|
|
'CreatedAt',
|
|
|
|
'PageId',
|
|
|
|
'UpdatedAt',
|
|
|
|
'Value',
|
2020-11-17 04:48:59 +00:00
|
|
|
'AdditionalData',
|
2020-02-08 17:19:00 +00:00
|
|
|
].forEach(field => {
|
|
|
|
if ( field in data ) {
|
|
|
|
this[field] = data[field];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
toSave() {
|
|
|
|
const data: any = {
|
|
|
|
Type: this.type
|
|
|
|
};
|
|
|
|
|
|
|
|
[
|
|
|
|
'CreatedAt',
|
|
|
|
'PageId',
|
|
|
|
'UUID',
|
|
|
|
'UpdatedAt',
|
|
|
|
'Value',
|
2020-11-17 04:48:59 +00:00
|
|
|
'AdditionalData',
|
2020-02-08 17:19:00 +00:00
|
|
|
].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
|
|
|
}
|