mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Restructure some popups to use <form>
This commit is contained in:
parent
169dbfecca
commit
b82d26b71b
7 changed files with 201 additions and 227 deletions
|
|
@ -2,7 +2,6 @@ import { getNotification } from 'Common/Translator';
|
|||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
export class AccountPopupView extends AbstractViewPopup {
|
||||
|
|
@ -26,39 +25,32 @@ export class AccountPopupView extends AbstractViewPopup {
|
|||
this.email.subscribe(() => this.emailError(false));
|
||||
|
||||
this.password.subscribe(() => this.passwordError(false));
|
||||
|
||||
decorateKoCommands(this, {
|
||||
addAccountCommand: self => !self.submitRequest()
|
||||
});
|
||||
}
|
||||
|
||||
addAccountCommand() {
|
||||
this.emailError(!this.email().trim());
|
||||
this.passwordError(!this.password().trim());
|
||||
|
||||
if (this.emailError() || this.passwordError()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.request('AccountSetup', (iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
this.submitErrorAdditional((data && data.ErrorMessageAdditional) || '');
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.closeCommand();
|
||||
}
|
||||
}, {
|
||||
Email: this.email(),
|
||||
Password: this.password(),
|
||||
New: this.isNew() ? 1 : 0
|
||||
submitForm() {
|
||||
if (!this.submitRequest()) {
|
||||
const email = this.email().trim(), pass = this.password();
|
||||
this.emailError(!email);
|
||||
this.passwordError(!pass);
|
||||
if (!this.emailError() && pass) {
|
||||
this.submitRequest(true);
|
||||
Remote.request('AccountSetup', (iError, data) => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
this.submitErrorAdditional((data && data.ErrorMessageAdditional) || '');
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.closeCommand();
|
||||
}
|
||||
}, {
|
||||
Email: email,
|
||||
Password: pass,
|
||||
New: this.isNew() ? 1 : 0
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
onShow(account) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import { SettingsUserStore } from 'Stores/User/Settings';
|
|||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
import { setFolder, getFolderFromCacheList } from 'Common/Cache';
|
||||
|
|
@ -42,48 +41,42 @@ export class FolderCreatePopupView extends AbstractViewPopup {
|
|||
);
|
||||
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
decorateKoCommands(this, {
|
||||
createFolderCommand: self => self.simpleFolderNameValidation(self.folderName())
|
||||
});
|
||||
}
|
||||
|
||||
createFolderCommand() {
|
||||
let parentFolderName = this.selectedParentValue();
|
||||
if (!parentFolderName && 1 < FolderUserStore.namespace.length) {
|
||||
parentFolderName = FolderUserStore.namespace.slice(0, FolderUserStore.namespace.length - 1);
|
||||
}
|
||||
submitForm() {
|
||||
if (/^[^\\/]+$/g.test(this.folderName())) {
|
||||
let parentFolderName = this.selectedParentValue();
|
||||
if (!parentFolderName && 1 < FolderUserStore.namespace.length) {
|
||||
parentFolderName = FolderUserStore.namespace.slice(0, FolderUserStore.namespace.length - 1);
|
||||
}
|
||||
|
||||
Remote.abort('Folders').post('FolderCreate', FolderUserStore.foldersCreating, {
|
||||
Folder: this.folderName(),
|
||||
Parent: parentFolderName,
|
||||
Subscribe: this.folderSubscribe() ? 1 : 0
|
||||
})
|
||||
.then(
|
||||
data => {
|
||||
const folder = getFolderFromCacheList(parentFolderName),
|
||||
subFolder = FolderModel.reviveFromJson(data.Result),
|
||||
folders = (folder ? folder.subFolders : FolderUserStore.folderList);
|
||||
setFolder(subFolder);
|
||||
folders.push(subFolder);
|
||||
sortFolders(folders);
|
||||
Remote.abort('Folders').post('FolderCreate', FolderUserStore.foldersCreating, {
|
||||
Folder: this.folderName(),
|
||||
Parent: parentFolderName,
|
||||
Subscribe: this.folderSubscribe() ? 1 : 0
|
||||
})
|
||||
.then(
|
||||
data => {
|
||||
const folder = getFolderFromCacheList(parentFolderName),
|
||||
subFolder = FolderModel.reviveFromJson(data.Result),
|
||||
folders = (folder ? folder.subFolders : FolderUserStore.folderList);
|
||||
setFolder(subFolder);
|
||||
folders.push(subFolder);
|
||||
sortFolders(folders);
|
||||
/*
|
||||
var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
|
||||
console.log((folder ? folder.subFolders : FolderUserStore.folderList).sort(collator.compare));
|
||||
var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
|
||||
console.log((folder ? folder.subFolders : FolderUserStore.folderList).sort(collator.compare));
|
||||
*/
|
||||
},
|
||||
error => {
|
||||
FolderUserStore.folderListError(
|
||||
getNotification(error.code, '', Notification.CantCreateFolder)
|
||||
+ '.\n' + error.message);
|
||||
}
|
||||
);
|
||||
},
|
||||
error => {
|
||||
FolderUserStore.folderListError(
|
||||
getNotification(error.code, '', Notification.CantCreateFolder)
|
||||
+ '.\n' + error.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.closeCommand();
|
||||
}
|
||||
|
||||
simpleFolderNameValidation(sName) {
|
||||
return /^[^\\/]+$/g.test(sName);
|
||||
this.closeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { getNotification } from 'Common/Translator';
|
|||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
const reEmail = /^[^@\s]+@[^@\s]+$/;
|
||||
|
|
@ -60,60 +59,57 @@ export class IdentityPopupView extends AbstractViewPopup {
|
|||
this.replyTo.valueHasMutated();
|
||||
this.bcc.valueHasMutated();
|
||||
*/
|
||||
decorateKoCommands(this, {
|
||||
addOrEditIdentityCommand: self => !self.submitRequest()
|
||||
});
|
||||
}
|
||||
|
||||
addOrEditIdentityCommand() {
|
||||
if (this.signature && this.signature.__fetchEditorValue) {
|
||||
this.signature.__fetchEditorValue();
|
||||
}
|
||||
|
||||
if (!this.emailHasError()) {
|
||||
this.emailHasError(!this.email().trim());
|
||||
}
|
||||
|
||||
if (this.emailHasError()) {
|
||||
if (!this.owner()) {
|
||||
this.emailFocused(true);
|
||||
submitForm() {
|
||||
if (!this.submitRequest()) {
|
||||
if (this.signature && this.signature.__fetchEditorValue) {
|
||||
this.signature.__fetchEditorValue();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!this.emailHasError()) {
|
||||
this.emailHasError(!this.email().trim());
|
||||
}
|
||||
|
||||
if (this.replyToHasError()) {
|
||||
this.replyToFocused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.bccHasError()) {
|
||||
this.bccFocused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.request('IdentityUpdate', iError => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.closeCommand();
|
||||
if (this.emailHasError()) {
|
||||
if (!this.owner()) {
|
||||
this.emailFocused(true);
|
||||
}
|
||||
}, {
|
||||
Id: this.id,
|
||||
Email: this.email(),
|
||||
Name: this.name(),
|
||||
ReplyTo: this.replyTo(),
|
||||
Bcc: this.bcc(),
|
||||
Signature: this.signature(),
|
||||
SignatureInsertBefore: this.signatureInsertBefore() ? 1 : 0
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.replyToHasError()) {
|
||||
this.replyToFocused(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.bccHasError()) {
|
||||
this.bccFocused(true);
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.request('IdentityUpdate', iError => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
this.submitError(getNotification(iError));
|
||||
} else {
|
||||
rl.app.accountsAndIdentities();
|
||||
this.closeCommand();
|
||||
}
|
||||
}, {
|
||||
Id: this.id,
|
||||
Email: this.email(),
|
||||
Name: this.name(),
|
||||
ReplyTo: this.replyTo(),
|
||||
Bcc: this.bcc(),
|
||||
Signature: this.signature(),
|
||||
SignatureInsertBefore: this.signatureInsertBefore() ? 1 : 0
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue