Identities refactoring and improvements (Reply-To and BCC)

This commit is contained in:
RainLoop Team 2015-02-06 19:26:20 +04:00
parent 3e01887f85
commit 493191375f
43 changed files with 578 additions and 1051 deletions

View file

@ -581,7 +581,7 @@
var
sId = Utils.pString(oIdentityData['Id']),
sEmail = Utils.pString(oIdentityData['Email']),
oIdentity = new IdentityModel(sId, sEmail, sId !== sAccountEmail)
oIdentity = new IdentityModel(sId, sEmail)
;
oIdentity.name(Utils.pString(oIdentityData['Name']));
@ -1410,7 +1410,6 @@
require('Stores/User/App').populate();
require('Stores/User/Settings').populate();
require('Stores/User/Notification').populate();
require('Stores/User/Identity').populate();
require('Stores/User/Account').populate();
var
@ -1528,10 +1527,7 @@
self.contactsSync();
}, iContactsSyncInterval * 60000 + 5000);
if (Settings.capa(Enums.Capa.AdditionalAccounts) || Settings.capa(Enums.Capa.AdditionalIdentities))
{
self.accountsAndIdentities(true);
}
self.accountsAndIdentities(true);
_.delay(function () {
var sF = Data.currentFolderFullNameRaw();

View file

@ -45,8 +45,7 @@
'Sieve': 'SIEVE',
'Filters': 'FILTERS',
'AttachmentThumbnails': 'ATTACHMENT_THUMBNAILS',
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS'
};
/**
@ -149,7 +148,8 @@
'FolderListSize': 4,
'MessageListSize': 5,
'LastReplyAction': 6,
'LastSignMe': 7
'LastSignMe': 7,
'ComposeLastIdentityID': 8
};
/**

View file

@ -28,8 +28,8 @@
this.count = ko.observable(iCount || 0);
this.deleteAccess = ko.observable(false);
this.canBeDalete = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete);
this.canBeEdit = this.canBeDalete;
this.canBeDeleted = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete);
this.canBeEdit = this.canBeDeleted;
}
_.extend(AccountModel.prototype, AbstractModel.prototype);

View file

@ -140,7 +140,7 @@
this.regDisposables([this.actionNoStop, this.actionTemplate]);
this.deleteAccess = ko.observable(false);
this.canBeDalete = ko.observable(true);
this.canBeDeleted = ko.observable(true);
}
_.extend(FilterModel.prototype, AbstractModel.prototype);

View file

@ -15,41 +15,35 @@
/**
* @param {string} sId
* @param {string} sEmail
* @param {boolean=} bCanBeDelete = true
* @constructor
*/
function IdentityModel(sId, sEmail, bCanBeDelete)
function IdentityModel(sId, sEmail)
{
AbstractModel.call(this, 'IdentityModel');
this.id = sId;
this.id = ko.observable(sId);
this.email = ko.observable(sEmail);
this.name = ko.observable('');
this.replyTo = ko.observable('');
this.bcc = ko.observable('');
this.deleteAccess = ko.observable(false);
this.canBeDalete = ko.observable(bCanBeDelete);
this.canBeDeleted = ko.computed(function () {
return '' !== this.id();
}, this);
}
_.extend(IdentityModel.prototype, AbstractModel.prototype);
IdentityModel.prototype.formattedName = function ()
{
var sName = this.name();
return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
};
var
sName = this.name(),
sEmail = this.email()
;
IdentityModel.prototype.formattedNameForCompose = function ()
{
var sName = this.name();
return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
};
IdentityModel.prototype.formattedNameForEmail = function ()
{
var sName = this.name();
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
return ('' !== sName) ? sName + ' (' + sEmail + ')' : sEmail;
};
module.exports = IdentityModel;

View file

@ -608,6 +608,16 @@
return MessageModel.emailsToLine(this.bcc, bFriendlyView, bWrapWithLink);
};
/**
* @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.prototype.replyToToLine = function (bFriendlyView, bWrapWithLink)
{
return MessageModel.emailsToLine(this.replyTo, bFriendlyView, bWrapWithLink);
};
/**
* @return string
*/
@ -867,6 +877,7 @@
'popupTo': this.toToLine(false),
'popupCc': this.ccToLine(false),
'popupBcc': this.bccToLine(false),
'popupReplyTo': this.replyToToLine(false),
'popupSubject': this.subject(),
'popupIsHtml': this.isHtml(),
'popupDate': this.fullFormatDateValue(),

