snappymail/dev/Model/Identity.js

40 lines
626 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 { AbstractModel } from 'Knoin/AbstractModel';
2016-07-07 05:03:30 +08:00
2021-01-22 23:32:08 +08:00
export 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) {
2020-10-19 01:19:45 +08:00
super();
2016-07-07 05:03:30 +08:00
2020-10-25 18:46:58 +08:00
this.addObservables({
id: id || '',
email: email,
name: '',
2016-07-07 05:03:30 +08:00
2020-10-25 18:46:58 +08:00
replyTo: '',
bcc: '',
2016-07-07 05:03:30 +08:00
2020-10-25 18:46:58 +08:00
signature: '',
signatureInsertBefore: false,
deleteAccess: false
});
2016-07-07 05:03:30 +08:00
this.canBeDeleted = ko.computed(() => !!this.id());
2016-07-07 05:03:30 +08:00
}
/**
* @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;
2016-07-07 05:03:30 +08:00
}
}