snappymail/dev/Model/Template.js

43 lines
795 B
JavaScript
Raw Normal View History

2016-07-07 05:03:30 +08:00
import ko from 'ko';
2019-07-05 03:19:24 +08:00
import { pString } from 'Common/Utils';
2016-07-07 05:03:30 +08:00
2019-07-05 03:19:24 +08:00
import { AbstractModel } from 'Knoin/AbstractModel';
2016-07-07 05:03:30 +08:00
2019-07-05 03:19:24 +08:00
class TemplateModel extends AbstractModel {
2016-07-07 05:03:30 +08:00
/**
* @param {string} id
* @param {string} name
* @param {string} body
*/
2019-07-05 03:19:24 +08:00
constructor(id, name, body) {
2016-07-07 05:03:30 +08:00
super('TemplateModel');
this.id = id;
this.name = name;
this.body = body;
this.populated = true;
this.deleteAccess = ko.observable(false);
}
/**
* @returns {boolean}
*/
parse(json) {
let result = false;
2019-07-05 03:19:24 +08:00
if (json && 'Object/Template' === json['@Object']) {
2016-07-07 05:03:30 +08:00
this.id = pString(json.ID);
this.name = pString(json.Name);
this.body = pString(json.Body);
this.populated = !!json.Populated;
result = true;
}
return result;
}
}
2019-07-05 03:19:24 +08:00
export { TemplateModel, TemplateModel as default };