mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Improved additional account management
This commit is contained in:
parent
b057c4083e
commit
6b8020b8f5
15 changed files with 161 additions and 161 deletions
|
|
@ -420,10 +420,10 @@ class AppUser extends AbstractApp {
|
|||
|
||||
if (!iError) {
|
||||
const counts = {},
|
||||
sAccountEmail = AccountUserStore.email();
|
||||
let parentEmail = SettingsGet('ParentEmail') || sAccountEmail;
|
||||
accounts = oData.Result.Accounts,
|
||||
mainEmail = SettingsGet('MainEmail');
|
||||
|
||||
if (isArray(oData.Result.Accounts)) {
|
||||
if (isArray(accounts)) {
|
||||
AccountUserStore.accounts.forEach(oAccount =>
|
||||
counts[oAccount.email] = oAccount.count()
|
||||
);
|
||||
|
|
@ -431,10 +431,12 @@ class AppUser extends AbstractApp {
|
|||
delegateRunOnDestroy(AccountUserStore.accounts());
|
||||
|
||||
AccountUserStore.accounts(
|
||||
oData.Result.Accounts.map(
|
||||
sValue => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0)
|
||||
accounts.map(
|
||||
sValue => new AccountModel(sValue, counts[sValue])
|
||||
)
|
||||
);
|
||||
// accounts.length &&
|
||||
AccountUserStore.accounts.unshift(new AccountModel(mainEmail, counts[mainEmail], false));
|
||||
}
|
||||
|
||||
if (isArray(oData.Result.Identities)) {
|
||||
|
|
@ -442,9 +444,10 @@ class AppUser extends AbstractApp {
|
|||
|
||||
IdentityUserStore(
|
||||
oData.Result.Identities.map(identityData => {
|
||||
const id = pString(identityData.Id),
|
||||
email = pString(identityData.Email),
|
||||
identity = new IdentityModel(id, email);
|
||||
const identity = new IdentityModel(
|
||||
pString(identityData.Id),
|
||||
pString(identityData.Email)
|
||||
);
|
||||
|
||||
identity.name(pString(identityData.Name));
|
||||
identity.replyTo(pString(identityData.ReplyTo));
|
||||
|
|
@ -715,7 +718,6 @@ class AppUser extends AbstractApp {
|
|||
NotificationUserStore.enableDesktopNotification(!!SettingsGet('DesktopNotifications'));
|
||||
|
||||
AccountUserStore.email(SettingsGet('Email'));
|
||||
AccountUserStore.parentEmail(SettingsGet('ParentEmail'));
|
||||
|
||||
this.foldersReload(value => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -51,12 +51,6 @@ export const
|
|||
*/
|
||||
serverRequest = type => SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/0/',
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {string}
|
||||
*/
|
||||
change = email => serverRequest('Change') + encodeURIComponent(email) + '/',
|
||||
|
||||
/**
|
||||
* @param {string} lang
|
||||
* @param {boolean} isAdmin
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { change } from 'Common/Links';
|
||||
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
export class AccountModel extends AbstractModel {
|
||||
|
|
@ -8,23 +6,16 @@ export class AccountModel extends AbstractModel {
|
|||
* @param {boolean=} canBeDelete = true
|
||||
* @param {number=} count = 0
|
||||
*/
|
||||
constructor(email, canBeDelete = true, count = 0) {
|
||||
constructor(email, count = 0, isAdditional = true) {
|
||||
super();
|
||||
|
||||
this.email = email;
|
||||
|
||||
this.addObservables({
|
||||
count: count,
|
||||
count: count || 0,
|
||||
deleteAccess: false,
|
||||
canBeDeleted: !!canBeDelete
|
||||
isAdditional: isAdditional
|
||||
});
|
||||
this.canBeEdit = this.canBeDeleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
changeAccountLink() {
|
||||
return change(this.email);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
|
||||
import { AccountUserStore } from 'Stores/User/Account';
|
||||
import { IdentityUserStore } from 'Stores/User/Identity';
|
||||
|
|
@ -20,6 +20,7 @@ export class AccountsUserSettings /*extends AbstractViewSettings*/ {
|
|||
this.accounts = AccountUserStore.accounts;
|
||||
this.loading = AccountUserStore.loading;
|
||||
this.identities = IdentityUserStore;
|
||||
this.mainEmail = SettingsGet('MainEmail');
|
||||
|
||||
this.accountForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
this.identityForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
|
@ -30,7 +31,7 @@ export class AccountsUserSettings /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
|
||||
editAccount(account) {
|
||||
if (account && account.canBeEdit()) {
|
||||
if (account && account.isAdditional()) {
|
||||
showScreenPopup(AccountPopupView, [account]);
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +82,10 @@ export class AccountsUserSettings /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
|
||||
accountsAndIdentitiesAfterMove() {
|
||||
Remote.accountsAndIdentitiesSortOrder(null, AccountUserStore.getEmailAddresses(), IdentityUserStore.getIDS());
|
||||
Remote.accountsAndIdentitiesSortOrder(null,
|
||||
AccountUserStore.getEmailAddresses().filter(v => v != SettingsGet('MainEmail')),
|
||||
IdentityUserStore.getIDS()
|
||||
);
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const AccountUserStore = {
|
|||
accounts: ko.observableArray(),
|
||||
loading: ko.observable(false).extend({ debounce: 100 }),
|
||||
|
||||
getEmailAddresses: () => AccountUserStore.accounts.map(item => item ? item.email : null).filter(v => v),
|
||||
getEmailAddresses: () => AccountUserStore.accounts.map(item => item.email),
|
||||
|
||||
accountsUnreadCount: ko.computed(() => 0),
|
||||
// accountsUnreadCount: ko.computed(() => {
|
||||
|
|
@ -21,6 +21,5 @@ export const AccountUserStore = {
|
|||
|
||||
addObservablesTo(AccountUserStore, {
|
||||
email: '',
|
||||
parentEmail: '',
|
||||
signature: ''
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td + td {
|
||||
td + td + td {
|
||||
text-align: right;
|
||||
}
|
||||
td + td + td {
|
||||
td:first-child,
|
||||
td:last-child, {
|
||||
width: 1em;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class AccountPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onShow(account) {
|
||||
if (account && account.canBeEdit()) {
|
||||
if (account && account.isAdditional()) {
|
||||
this.isNew(false);
|
||||
this.email(account.email);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
|
|||
if (iError) {
|
||||
AccountUserStore.loading(false);
|
||||
alert(getNotification(iError).replace('%EMAIL%', account.email));
|
||||
if (account.canBeEdit()) {
|
||||
if (account.isAdditional()) {
|
||||
showScreenPopup(AccountPopupView, [account]);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue