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

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