View file

@ -59,17 +59,6 @@
'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
}
if (Settings.capa(Enums.Capa.AdditionalIdentities))
{
kn.addSettingsViewModel(require('Settings/User/Identities'),
'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
}
else
{
kn.addSettingsViewModel(require('Settings/User/Identity'),
'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
}
if (Settings.capa(Enums.Capa.Sieve))
{
kn.addSettingsViewModel(require('Settings/User/Filters'),

View file

@ -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'

View file

@ -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);
}
})
;
};

View file

@ -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;
}());

View file

@ -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;
}());

View file

@ -494,10 +494,10 @@
/**
* @param {?Function} fCallback
* @param {string} sIdentityID
* @param {string} sMessageFolder
* @param {string} sMessageUid
* @param {string} sDraftFolder
* @param {string} sFrom
* @param {string} sTo
* @param {string} sCc
* @param {string} sBcc
@ -510,17 +510,18 @@
* @param {string} sReferences
* @param {boolean} bMarkAsImportant
*/
RemoteUserStorage.prototype.saveMessage = function (fCallback, sMessageFolder, sMessageUid, sDraftFolder,
sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bMarkAsImportant)
RemoteUserStorage.prototype.saveMessage = function (fCallback, sIdentityID, sMessageFolder, sMessageUid, sDraftFolder,
sTo, sCc, sBcc, sReplyTo, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bMarkAsImportant)
{
this.defaultRequest(fCallback, 'SaveMessage', {
'IdentityID': sIdentityID,
'MessageFolder': sMessageFolder,
'MessageUid': sMessageUid,
'DraftFolder': sDraftFolder,
'From': sFrom,
'To': sTo,
'Cc': sCc,
'Bcc': sBcc,
'ReplyTo': sReplyTo,
'Subject': sSubject,
'TextIsHtml': bTextIsHtml ? '1' : '0',
'Text': sText,
@ -554,13 +555,14 @@
/**
* @param {?Function} fCallback
* @param {string} sIdentityID
* @param {string} sMessageFolder
* @param {string} sMessageUid
* @param {string} sSentFolder
* @param {string} sFrom
* @param {string} sTo
* @param {string} sCc
* @param {string} sBcc
* @param {string} sReplyTo
* @param {string} sSubject
* @param {boolean} bTextIsHtml
* @param {string} sText
@ -571,18 +573,19 @@
* @param {boolean} bRequestReadReceipt
* @param {boolean} bMarkAsImportant
*/
RemoteUserStorage.prototype.sendMessage = function (fCallback, sMessageFolder, sMessageUid, sSentFolder,
sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences,
RemoteUserStorage.prototype.sendMessage = function (fCallback, sIdentityID, sMessageFolder, sMessageUid, sSentFolder,
sTo, sCc, sBcc, sReplyTo, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences,
bRequestReadReceipt, bMarkAsImportant)
{
this.defaultRequest(fCallback, 'SendMessage', {
'IdentityID': sIdentityID,
'MessageFolder': sMessageFolder,
'MessageUid': sMessageUid,
'SentFolder': sSentFolder,
'From': sFrom,
'To': sTo,
'Cc': sCc,
'Bcc': sBcc,
'ReplyTo': sReplyTo,
'Subject': sSubject,
'TextIsHtml': bTextIsHtml ? '1' : '0',
'Text': sText,

View file

@ -17,7 +17,6 @@
function CapaAdminStore()
{
this.additionalAccounts = ko.observable(false);
this.additionalIdentities = ko.observable(false);
this.gravatar = ko.observable(false);
this.attachmentThumbnails = ko.observable(false);
this.sieve = ko.observable(false);
@ -31,7 +30,6 @@
CapaAdminStore.prototype.populate = function()
{
this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
this.additionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities));
this.gravatar(Settings.capa(Enums.Capa.Gravatar));
this.attachmentThumbnails(Settings.capa(Enums.Capa.AttachmentThumbnails));
this.sieve(Settings.capa(Enums.Capa.Sieve));

View file

@ -21,8 +21,6 @@
// this.incLogin = ko.observable('');
// this.outLogin = ko.observable('');
this.displayName = ko.observable('');
this.replyTo = ko.observable('');
this.signature = ko.observable('');
this.accounts = ko.observableArray([]);
@ -70,9 +68,7 @@
// this.incLogin(Settings.settingsGet('IncLogin'));
// this.outLogin(Settings.settingsGet('OutLogin'));
this.displayName(Settings.settingsGet('DisplayName'));
this.replyTo(Settings.settingsGet('ReplyTo'));
this.signature(Settings.settingsGet('Signature'));
// this.signature(Settings.settingsGet('Signature'));
};
module.exports = new AccountUserStore();

View file

@ -7,7 +7,7 @@
ko = require('ko'),
Settings = require('Storage/Settings'),
AppStore = require('Stores/App')
;
@ -36,7 +36,9 @@
this.projectHash(Settings.settingsGet('ProjectHash'));
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
this.devEmail = Settings.settingsGet('DevEmail');

View file

@ -4,9 +4,7 @@
'use strict';
var
ko = require('ko'),
Settings = require('Storage/Settings')
ko = require('ko')
;
/**
@ -14,17 +12,10 @@
*/
function IdentityUserStore()
{
this.defaultIdentityID = ko.observable('');
this.identities = ko.observableArray([]);
this.identities.loading = ko.observable(false).extend({'throttle': 100});
}
IdentityUserStore.prototype.populate = function ()
{
this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID'));
};
module.exports = new IdentityUserStore();
}());

View file

@ -62,7 +62,7 @@
@import "FolderSystem.less";
@import "Filter.less";
@import "Languages.less";
@import "AddAccount.less";
@import "Account.less";
@import "OpenPgpKey.less";
@import "TwoFactor.less";
@import "Identity.less";
@ -85,8 +85,6 @@
@import "Settings.less";
@import "SettingsGeneral.less";
@import "SettingsAccounts.less";
@import "SettingsIdentity.less";
@import "SettingsIdentities.less";
@import "SettingsOpenPGP.less";
@import "SettingsFolders.less";
@import "SettingsThemes.less";

View file

@ -1,7 +1,7 @@
.popups {
.b-account-add-content {
.modal-header {
background-color: #fff;
}
}
}
.popups {
.b-account-add-content {
.modal-header {
background-color: #fff;
}
}
}

View file

@ -24,7 +24,7 @@
color: #aaa;
}
.account-img {
.account-img, .identity-img {
font-size: 12px;
margin-right: 5px;
}
@ -35,6 +35,14 @@
box-sizing: border-box;
line-height: 22px;
}
.identity-name {
display: inline-block;
word-break: break-all;
box-sizing: border-box;
line-height: 22px;
cursor: pointer;
}
}
.account-item {
@ -67,4 +75,31 @@
opacity: 0.5;
}
}
.identity-item {
.e-action {
cursor: pointer;
}
.button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
opacity: 0;
}
.delete-access {
&.button-delete {
visibility: visible;
margin-right: 0;
opacity: 1;
}
}
.delete-identity {
cursor: pointer;
opacity: 0.5;
}
}
}

View file

@ -1,66 +0,0 @@
.b-settings-identities {
.process-place {
text-align: center;
width: 600px;
padding: 14px 0;
}
.e-signature-place {
display: inline-block;
width: 680px;
width: 730px;
height: 250px;
}
.list-table {
width: 600px;
td {
padding: 4px 8px;
line-height: 30px;
}
.identity-img {
font-size: 12px;
margin-right: 5px;
}
.identity-name {
display: inline-block;
word-break: break-all;
box-sizing: border-box;
line-height: 22px;
cursor: pointer;
}
}
.identity-item {
.e-action {
cursor: pointer;
}
.button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
opacity: 0;
}
.delete-access {
&.button-delete {
visibility: visible;
margin-right: 0;
opacity: 1;
}
}
.delete-identity {
cursor: pointer;
opacity: 0.5;
}
}
}

View file

@ -1,9 +0,0 @@
.b-settings-identity {
.e-signature-place {
display: inline-block;
width: 680px;
width: 730px;
height: 250px;
}
}

View file

@ -21,9 +21,9 @@
* @constructor
* @extends AbstractView
*/
function AddAccountPopupView()
function AccountPopupView()
{
AbstractView.call(this, 'Popups', 'PopupsAddAccount');
AbstractView.call(this, 'Popups', 'PopupsAccount');
this.isNew = ko.observable(true);
@ -89,10 +89,10 @@
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AddAccountPopupView);
_.extend(AddAccountPopupView.prototype, AbstractView.prototype);
kn.extendAsViewModel(['View/Popup/Account', 'View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AccountPopupView);
_.extend(AccountPopupView.prototype, AbstractView.prototype);
AddAccountPopupView.prototype.clearPopup = function ()
AccountPopupView.prototype.clearPopup = function ()
{
this.isNew(true);
@ -106,7 +106,7 @@
this.submitError('');
};
AddAccountPopupView.prototype.onShow = function (oAccount)
AccountPopupView.prototype.onShow = function (oAccount)
{
this.clearPopup();
if (oAccount && oAccount.canBeEdit())
@ -116,11 +116,11 @@
}
};
AddAccountPopupView.prototype.onFocus = function ()
AccountPopupView.prototype.onFocus = function ()
{
this.emailFocus(true);
};
module.exports = AddAccountPopupView;
module.exports = AccountPopupView;
}());

View file

@ -33,6 +33,7 @@
Data = require('Storage/User/Data'),
Cache = require('Storage/User/Cache'),
Remote = require('Storage/User/Remote'),
Local = require('Storage/Client'),
ComposeAttachmentModel = require('Model/ComposeAttachment'),
@ -48,7 +49,30 @@
{
AbstractView.call(this, 'Popups', 'PopupsCompose');
var self = this;
var
self = this,
fEmailOutInHelper = function (self, oIdentity, sName, bIn) {
if (oIdentity && self && oIdentity[sName]() && (bIn ? true : self[sName]()))
{
var
sIdentityEmail = oIdentity[sName](),
aList = Utils.trim(self[sName]()).split(/[,]/)
;
aList = _.filter(aList, function (sEmail) {
sEmail = Utils.trim(sEmail);
return sEmail && Utils.trim(sIdentityEmail) !== sEmail;
});
if (bIn)
{
aList.push(sIdentityEmail);
}
self[sName](aList.join(','));
}
}
;
this.oEditor = null;
this.aDraftInfo = null;
@ -58,8 +82,6 @@
this.triggerForResize = _.bind(this.triggerForResize, this);
this.bCapaAdditionalIdentities = Settings.capa(Enums.Capa.AdditionalIdentities);
this.allowContacts = !!AppStore.contactsIsAllowed();
this.bSkipNextHide = false;
@ -76,8 +98,8 @@
this.to.focusTrigger = ko.observable(false);
this.cc = ko.observable('');
this.bcc = ko.observable('');
this.replyTo = ko.observable('');
this.subject = ko.observable('');
this.isHtml = ko.observable(false);
@ -97,6 +119,7 @@
this.showCc = ko.observable(false);
this.showBcc = ko.observable(false);
this.showReplyTo = ko.observable(false);
this.cc.subscribe(function (aValue) {
if (false === self.showCc() && 0 < aValue.length)
@ -112,6 +135,13 @@
}
}, this);
this.replyTo.subscribe(function (aValue) {
if (false === self.showReplyTo() && 0 < aValue.length)
{
self.showReplyTo(true);
}
}, this);
this.draftFolder = ko.observable('');
this.draftUid = ko.observable('');
this.sending = ko.observable(false);
@ -168,68 +198,63 @@
this.composeEditorArea = ko.observable(null);
this.identities = IdentityStore.identities;
this.defaultIdentityID = IdentityStore.defaultIdentityID;
this.currentIdentityID = ko.observable('');
this.currentIdentityString = ko.observable('');
this.currentIdentityResultEmail = ko.observable('');
this.identities = AccountStore.identities;
this.identitiesOptions = ko.computed(function () {
var aList = [{
'optValue': AccountStore.email(),
'optText': this.formattedFrom(false)
}];
_.each(IdentityStore.identities(), function (oItem) {
aList.push({
'optValue': oItem.id,
'optText': oItem.formattedNameForCompose()
});
return _.map(IdentityStore.identities(), function (oItem) {
return {
'optValue': oItem.id(),
'optText': oItem.formattedName()
};
});
return aList;
}, this);
ko.computed(function () {
this.currentIdentityID = ko.observable(
Local.get(Enums.ClientSideKeyName.ComposeLastIdentityID, ''));
this.currentIdentity = ko.computed(function () {
var
sResult = '',
sResultEmail = '',
oItem = null,
aList = IdentityStore.identities(),
sID = this.currentIdentityID()
sID = this.currentIdentityID(),
aList = IdentityStore.identities()
;
if (this.bCapaAdditionalIdentities && sID && sID !== AccountStore.email())
if (Utils.isArray(aList))
{
oItem = _.find(aList, function (oItem) {
return oItem && sID === oItem['id'];
return oItem && sID === oItem.id();
});
sResult = oItem ? oItem.formattedNameForCompose() : '';
sResultEmail = oItem ? oItem.formattedNameForEmail() : '';
if ('' === sResult && aList[0])
if (!oItem)
{
this.currentIdentityID(aList[0]['id']);
return '';
oItem = _.find(aList, function (oItem) {
return oItem && '' === oItem.id();
});
}
if (!oItem)
{
oItem = aList[0] ? aList[0] : null;
}
}
if ('' === sResult)
{
sResult = this.formattedFrom(false);
sResultEmail = this.formattedFrom(true);
return oItem ? oItem : null;
}, this);
this.currentIdentity.extend({'toggleSubscribe': [this,
function (oIdentity) {
fEmailOutInHelper(this, oIdentity, 'bcc');
fEmailOutInHelper(this, oIdentity, 'replyTo');
}, function (oIdentity) {
fEmailOutInHelper(this, oIdentity, 'bcc', true);
fEmailOutInHelper(this, oIdentity, 'replyTo', true);
}
]});
this.currentIdentityString(sResult);
this.currentIdentityResultEmail(sResultEmail);
return sResult;
this.currentIdentityView = ko.computed(function () {
var oItem = this.currentIdentity();
return oItem ? oItem.formattedName() : 'unknown';
}, this);
this.to.subscribe(function (sValue) {
@ -336,13 +361,14 @@
Remote.sendMessage(
this.sendMessageResponse,
this.currentIdentityID(),
this.draftFolder(),
this.draftUid(),
sSentFolder,
this.currentIdentityResultEmail(),
sTo,
this.cc(),
this.bcc(),
this.replyTo(),
this.subject(),
this.oEditor ? this.oEditor.isHtml() : false,
this.oEditor ? this.oEditor.getData(true) : '',
@ -374,13 +400,14 @@
Remote.saveMessage(
this.saveMessageResponse,
this.currentIdentityID(),
this.draftFolder(),
this.draftUid(),
FolderStore.draftFolder(),
this.currentIdentityResultEmail(),
this.to(),
this.cc(),
this.bcc(),
this.replyTo(),
this.subject(),
this.oEditor ? this.oEditor.isHtml() : false,
this.oEditor ? this.oEditor.getData(true) : '',
@ -434,6 +461,7 @@
this.showCc.subscribe(this.triggerForResize);
this.showBcc.subscribe(this.triggerForResize);
this.showReplyTo.subscribe(this.triggerForResize);
this.dropboxEnabled = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey;
@ -538,7 +566,7 @@
});
},
this.oEditor.getData(),
this.currentIdentityResultEmail(),
this.currentIdentity(),
this.to(),
this.cc(),
this.bcc()
@ -566,18 +594,23 @@
}
};
ComposePopupView.prototype.findIdentityIdByMessage = function (sComposeType, oMessage)
ComposePopupView.prototype.findIdentityByMessage = function (sComposeType, oMessage)
{
var
oIDs = {},
sResult = '',
sEmail = '',
sDefaultIdentityID = Local.get(Enums.ClientSideKeyName.ComposeLastIdentityID, ''),
aIdentities = IdentityStore.identities(),
oResultIdentity = null,
oIdentitiesCache = {},
fFindHelper = function (oItem) {
if (oItem && oItem.email && oIDs[oItem.email])
if (oResultIdentity)
{
sEmail = oItem.email;
sResult = oIDs[oItem.email];
return true;
}
if (!oResultIdentity && oItem && oItem.email && oIdentitiesCache[oItem.email])
{
oResultIdentity = oIdentitiesCache[oItem.email];
return true;
}
@ -585,14 +618,9 @@
}
;
if (this.bCapaAdditionalIdentities)
{
_.each(IdentityStore.identities(), function (oItem) {
oIDs[oItem.email()] = oItem['id'];
});
}
oIDs[AccountStore.email()] = AccountStore.email();
_.each(aIdentities, function (oItem) {
oIdentitiesCache[oItem.email()] = oItem;
});
if (oMessage)
{
@ -612,18 +640,26 @@
}
}
if ('' === sResult)
if (!oResultIdentity)
{
sResult = IdentityStore.defaultIdentityID();
oResultIdentity = _.find(aIdentities, function (oItem) {
return oItem.id() === sDefaultIdentityID;
});
}
if ('' === sResult)
if (!oResultIdentity && '' !== sDefaultIdentityID)
{
sResult = AccountStore.email();
sEmail = sResult;
oResultIdentity = _.find(aIdentities, function (oItem) {
return oItem.id() === '';
});
}
return [sResult, sEmail];
if (!oResultIdentity)
{
oResultIdentity = aIdentities[0] || null;
}
return oResultIdentity;
};
ComposePopupView.prototype.selectIdentity = function (oIdentity)
@ -631,28 +667,10 @@
if (oIdentity)
{
this.currentIdentityID(oIdentity.optValue);
Local.set(Enums.ClientSideKeyName.ComposeLastIdentityID, oIdentity.optValue);
}
};
/**
*
* @param {boolean=} bHeaderResult = false
* @returns {string}
*/
ComposePopupView.prototype.formattedFrom = function (bHeaderResult)
{
var
sDisplayName = AccountStore.displayName(),
sEmail = AccountStore.email()
;
return '' === sDisplayName ? sEmail :
((Utils.isUnd(bHeaderResult) ? false : !!bHeaderResult) ?
'"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' :
sDisplayName + ' (' + sEmail + ')')
;
};
ComposePopupView.prototype.sendMessageResponse = function (sResult, oData)
{
var
@ -964,7 +982,7 @@
sReplyTitle = '',
aResplyAllParts = [],
oExcludeEmail = {},
oIdResult = null,
oIdentity = null,
mEmail = AccountStore.email(),
sSignature = AccountStore.signature(),
aDownloads = [],
@ -1000,15 +1018,21 @@
oExcludeEmail[mEmail] = true;
}
oIdResult = this.findIdentityIdByMessage(sComposeType, oMessage);
if (oIdResult && oIdResult[0])
oIdentity = this.findIdentityByMessage(sComposeType, oMessage);
if (oIdentity)
{
oExcludeEmail[oIdResult[1]] = true;
this.currentIdentityID(oIdResult[0]);
oExcludeEmail[oIdentity.email()] = true;
this.currentIdentityID(oIdentity.id());
}
else
{
this.currentIdentityID('');
}
this.reset();
this.currentIdentityID.valueHasMutated(); // Populate BBC from Identity
if (Utils.isNonEmptyArray(aToEmails))
{
this.to(fEmailArrayToStringLineHelper(aToEmails));
@ -1089,6 +1113,7 @@
this.to(fEmailArrayToStringLineHelper(oMessage.to));
this.cc(fEmailArrayToStringLineHelper(oMessage.cc));
this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc));
this.replyTo(fEmailArrayToStringLineHelper(oMessage.replyTo));
this.bFromDraft = true;
@ -1107,6 +1132,7 @@
this.to(fEmailArrayToStringLineHelper(oMessage.to));
this.cc(fEmailArrayToStringLineHelper(oMessage.cc));
this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc));
this.replyTo(fEmailArrayToStringLineHelper(oMessage.replyTo));
this.subject(sSubject);
this.prepearMessageAttachments(oMessage, sComposeType);
@ -1963,6 +1989,7 @@
return 0 === this.to().length &&
0 === this.cc().length &&
0 === this.bcc().length &&
0 === this.replyTo().length &&
0 === this.subject().length &&
bWithoutAttach &&
(!this.oEditor || '' === this.oEditor.getData())
@ -1997,6 +2024,7 @@
this.showCc(false);
this.showBcc(false);
this.showReplyTo(false);
Utils.delegateRunOnDestroy(this.attachments());
this.attachments([]);

View file

@ -215,25 +215,17 @@
}
};
ComposeOpenPgpPopupView.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
ComposeOpenPgpPopupView.prototype.onShow = function (fCallback, sText, oIdentity, sTo, sCc, sBcc)
{
this.clearPopup();
var
oEmail = new EmailModel(),
sResultFromEmail = '',
aRec = []
aRec = [],
oEmail = new EmailModel()
;
this.resultCallback = fCallback;
oEmail.clear();
oEmail.mailsoParse(sFromEmail);
if ('' !== oEmail.email)
{
sResultFromEmail = oEmail.email;
}
if ('' !== sTo)
{
aRec.push(sTo);
@ -256,7 +248,7 @@
return '' === oEmail.email ? false : oEmail.email;
}));
this.from(sResultFromEmail);
this.from(oIdentity ? oIdentity.email() : '');
this.to(aRec);
this.text(sText);
};

View file

@ -10,9 +10,9 @@
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
HtmlEditor = require('Common/HtmlEditor'),
Remote = require('Storage/User/Remote'),
AccountStore = require('Stores/User/Account'),
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView')
@ -30,6 +30,9 @@
this.edit = ko.observable(false);
this.owner = ko.observable(false);
this.editor = null;
this.signatureDom = ko.observable(null);
this.email = ko.observable('').validateEmail();
this.email.focused = ko.observable(false);
this.name = ko.observable('');
@ -39,6 +42,8 @@
this.bcc = ko.observable('').validateSimpleEmail();
this.bcc.focused = ko.observable(false);
this.signature = ko.observable('');
// this.email.subscribe(function () {
// this.email.hasError(false);
// }, this);
@ -128,6 +133,11 @@
this.submitRequest(false);
this.submitError('');
if (this.editor)
{
this.editor.clear(false);
}
};
/**
@ -141,18 +151,58 @@
{
this.edit(true);
this.id = oIdentity.id;
this.id = oIdentity.id();
this.name(oIdentity.name());
this.email(oIdentity.email());
this.replyTo(oIdentity.replyTo());
this.bcc(oIdentity.bcc());
this.owner(this.id === AccountStore.email());
this.owner(this.id === '');
}
else
{
this.id = Utils.fakeMd5();
}
};
IdentityPopupView.prototype.onHide = function ()
{
this.clearPopup();
};
IdentityPopupView.prototype.setSignature = function (sSignature)
{
if (this.editor)
{
if (':HTML:' === sSignature.substr(0, 6))
{
this.editor.setHtml(sSignature.substr(6), false);
}
else
{
this.editor.setPlain(sSignature, false);
}
}
};
IdentityPopupView.prototype.onFocus = function ()
{
if (!this.editor && this.signatureDom())
{
var self = this;
this.editor = new HtmlEditor(self.signatureDom(), function () {
self.signature(
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
);
}, function () {
self.setSignature(self.signature());
});
}
else
{
this.setSignature(this.signature());
}
if (!this.owner())
{
this.email.focused(true);

View file

@ -74,7 +74,7 @@
{
if (this.capaAdditionalAccounts())
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/AddAccount'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
}
};

View file

@ -186,6 +186,7 @@
this.viewTo = ko.observable('');
this.viewCc = ko.observable('');
this.viewBcc = ko.observable('');
this.viewReplyTo = ko.observable('');
this.viewDate = ko.observable('');
this.viewSize = ko.observable('');
this.viewMoment = ko.observable('');
@ -267,6 +268,7 @@
this.viewTo(oMessage.toToLine(false));
this.viewCc(oMessage.ccToLine(false));
this.viewBcc(oMessage.bccToLine(false));
this.viewReplyTo(oMessage.replyToToLine(false));
this.viewDate(oMessage.fullFormatDateValue());
this.viewSize(oMessage.friendlySize());
this.viewMoment(oMessage.momentDate());