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

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