mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Identities refactoring and improvements (Reply-To and BCC)
This commit is contained in:
parent
3e01887f85
commit
493191375f
43 changed files with 578 additions and 1051 deletions
|
|
@ -33,7 +33,6 @@
|
|||
this.capaUserBackground = CapaAdminStore.userBackground;
|
||||
this.capaGravatar = CapaAdminStore.gravatar;
|
||||
this.capaAdditionalAccounts = CapaAdminStore.additionalAccounts;
|
||||
this.capaAdditionalIdentities = CapaAdminStore.additionalIdentities;
|
||||
this.capaAttachmentThumbnails = CapaAdminStore.attachmentThumbnails;
|
||||
|
||||
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
|
||||
|
|
@ -106,12 +105,6 @@
|
|||
});
|
||||
});
|
||||
|
||||
self.capaAdditionalIdentities.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaAdditionalIdentities': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.capaGravatar.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaGravatar': bValue ? '1' : '0'
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
Links = require('Common/Links'),
|
||||
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
IdentityStore = require('Stores/User/Identity'),
|
||||
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
function AccountsUserSettings()
|
||||
{
|
||||
this.accounts = AccountStore.accounts;
|
||||
this.identities = IdentityStore.identities;
|
||||
|
||||
this.processText = ko.computed(function () {
|
||||
return AccountStore.accounts.loading() ? Translator.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : '';
|
||||
|
|
@ -45,6 +47,20 @@
|
|||
}
|
||||
}
|
||||
]});
|
||||
|
||||
this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
|
||||
function (oPrev) {
|
||||
if (oPrev)
|
||||
{
|
||||
oPrev.deleteAccess(false);
|
||||
}
|
||||
}, function (oNext) {
|
||||
if (oNext)
|
||||
{
|
||||
oNext.deleteAccess(true);
|
||||
}
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
AccountsUserSettings.prototype.scrollableOptions = function ()
|
||||
|
|
@ -56,17 +72,27 @@
|
|||
|
||||
AccountsUserSettings.prototype.addNewAccount = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/AddAccount'));
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
|
||||
};
|
||||
|
||||
AccountsUserSettings.prototype.editAccount = function (oAccountItem)
|
||||
{
|
||||
if (oAccountItem && oAccountItem.canBeEdit())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/AddAccount'), [oAccountItem]);
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]);
|
||||
}
|
||||
};
|
||||
|
||||
AccountsUserSettings.prototype.addNewIdentity = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'));
|
||||
};
|
||||
|
||||
AccountsUserSettings.prototype.editIdentity = function (oIdentity)
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AccountModel} oAccountToRemove
|
||||
*/
|
||||
|
|
@ -110,18 +136,47 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {IdentityModel} oIdentityToRemove
|
||||
*/
|
||||
AccountsUserSettings.prototype.deleteIdentity = function (oIdentityToRemove)
|
||||
{
|
||||
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
|
||||
{
|
||||
this.identityForDeletion(null);
|
||||
|
||||
if (oIdentityToRemove)
|
||||
{
|
||||
IdentityStore.identities.remove(function (oIdentity) {
|
||||
return oIdentityToRemove === oIdentity;
|
||||
});
|
||||
|
||||
Remote.identityDelete(function () {
|
||||
require('App/User').accountsAndIdentities();
|
||||
}, oIdentityToRemove.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AccountsUserSettings.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.account-item .e-action', function () {
|
||||
.on('click', '.accounts-list .account-item .e-action', function () {
|
||||
var oAccountItem = ko.dataFor(this);
|
||||
if (oAccountItem)
|
||||
{
|
||||
self.editAccount(oAccountItem);
|
||||
}
|
||||
})
|
||||
.on('click', '.identities-list .identity-item .e-action', function () {
|
||||
var oIdentityItem = ko.dataFor(this);
|
||||
if (oIdentityItem)
|
||||
{
|
||||
self.editIdentity(oIdentityItem);
|
||||
}
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,226 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
IdentityStore = require('Stores/User/Identity'),
|
||||
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function IdentitiesUserSettings()
|
||||
{
|
||||
this.editor = null;
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.accountEmail = AccountStore.email;
|
||||
|
||||
this.displayName = AccountStore.displayName;
|
||||
this.signature = AccountStore.signature;
|
||||
this.replyTo = AccountStore.replyTo;
|
||||
|
||||
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 = IdentityStore.identities;
|
||||
this.defaultIdentityID = IdentityStore.defaultIdentityID;
|
||||
|
||||
this.identitiesOptions = ko.computed(function () {
|
||||
|
||||
var
|
||||
aList = IdentityStore.identities(),
|
||||
aResult = []
|
||||
;
|
||||
|
||||
if (0 < aList.length)
|
||||
{
|
||||
aResult.push({
|
||||
'id': AccountStore.email.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 IdentityStore.identities.loading() ? Translator.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
|
||||
}, this);
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return '' === this.processText() ? 'hidden' : 'visible';
|
||||
}, this);
|
||||
|
||||
this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
|
||||
function (oPrev) {
|
||||
if (oPrev)
|
||||
{
|
||||
oPrev.deleteAccess(false);
|
||||
}
|
||||
}, function (oNext) {
|
||||
if (oNext)
|
||||
{
|
||||
oNext.deleteAccess(true);
|
||||
}
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
IdentitiesUserSettings.prototype.formattedAccountIdentity = function ()
|
||||
{
|
||||
var
|
||||
sDisplayName = AccountStore.displayName.peek(),
|
||||
sEmail = AccountStore.email.peek()
|
||||
;
|
||||
|
||||
return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>';
|
||||
};
|
||||
|
||||
IdentitiesUserSettings.prototype.addNewIdentity = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'));
|
||||
};
|
||||
|
||||
IdentitiesUserSettings.prototype.editIdentity = function (oIdentity)
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {IdentityModel} oIdentityToRemove
|
||||
*/
|
||||
IdentitiesUserSettings.prototype.deleteIdentity = function (oIdentityToRemove)
|
||||
{
|
||||
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
|
||||
{
|
||||
this.identityForDeletion(null);
|
||||
|
||||
if (oIdentityToRemove)
|
||||
{
|
||||
IdentityStore.identities.remove(function (oIdentity) {
|
||||
return oIdentityToRemove === oIdentity;
|
||||
});
|
||||
|
||||
Remote.identityDelete(function () {
|
||||
require('App/User').accountsAndIdentities();
|
||||
}, oIdentityToRemove.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
IdentitiesUserSettings.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sSignature = AccountStore.signature()
|
||||
;
|
||||
|
||||
this.editor = new HtmlEditor(self.signatureDom(), function () {
|
||||
AccountStore.signature(
|
||||
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
|
||||
);
|
||||
}, function () {
|
||||
if (':HTML:' === sSignature.substr(0, 6))
|
||||
{
|
||||
self.editor.setHtml(sSignature.substr(6), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.editor.setPlain(sSignature, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
IdentitiesUserSettings.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.identity-item .e-action', function () {
|
||||
var oIdentityItem = ko.dataFor(this);
|
||||
if (oIdentityItem)
|
||||
{
|
||||
self.editIdentity(oIdentityItem);
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self),
|
||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self)
|
||||
;
|
||||
|
||||
IdentityStore.defaultIdentityID.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f4, {
|
||||
'DefaultIdentityID': sValue
|
||||
});
|
||||
});
|
||||
|
||||
AccountStore.displayName.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f1, {
|
||||
'DisplayName': sValue
|
||||
});
|
||||
});
|
||||
|
||||
AccountStore.replyTo.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f2, {
|
||||
'ReplyTo': sValue
|
||||
});
|
||||
});
|
||||
|
||||
AccountStore.signature.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f3, {
|
||||
'Signature': sValue
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = IdentitiesUserSettings;
|
||||
|
||||
}());
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function IdentityUserSettings()
|
||||
{
|
||||
this.editor = null;
|
||||
|
||||
this.displayName = AccountStore.displayName;
|
||||
this.signature = AccountStore.signature;
|
||||
this.replyTo = AccountStore.replyTo;
|
||||
|
||||
this.signatureDom = ko.observable(null);
|
||||
|
||||
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
IdentityUserSettings.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sSignature = AccountStore.signature()
|
||||
;
|
||||
|
||||
this.editor = new HtmlEditor(self.signatureDom(), function () {
|
||||
AccountStore.signature(
|
||||
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
|
||||
);
|
||||
}, function () {
|
||||
if (':HTML:' === sSignature.substr(0, 6))
|
||||
{
|
||||
self.editor.setHtml(sSignature.substr(6), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.editor.setPlain(sSignature, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
IdentityUserSettings.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
|
||||
;
|
||||
|
||||
AccountStore.displayName.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f1, {
|
||||
'DisplayName': sValue
|
||||
});
|
||||
});
|
||||
|
||||
AccountStore.replyTo.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f2, {
|
||||
'ReplyTo': sValue
|
||||
});
|
||||
});
|
||||
|
||||
AccountStore.signature.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f3, {
|
||||
'Signature': sValue
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = IdentityUserSettings;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue