2021-12-31 20:30:05 +08:00
|
|
|
import { koComputable } from 'External/ko';
|
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
|
|
|
|
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,
|
|
|
|
|
2022-01-28 06:07:34 +08:00
|
|
|
askDelete: false
|
2020-10-25 18:46:58 +08:00
|
|
|
});
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
this.canBeDeleted = koComputable(() => !!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();
|
|
|
|
|
2022-02-15 17:22:52 +08:00
|
|
|
return name ? name + ' <' + email + '>' : email;
|
2016-07-07 05:03:30 +08:00
|
|
|
}
|
|
|
|
}
|