2016-07-07 05:03:30 +08:00
|
|
|
import ko from 'ko';
|
|
|
|
|
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 IdentityModel extends AbstractModel {
|
2016-07-07 05:03:30 +08:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
* @param {string} email
|
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
constructor(id, email) {
|
2016-07-07 05:03:30 +08:00
|
|
|
super('IdentityModel');
|
|
|
|
|
|
|
|
this.id = ko.observable(id || '');
|
|
|
|
this.email = ko.observable(email);
|
|
|
|
this.name = ko.observable('');
|
|
|
|
|
|
|
|
this.replyTo = ko.observable('');
|
|
|
|
this.bcc = ko.observable('');
|
|
|
|
|
|
|
|
this.signature = ko.observable('');
|
|
|
|
this.signatureInsertBefore = ko.observable(false);
|
|
|
|
|
|
|
|
this.deleteAccess = ko.observable(false);
|
|
|
|
this.canBeDeleted = ko.computed(() => '' !== this.id());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
formattedName() {
|
2019-07-05 03:19:24 +08:00
|
|
|
const name = this.name(),
|
2016-07-07 05:03:30 +08:00
|
|
|
email = this.email();
|
|
|
|
|
|
|
|
return '' !== name ? name + ' (' + email + ')' : email;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { IdentityModel, IdentityModel as default };
|