mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Added "Default identity" setting (Closes #157)
This commit is contained in:
parent
c82a897582
commit
d80a9e8485
29 changed files with 239 additions and 67 deletions
|
|
@ -6,9 +6,11 @@
|
|||
function SettingsIdentities()
|
||||
{
|
||||
var oData = RL.data();
|
||||
|
||||
|
||||
this.editor = null;
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.accountEmail = oData.accountEmail;
|
||||
this.displayName = oData.displayName;
|
||||
this.signature = oData.signature;
|
||||
this.signatureToAll = oData.signatureToAll;
|
||||
|
|
@ -16,11 +18,47 @@ function SettingsIdentities()
|
|||
|
||||
this.signatureDom = ko.observable(null);
|
||||
|
||||
this.defaultIdentityIDTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.identities = oData.identities;
|
||||
this.defaultIdentityID = oData.defaultIdentityID;
|
||||
|
||||
this.identitiesOptions = ko.computed(function () {
|
||||
|
||||
var
|
||||
aList = this.identities(),
|
||||
aResult = []
|
||||
;
|
||||
|
||||
if (0 < aList.length)
|
||||
{
|
||||
aResult.push({
|
||||
'id': this.accountEmail.peek(),
|
||||
'name': this.formattedAccountIdentity(),
|
||||
'seporator': false
|
||||
});
|
||||
|
||||
aResult.push({
|
||||
'id': '---',
|
||||
'name': '---',
|
||||
'seporator': true,
|
||||
'disabled': true
|
||||
});
|
||||
|
||||
_.each(aList, function (oItem) {
|
||||
aResult.push({
|
||||
'id': oItem.id,
|
||||
'name': oItem.formattedNameForEmail(),
|
||||
'seporator': false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return aResult;
|
||||
}, this);
|
||||
|
||||
this.processText = ko.computed(function () {
|
||||
return oData.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
|
||||
|
|
@ -47,6 +85,20 @@ function SettingsIdentities()
|
|||
|
||||
Utils.addSettingsViewModel(SettingsIdentities, 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
SettingsIdentities.prototype.formattedAccountIdentity = function ()
|
||||
{
|
||||
var
|
||||
sDisplayName = this.displayName.peek(),
|
||||
sEmail = this.accountEmail.peek()
|
||||
;
|
||||
|
||||
return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>';
|
||||
};
|
||||
|
||||
SettingsIdentities.prototype.addNewIdentity = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsIdentityViewModel);
|
||||
|
|
@ -65,7 +117,7 @@ SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
|
|||
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
|
||||
{
|
||||
this.identityForDeletion(null);
|
||||
|
||||
|
||||
var
|
||||
fRemoveFolder = function (oIdentity) {
|
||||
return oIdentityToRemove === oIdentity;
|
||||
|
|
@ -75,7 +127,7 @@ SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
|
|||
if (oIdentityToRemove)
|
||||
{
|
||||
this.identities.remove(fRemoveFolder);
|
||||
|
||||
|
||||
RL.remote().identityDelete(function () {
|
||||
RL.accountsAndIdentities();
|
||||
}, oIdentityToRemove.id);
|
||||
|
|
@ -121,7 +173,7 @@ SettingsIdentities.prototype.onBuild = function (oDom)
|
|||
self.editIdentity(oIdentityItem);
|
||||
}
|
||||
})
|
||||
;
|
||||
;
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
|
|
@ -129,9 +181,16 @@ SettingsIdentities.prototype.onBuild = function (oDom)
|
|||
oData = RL.data(),
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self),
|
||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self)
|
||||
;
|
||||
|
||||
oData.defaultIdentityID.subscribe(function (sValue) {
|
||||
RL.remote().saveSettings(f4, {
|
||||
'DefaultIdentityID': sValue
|
||||
});
|
||||
});
|
||||
|
||||
oData.displayName.subscribe(function (sValue) {
|
||||
RL.remote().saveSettings(f1, {
|
||||
'DisplayName': sValue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue