Add new "Move to folder" button

This commit is contained in:
RainLoop Team 2017-02-08 20:48:53 +03:00
parent 2c3881abc6
commit f0e9d1a6d5
14 changed files with 312 additions and 182 deletions

View file

@ -192,10 +192,23 @@ export const VIEW_MODELS = {
'settings-disabled': []
};
export const moveAction = ko.observable(false);
export const leftPanelDisabled = ko.observable(false);
export const leftPanelType = ko.observable('');
export const leftPanelWidth = ko.observable(0);
leftPanelDisabled.subscribe((value) => {
if (value && moveAction()) {
moveAction(false);
}
});
moveAction.subscribe((value) => {
if (value && leftPanelDisabled()) {
leftPanelDisabled(false);
}
});
// popups
export const popupVisibilityNames = ko.observableArray([]);

View file

@ -2,7 +2,7 @@
import _ from '_';
import {Focused, Capa, ClientSideKeyName, Magics} from 'Common/Enums';
import {leftPanelDisabled, leftPanelType, bMobileDevice} from 'Common/Globals';
import {$html, leftPanelDisabled, leftPanelType, moveAction, bMobileDevice} from 'Common/Globals';
import {pString, pInt, decodeURI, windowResizeCallback} from 'Common/Utils';
import {getFolderFromCacheList, getFolderFullNameRaw, getFolderInboxName} from 'Common/Cache';
import {i18n} from 'Common/Translator';
@ -141,6 +141,10 @@ class MailBoxUserScreen extends AbstractScreen
getApp().initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
});
}
$html.on('click', '#rl-right', () => {
moveAction(false);
});
}
/**

View file

@ -42,6 +42,7 @@ class GeneralAdminSettings
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
this.weakPassword = AppAdminStore.weakPassword;
this.newMoveToFolder = AppAdminStore.newMoveToFolder;
this.mainAttachmentLimit = ko.observable(pInt(settingsGet('AttachmentLimit')) / (Magics.BitLength1024 * Magics.BitLength1024)).extend({posInterer: 25});
@ -151,6 +152,12 @@ class GeneralAdminSettings
'AllowLanguagesOnSettings': boolToAjax(value)
});
});
this.newMoveToFolder.subscribe((value) => {
Remote.saveAdminConfig(null, {
'NewMoveToFolder': boolToAjax(value)
});
});
}, Magics.Time50ms);
}

View file

@ -8,6 +8,7 @@ class AbstractAppStore
constructor() {
this.allowLanguagesOnSettings = ko.observable(true);
this.allowLanguagesOnLogin = ko.observable(true);
this.newMoveToFolder = ko.observable(true);
this.interfaceAnimation = ko.observable(true);
@ -25,6 +26,7 @@ class AbstractAppStore
populate() {
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
this.newMoveToFolder(!!Settings.settingsGet('NewMoveToFolder'));
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));

View file

@ -1,7 +1,8 @@
import ko from 'ko';
import {Focused, KeyState} from 'Common/Enums';
import {keyScope} from 'Common/Globals';
import {keyScope, leftPanelDisabled} from 'Common/Globals';
import {isNonEmptyArray} from 'Common/Utils';
import * as Settings from 'Storage/Settings';
@ -17,17 +18,28 @@ class AppUserStore extends AbstractAppStore
this.focusedState = ko.observable(Focused.None);
const isMobile = Settings.appSettingsGet('mobile');
this.focusedState.subscribe((value) => {
switch (value)
{
case Focused.MessageList:
keyScope(KeyState.MessageList);
if (isMobile) {
leftPanelDisabled(true);
}
break;
case Focused.MessageView:
keyScope(KeyState.MessageView);
if (isMobile) {
leftPanelDisabled(true);
}
break;
case Focused.FolderList:
keyScope(KeyState.FolderList);
if (isMobile) {
leftPanelDisabled(false);
}
break;
default:
break;

View file

@ -4,6 +4,21 @@
.b-folders {
.move-action-content-wrapper {
z-index: -1;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: 0.05;
background-color: #fff;
background-size: 60px 60px;
background-image: linear-gradient(135deg, #000 25%, transparent 25%,
transparent 50%, #000 50%, #000 75%,
transparent 75%, transparent);
}
&.focused .b-content {
}

View file

@ -6,7 +6,7 @@ import key from 'key';
import {trim, isNormal, isArray, windowResize} from 'Common/Utils';
import {Capa, Focused, Layout, KeyState, EventKeyCode, Magics} from 'Common/Enums';
import {$html, leftPanelDisabled} from 'Common/Globals';
import {$html, leftPanelDisabled, moveAction} from 'Common/Globals';
import {mailBox, settings} from 'Common/Links';
import {setFolderHash} from 'Common/Cache';
@ -42,6 +42,8 @@ class FolderListMailBoxUserView extends AbstractViewNext
this.folderListSystem = FolderStore.folderListSystem;
this.foldersChanging = FolderStore.foldersChanging;
this.moveAction = moveAction;
this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;
this.leftPanelDisabled = leftPanelDisabled;
@ -71,6 +73,7 @@ class FolderListMailBoxUserView extends AbstractViewNext
isMobile = Settings.appSettingsGet('mobile'),
fSelectFolder = (el, event, starred) => {
const isMove = moveAction();
if (isMobile)
{
leftPanelDisabled(true);
@ -86,24 +89,39 @@ class FolderListMailBoxUserView extends AbstractViewNext
const folder = ko.dataFor(el);
if (folder)
{
if (Layout.NoPreview === SettingsStore.layout())
if (isMove)
{
MessageStore.message(null);
}
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
{
setFolderHash(folder.fullNameRaw, '');
}
if (starred)
{
setHash(mailBox(folder.fullNameHash, 1, 'is:flagged'));
moveAction(false);
getApp().moveMessagesToFolder(
FolderStore.currentFolderFullNameRaw(),
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
folder.fullNameRaw,
false
);
}
else
{
setHash(mailBox(folder.fullNameHash));
if (Layout.NoPreview === SettingsStore.layout())
{
MessageStore.message(null);
}
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
{
setFolderHash(folder.fullNameRaw, '');
}
if (starred)
{
setHash(mailBox(folder.fullNameHash, 1, 'is:flagged'));
}
else
{
setHash(mailBox(folder.fullNameHash));
}
}
AppStore.focusedState(Focused.MessageList);
}
};
@ -186,6 +204,7 @@ class FolderListMailBoxUserView extends AbstractViewNext
key('esc, tab, shift+tab, right', KeyState.FolderList, () => {
AppStore.focusedState(Focused.MessageList);
moveAction(false);
return false;
});

View file

@ -20,7 +20,8 @@ import {
import {
bMobileDevice,
popupVisibility,
leftPanelDisabled
leftPanelDisabled,
moveAction
} from 'Common/Globals';
import {
@ -76,6 +77,7 @@ class MessageListMailBoxUserView extends AbstractViewNext
this.iGoToUpUpOrDownDownTimeout = 0;
this.mobile = !!Settings.appSettingsGet('mobile');
this.newMoveToFolder = AppStore.newMoveToFolder;
this.allowReload = !!Settings.capa(Capa.Reload);
this.allowSearch = !!Settings.capa(Capa.Search);
@ -350,6 +352,30 @@ class MessageListMailBoxUserView extends AbstractViewNext
@command(canBeMovedHelper)
moveCommand() {} // eslint-disable-line no-empty-function
@command(canBeMovedHelper)
moveNewCommand(vm, event) {
if (this.newMoveToFolder() && this.mobileCheckedStateShow())
{
if (vm && event && event.preventDefault) {
event.preventDefault();
if (event.stopPropagation) {
event.stopPropagation();
}
}
if (moveAction())
{
AppStore.focusedState(Focused.MessageList);
moveAction(false);
}
else
{
AppStore.focusedState(Focused.FolderList);
moveAction(true);
}
}
}
hideLeft(item, event) {
event.preventDefault();
event.stopPropagation();
@ -869,7 +895,16 @@ class MessageListMailBoxUserView extends AbstractViewNext
{
// move
key('m', KeyState.MessageList, () => {
this.moveDropdownTrigger(true);
if (this.newMoveToFolder())
{
this.moveNewCommand();
}
else
{
this.moveDropdownTrigger(true);
}
return false;
});
}