Add asserts folder

Add @command decorator
This commit is contained in:
RainLoop Team 2016-09-03 02:19:37 +03:00
parent a60ffc06e1
commit 1526130bfc
44 changed files with 300 additions and 264 deletions

View file

@ -3,8 +3,7 @@ import ko from 'ko';
import _ from '_';
import {
trim, createCommand,
triggerAutocompleteInputChange
trim, triggerAutocompleteInputChange
} from 'Common/Utils';
import {StorageResultType, Notification, Magics} from 'Common/Enums';
@ -16,7 +15,7 @@ import Remote from 'Remote/Admin/Ajax';
import {getApp} from 'Helper/Apps/Admin';
import {view, ViewType, routeOff} from 'Knoin/Knoin';
import {view, command, ViewType, routeOff} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
@ -61,53 +60,52 @@ class LoginAdminView extends AbstractViewNext
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
}
this.submitCommand = createCommand(() => {
@command((self) => !self.submitRequest())
submitCommand() {
triggerAutocompleteInputChange();
triggerAutocompleteInputChange();
this.loginError(false);
this.passwordError(false);
this.loginError(false);
this.passwordError(false);
this.loginError('' === trim(this.login()));
this.passwordError('' === trim(this.password()));
this.loginError('' === trim(this.login()));
this.passwordError('' === trim(this.password()));
if (this.loginError() || this.passwordError())
if (this.loginError() || this.passwordError())
{
return false;
}
this.submitRequest(true);
Remote.adminLogin((sResult, oData) => {
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
{
return false;
}
this.submitRequest(true);
Remote.adminLogin((sResult, oData) => {
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
if (oData.Result)
{
if (oData.Result)
{
getApp().loginAndLogoutReload(true);
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(getNotification(oData.ErrorCode));
}
getApp().loginAndLogoutReload(true);
}
else
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(getNotification(Notification.UnknownError));
this.submitError(getNotification(oData.ErrorCode));
}
}
else
{
this.submitRequest(false);
this.submitError(getNotification(Notification.UnknownError));
}
}, this.login(), this.password());
}, this.login(), this.password());
return true;
}, () => !this.submitRequest());
return true;
}
onShow() {
routeOff();
_.delay(() => {

View file

@ -15,7 +15,6 @@ class AboutUserView extends AbstractViewNext
{
constructor() {
super();
this.version = ko.observable(Settings.appSettingsGet('version'));
}
}

View file

@ -46,15 +46,15 @@ class AbstractSystemDropDownUserView extends AbstractViewNext
this.addAccountClick = _.bind(this.addAccountClick, this);
Events.sub('audio.stop', () => AppStore.currentAudio(''));
Events.sub('audio.start', (sName) => AppStore.currentAudio(sName));
Events.sub('audio.start', (name) => AppStore.currentAudio(name));
}
stopPlay() {
Events.pub('audio.api.stop');
}
accountClick(oAccount, oEvent) {
if (oAccount && oEvent && !isUnd(oEvent.which) && 1 === oEvent.which)
accountClick(account, event) {
if (account && event && !isUnd(event.which) && 1 === event.which)
{
AccountStore.accounts.loading(true);
_.delay(() => AccountStore.accounts.loading(false), Magics.Time1s);

View file

@ -14,9 +14,7 @@ import {
import {
trim, inArray, pInt,
convertLangName,
createCommand, createCommandLegacy,
triggerAutocompleteInputChange
convertLangName, triggerAutocompleteInputChange
} from 'Common/Utils';
import {socialFacebook, socialGoogle, socialTwitter} from 'Common/Links';
@ -34,7 +32,7 @@ import Remote from 'Remote/User/Ajax';
import {getApp} from 'Helper/Apps/User';
import {view, ViewType, routeOff, showScreenPopup} from 'Knoin/Knoin';
import {view, command, ViewType, routeOff, showScreenPopup} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
@ -151,36 +149,10 @@ class LoginUserView extends AbstractViewNext
);
this.facebookLoginEnabled = ko.observable(false);
this.facebookCommand = createCommand(() => {
window.open(socialFacebook(), 'Facebook',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.facebookLoginEnabled());
this.googleLoginEnabled = ko.observable(false);
this.googleFastLoginEnabled = ko.observable(false);
this.googleCommand = createCommand(() => {
window.open(socialGoogle(), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.googleLoginEnabled());
this.googleFastCommand = createCommand(() => {
window.open(socialGoogle(true), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.googleFastLoginEnabled());
this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = createCommand(() => {
window.open(socialTwitter(), 'Twitter',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.twitterLoginEnabled());
this.socialLoginEnabled = ko.computed(() => {
const
bF = this.facebookLoginEnabled(),
@ -194,11 +166,33 @@ class LoginUserView extends AbstractViewNext
{
this.submitError(Settings.settingsGet('AdditionalLoginError'));
}
// commands // todo
this.submitCommand = createCommandLegacy(this, this.submitCommand, () => !this.submitRequest());
}
@command((self) => !self.submitRequest() && self.facebookLoginEnabled())
facebookCommand() {
window.open(socialFacebook(), 'Facebook', 'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}
@command((self) => !self.submitRequest() && self.googleLoginEnabled())
googleCommand() {
window.open(socialGoogle(), 'Google', 'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}
@command((self) => !self.submitRequest() && self.googleFastLoginEnabled())
googleFastCommand() {
window.open(socialGoogle(true), 'Google', 'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}
@command((self) => !self.submitRequest() && self.twitterLoginEnabled())
twitterCommand() {
window.open(socialTwitter(), 'Twitter', 'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}
@command((self) => !self.submitRequest())
submitCommand() {
triggerAutocompleteInputChange();
@ -383,10 +377,8 @@ class LoginUserView extends AbstractViewNext
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialAuthFast'));
switch (signMe)
{

View file

@ -26,7 +26,6 @@ import {
import {
noop,
noopFalse,
createCommand,
computedPagenatorHelper,
draggablePlace,
friendlySize,
@ -55,9 +54,11 @@ import Remote from 'Remote/User/Ajax';
import {getApp} from 'Helper/Apps/User';
import {view, ViewType, showScreenPopup, setHash} from 'Knoin/Knoin';
import {view, command, ViewType, showScreenPopup, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
const canBeMovedHelper = (self) => self.canBeMoved();
@view({
name: 'View/User/MailBox/MessageList',
type: ViewType.Right,
@ -226,63 +227,6 @@ class MessageListMailBoxUserView extends AbstractViewNext
this.canBeMoved = this.hasCheckedOrSelectedLines;
this.clearCommand = createCommand(() => {
if (Settings.capa(Capa.DangerousActions))
{
showScreenPopup(require('View/Popup/FolderClear'), [FolderStore.currentFolder()]);
}
});
this.multyForwardCommand = createCommand(() => {
if (Settings.capa(Capa.Composer))
{
showScreenPopup(require('View/Popup/Compose'), [
ComposeType.ForwardAsAttachment, MessageStore.messageListCheckedOrSelected()]);
}
}, this.canBeMoved);
this.deleteWithoutMoveCommand = createCommand(() => {
if (Settings.capa(Capa.DangerousActions))
{
getApp().deleteMessagesFromFolder(FolderType.Trash,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
}
}, this.canBeMoved);
this.deleteCommand = createCommand(() => {
getApp().deleteMessagesFromFolder(FolderType.Trash,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}, this.canBeMoved);
this.archiveCommand = createCommand(() => {
getApp().deleteMessagesFromFolder(FolderType.Archive,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}, this.canBeMoved);
this.spamCommand = createCommand(() => {
getApp().deleteMessagesFromFolder(FolderType.Spam,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}, this.canBeMoved);
this.notSpamCommand = createCommand(() => {
getApp().deleteMessagesFromFolder(FolderType.NotSpam,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}, this.canBeMoved);
this.moveCommand = createCommand(noop, this.canBeMoved);
this.reloadCommand = createCommand(() => {
if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload)
{
getApp().reloadMessageList(false, true);
}
});
this.quotaTooltip = _.bind(this.quotaTooltip, this);
this.selector = new Selector(
@ -340,16 +284,82 @@ class MessageListMailBoxUserView extends AbstractViewNext
});
}
hideLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
@command()
clearCommand() {
if (Settings.capa(Capa.DangerousActions))
{
showScreenPopup(require('View/Popup/FolderClear'), [FolderStore.currentFolder()]);
}
}
@command()
reloadCommand() {
if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload)
{
getApp().reloadMessageList(false, true);
}
}
@command(canBeMovedHelper)
multyForwardCommand() {
if (Settings.capa(Capa.Composer))
{
showScreenPopup(require('View/Popup/Compose'), [
ComposeType.ForwardAsAttachment, MessageStore.messageListCheckedOrSelected()]);
}
}
@command(canBeMovedHelper)
deleteWithoutMoveCommand() {
if (Settings.capa(Capa.DangerousActions))
{
getApp().deleteMessagesFromFolder(FolderType.Trash,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
}
}
@command(canBeMovedHelper)
deleteCommand() {
getApp().deleteMessagesFromFolder(FolderType.Trash,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}
@command(canBeMovedHelper)
archiveCommand() {
getApp().deleteMessagesFromFolder(FolderType.Archive,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}
@command(canBeMovedHelper)
spamCommand() {
getApp().deleteMessagesFromFolder(FolderType.Spam,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}
@command(canBeMovedHelper)
notSpamCommand() {
getApp().deleteMessagesFromFolder(FolderType.NotSpam,
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
}
@command(canBeMovedHelper)
moveCommand() {} // eslint-disable-line no-empty-function
hideLeft(item, event) {
event.preventDefault();
event.stopPropagation();
leftPanelDisabled(true);
}
showLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
showLeft(item, event) {
event.preventDefault();
event.stopPropagation();
leftPanelDisabled(false);
}

View file

@ -20,10 +20,10 @@ import {
} from 'Common/Globals';
import {
createCommand, inArray, trim, noop,
isNonEmptyArray, windowResize, windowResizeCallback,
inArray, isArray, isNonEmptyArray, trim, noop,
windowResize, windowResizeCallback, inFocus,
removeSelection, removeInFocus, mailToHelper,
inFocus, isArray
createCommand
} from 'Common/Utils';
import Audio from 'Common/Audio';
@ -52,7 +52,7 @@ import Promises from 'Promises/User/Ajax';
import {getApp} from 'Helper/Apps/User';
import {view, ViewType, showScreenPopup} from 'Knoin/Knoin';
import {view, command, ViewType, showScreenPopup} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
@ -66,10 +66,22 @@ class MessageViewMailBoxUserView extends AbstractViewNext
super();
let lastEmail = '';
const createCommandHelper = (type) => createCommand(() => {
this.lastReplyAction(type);
this.replyOrforward(type);
}, this.canBeRepliedOrForwarded);
const
createCommandReplyHelper = (type) => createCommand(() => {
this.lastReplyAction(type);
this.replyOrforward(type);
}, this.canBeRepliedOrForwarded),
createCommandActionHelper = (folderType, useFolder) => createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(
folderType, message.folderFullNameRaw, [message.uid], useFolder);
}
}, this.messageVisibility);
this.oDom = null;
this.oHeaderDom = null;
@ -214,71 +226,17 @@ class MessageViewMailBoxUserView extends AbstractViewNext
});
// commands
this.closeMessage = createCommand(() => {
MessageStore.message(null);
});
this.replyCommand = createCommandReplyHelper(ComposeType.Reply);
this.replyAllCommand = createCommandReplyHelper(ComposeType.ReplyAll);
this.forwardCommand = createCommandReplyHelper(ComposeType.Forward);
this.forwardAsAttachmentCommand = createCommandReplyHelper(ComposeType.ForwardAsAttachment);
this.editAsNewCommand = createCommandReplyHelper(ComposeType.EditAsNew);
this.replyCommand = createCommandHelper(ComposeType.Reply);
this.replyAllCommand = createCommandHelper(ComposeType.ReplyAll);
this.forwardCommand = createCommandHelper(ComposeType.Forward);
this.forwardAsAttachmentCommand = createCommandHelper(ComposeType.ForwardAsAttachment);
this.editAsNewCommand = createCommandHelper(ComposeType.EditAsNew);
this.messageVisibilityCommand = createCommand(noop, this.messageVisibility);
this.messageEditCommand = createCommand(() => {
this.editMessage();
}, this.messageVisibility);
this.deleteCommand = createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(FolderType.Trash,
message.folderFullNameRaw, [message.uid], true);
}
}, this.messageVisibility);
this.deleteWithoutMoveCommand = createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(FolderType.Trash,
message.folderFullNameRaw, [message.uid], false);
}
}, this.messageVisibility);
this.archiveCommand = createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(FolderType.Archive,
message.folderFullNameRaw, [message.uid], true);
}
}, this.messageVisibility);
this.spamCommand = createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(FolderType.Spam,
message.folderFullNameRaw, [message.uid], true);
}
}, this.messageVisibility);
this.notSpamCommand = createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions)
{
this.message(null);
getApp().deleteMessagesFromFolder(FolderType.NotSpam,
message.folderFullNameRaw, [message.uid], true);
}
}, this.messageVisibility);
this.deleteCommand = createCommandActionHelper(FolderType.Trash, true);
this.deleteWithoutMoveCommand = createCommandActionHelper(FolderType.Trash, false);
this.archiveCommand = createCommandActionHelper(FolderType.Archive, true);
this.spamCommand = createCommandActionHelper(FolderType.Spam, true);
this.notSpamCommand = createCommandActionHelper(FolderType.NotSpam, true);
this.dropboxEnabled = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey;
@ -430,18 +388,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext
() => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle()
);
this.goUpCommand = createCommand(() => {
Events.pub('mailbox.message-list.selector.go-up', [
Layout.NoPreview === this.layout() ? !!this.message() : true
]);
}, () => !this.messageListAndMessageViewLoading());
this.goDownCommand = createCommand(() => {
Events.pub('mailbox.message-list.selector.go-down', [
Layout.NoPreview === this.layout() ? !!this.message() : true
]);
}, () => !this.messageListAndMessageViewLoading());
Events.sub('mailbox.message-view.toggle-full-screen', () => {
this.toggleFullScreen();
});
@ -449,6 +395,33 @@ class MessageViewMailBoxUserView extends AbstractViewNext
this.attachmentPreview = _.bind(this.attachmentPreview, this);
}
@command()
closeMessageCommand() {
MessageStore.message(null);
}
@command((self) => self.messageVisibility())
messageVisibilityCommand() {} // eslint-disable-line no-empty-function
@command((self) => self.messageVisibility())
messageEditCommand() {
this.editMessage();
}
@command((self) => !self.messageListAndMessageViewLoading())
goUpCommand() {
Events.pub('mailbox.message-list.selector.go-up', [
Layout.NoPreview === this.layout() ? !!this.message() : true
]);
}
@command((self) => !self.messageListAndMessageViewLoading())
goDownCommand() {
Events.pub('mailbox.message-list.selector.go-down', [
Layout.NoPreview === this.layout() ? !!this.message() : true
]);
}
detectDomBackgroundColor(dom) {
let
limit = 5,

View file

@ -69,8 +69,8 @@ class MenuSettingsUserView extends AbstractViewNext
}, Magics.Time200ms));
}
link(sRoute) {
return settings(sRoute);
link(route) {
return settings(route);
}
backToMailBoxClick() {

View file

@ -29,16 +29,16 @@ class PaneSettingsUserView extends AbstractViewNext
MessageStore.message(null);
}
hideLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
hideLeft(item, event) {
event.preventDefault();
event.stopPropagation();
leftPanelDisabled(true);
}
showLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
showLeft(item, event) {
event.preventDefault();
event.stopPropagation();
leftPanelDisabled(false);
}