From e6e0b0284952ff85799efa918c609009fd6d6e68 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Sat, 10 Sep 2016 01:38:16 +0300 Subject: [PATCH] Code refactoring Flow first look --- .eslintrc.js | 2 +- .flowconfig | 23 + dev/App/User.js | 9 +- dev/Common/Audio.js | 22 +- .../ClientStorageDriver/LocalStorage.js | 2 + dev/Common/Cmd.js | 46 +- dev/Common/HtmlEditor.js | 41 +- dev/Common/Selector.js | 36 +- dev/Common/Translator.js | 6 +- dev/Common/Utils.js | 18 +- dev/Component/AbstracCheckbox.js | 1 - dev/Component/AbstracRadio.js | 1 - dev/Component/Abstract.js | 4 +- dev/Component/AbstractInput.js | 1 - dev/Component/MaterialDesign/Checkbox.js | 1 - dev/Component/SaveTrigger.js | 1 - dev/Component/Script.js | 1 - dev/Component/Select.js | 1 - dev/Component/TextArea.js | 1 - dev/External/ko.js | 12 +- dev/Knoin/AbstractModel.js | 8 +- dev/Knoin/AbstractScreen.js | 12 +- dev/Knoin/AbstractViewNext.js | 18 +- dev/Knoin/Knoin.js | 80 +++- dev/Model/Email.js | 5 + dev/Promises/AbstractAjax.js | 4 +- dev/Promises/AbstractBasic.js | 4 +- dev/Screen/AbstractSettings.js | 3 +- dev/Settings/Admin/Contacts.js | 37 +- dev/Settings/Admin/Security.js | 57 +-- dev/Settings/User/ChangePassword.js | 44 +- dev/Settings/User/Filters.js | 80 ++-- dev/Settings/User/Social.js | 64 +-- dev/View/Popup/Account.js | 77 ++- dev/View/Popup/Activate.js | 83 ++-- dev/View/Popup/AddOpenPgpKey.js | 130 +++--- dev/View/Popup/AdvancedSearch.js | 30 +- dev/View/Popup/Ask.js | 7 +- dev/View/Popup/Compose.js | 437 +++++++++--------- dev/View/Popup/ComposeOpenPgp.js | 419 +++++++++-------- dev/View/Popup/Contacts.js | 309 +++++++------ dev/View/Popup/Domain.js | 160 +++---- dev/View/Popup/DomainAlias.js | 27 +- dev/View/Popup/Filter.js | 66 +-- dev/View/Popup/FolderClear.js | 74 ++- dev/View/Popup/FolderCreate.js | 44 +- dev/View/Popup/FolderSystem.js | 7 +- dev/View/Popup/Identity.js | 107 +++-- dev/View/Popup/KeyboardShortcutsHelp.js | 7 +- dev/View/Popup/Languages.js | 8 +- dev/View/Popup/MessageOpenPgp.js | 80 ++-- dev/View/Popup/NewOpenPgpKey.js | 96 ++-- dev/View/Popup/Plugin.js | 47 +- dev/View/Popup/Template.js | 73 ++- dev/View/Popup/TwoFactorConfiguration.js | 7 +- dev/View/Popup/TwoFactorTest.js | 33 +- dev/View/Popup/ViewOpenPgpKey.js | 7 +- dev/View/Popup/WelcomePage.js | 7 +- dev/View/User/MailBox/MessageView.js | 5 +- dev/admin.js | 2 +- dev/app.js | 2 +- dev/bootstrap.js | 2 +- gulpfile.js | 17 +- npm-shrinkwrap.json | 203 ++++++-- package.json | 2 +- .../templates/Views/User/PopupsFilter.html | 128 ++--- .../Views/User/PopupsFolderCreate.html | 84 ++-- .../Views/User/PopupsTwoFactorTest.html | 68 +-- .../templates/Views/User/SettingsFilters.html | 210 ++++----- .../templates/Views/User/SettingsSocial.html | 200 ++++---- webpack.config.builder.js | 18 +- 71 files changed, 2092 insertions(+), 1836 deletions(-) create mode 100644 .flowconfig diff --git a/.eslintrc.js b/.eslintrc.js index 7d71f359f..d8ad8233e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -90,7 +90,7 @@ module.exports = { 'no-lone-blocks': 2, 'no-loop-func': 2, // 'no-magic-numbers': [2, { -// 'ignore': [-1, 0, 1, 2], +// 'ignore': [-1, 0, 1, 2, 10, 100], // 'ignoreArrayIndexes': true // }], 'no-multi-spaces': 2, diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 000000000..b19212b15 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,23 @@ + +[ignore] +.*/node_modules/.* +.*/vendors/.* +.*/rainloop/.* +.*/plugins/.* +.*/build/.* +.*/asserts/.* + +[include] + +[libs] +./dev/ + +[options] +module.system=haste + +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable + +experimental.strict_type_args=true + +unsafe.enable_getters_and_setters=true diff --git a/dev/App/User.js b/dev/App/User.js index 457e708ec..cd3f4c66c 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -437,11 +437,12 @@ class AppUser extends AbstractApp const prom = Promises.foldersReload(FolderStore.foldersLoading); if (callback) { - prom.then((value) => { - callback(!!value); - }).catch(() => { + prom.then((value) => !!value).then(callback).catch(() => { _.delay(() => { - callback(false); + if (callback) + { + callback(false); // eslint-disable-line callback-return + } }, 1); }); } diff --git a/dev/Common/Audio.js b/dev/Common/Audio.js index 6fd5517fa..41acf17da 100644 --- a/dev/Common/Audio.js +++ b/dev/Common/Audio.js @@ -7,18 +7,20 @@ import {trim} from 'Common/Utils'; class Audio { + notificator = null; + player = null; + + supported = false; + supportedMp3 = false; + supportedOgg = false; + supportedWav = false; + supportedNotification = false; + constructor() { - this.notificator = null; - - this.supportedMp3 = false; - this.supportedOgg = false; - this.supportedWav = false; - this.supportedNotification = false; - this.player = this.createNewObject(); this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play; - if (this.supported && this.player.canPlayType) + if (this.supported && this.player && this.player.canPlayType) { this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, ''); this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, ''); @@ -35,7 +37,7 @@ class Audio this.supportedNotification = false; } - if (this.supported) + if (this.supported && this.player) { const stopFn = () => this.stop(); @@ -137,4 +139,4 @@ class Audio } } -module.exports = new Audio(); +export default new Audio(); diff --git a/dev/Common/ClientStorageDriver/LocalStorage.js b/dev/Common/ClientStorageDriver/LocalStorage.js index c90d6c089..c85613383 100644 --- a/dev/Common/ClientStorageDriver/LocalStorage.js +++ b/dev/Common/ClientStorageDriver/LocalStorage.js @@ -6,6 +6,8 @@ import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts'; class LocalStorageDriver { + s = null; + constructor() { this.s = window.localStorage || null; } diff --git a/dev/Common/Cmd.js b/dev/Common/Cmd.js index 17fdd771c..63e3a452f 100644 --- a/dev/Common/Cmd.js +++ b/dev/Common/Cmd.js @@ -4,7 +4,7 @@ import $ from '$'; import _ from '_'; import ko from 'ko'; import {$html, $body} from 'Common/Globals'; -import {EventKeyCode} from 'Common/Enums'; +import {EventKeyCode, Magics} from 'Common/Enums'; import {trim, inArray, changeTheme} from 'Common/Utils'; import {reload as translatorReload} from 'Common/Translator'; @@ -111,25 +111,28 @@ function cmdVersion() { class CmdContoller { + dom = null; + + opened = ko.observable(false); + cmd = ko.observable(''); + focused = ko.observable(false); + + themes = ThemeStore.themes; + + cmdHistory = []; + cmdHistoryShift = 0; + + cmdHelper = ko.observable(''); + + cmds = ['help', 'version', 'glass', 'clear', 'theme', 'lang']; + cmdsWithParameters = ['theme', 'lang']; + + isAdmin = false; + constructor(dom) { this.dom = dom; - - this.opened = ko.observable(false); - this.cmd = ko.observable(''); - this.focused = ko.observable(false); - - this.themes = ThemeStore.themes; - - this.cmdHistory = []; - this.cmdHistoryShift = 0; - - this.cmdHelper = ko.observable(''); - - this.cmds = ['help', 'version', 'glass', 'clear', 'theme', 'lang']; - this.cmdsWithParameters = ['theme', 'lang']; - - this.isAdmin = Settings.appSettingsGet('admin'); + this.isAdmin = !!Settings.appSettingsGet('admin'); } runCmd(cmd, params, isTab) { @@ -377,11 +380,14 @@ export function toggle() if (contoller.opened()) { _.delay(() => { - contoller.focused(true); - }, 50); + if (contoller && contoller.focused) + { + contoller.focused(true); + } + }, Magics.Time50ms); } } - }, 50); + }, Magics.Time50ms); } } diff --git a/dev/Common/HtmlEditor.js b/dev/Common/HtmlEditor.js index 13c64207c..1249e1bf9 100644 --- a/dev/Common/HtmlEditor.js +++ b/dev/Common/HtmlEditor.js @@ -3,13 +3,27 @@ import window from 'window'; import _ from '_'; import $ from '$'; import {htmlEditorDefaultConfig, htmlEditorLangsMap} from 'Common/Globals'; -import {EventKeyCode} from 'Common/Enums'; +import {EventKeyCode, Magics} from 'Common/Enums'; import * as Settings from 'Storage/Settings'; class HtmlEditor { + editor; + blurTimer = 0; + + __resizable = false; + __inited = false; + + onBlur = null; + onReady = null; + onModeChange = null; + + element; + $element; + + resize; + /** - * @constructor * @param {Object} element * @param {Function=} onBlur * @param {Function=} onReady @@ -17,9 +31,6 @@ class HtmlEditor */ constructor(element, onBlur = null, onReady = null, onModeChange = null) { - this.editor = null; - this.blurTimer = 0; - this.onBlur = onBlur; this.onReady = onReady; this.onModeChange = onModeChange; @@ -27,20 +38,25 @@ class HtmlEditor this.element = element; this.$element = $(element); - this.resize = _.throttle(_.bind(this.resize, this), 100); - - this.__inited = false; + this.resize = _.throttle(_.bind(this.resizeEditor, this), 100); this.init(); } + runOnBlur() { + if (this.onBlur) + { + this.onBlur(); + } + } + blurTrigger() { if (this.onBlur) { window.clearTimeout(this.blurTimer); this.blurTimer = window.setTimeout(() => { - this.onBlur(); - }, 200); + this.runOnBlur(); + }, Magics.Time200ms); } } @@ -198,8 +214,7 @@ class HtmlEditor if (this.editor && this.__inited && 'wysiwyg' === this.editor.mode) { try { - this.editor.setData( - this.editor.getData().replace(find, replaceHtml)); + this.editor.setData(this.editor.getData().replace(find, replaceHtml)); } catch (e) {} // eslint-disable-line no-empty } @@ -387,7 +402,7 @@ class HtmlEditor } } - resize() { + resizeEditor() { if (this.editor && this.__resizable) { try { diff --git a/dev/Common/Selector.js b/dev/Common/Selector.js index f969a2b0a..378a56688 100644 --- a/dev/Common/Selector.js +++ b/dev/Common/Selector.js @@ -8,8 +8,31 @@ import {isArray, inArray, noop, noopTrue} from 'Common/Utils'; class Selector { + list; + listChecked; + isListChecked; + + focusedItem; + selectedItem; + + itemSelectedThrottle; + + selectedItemUseCallback = true; + + iSelectNextHelper = 0; + iFocusedNextHelper = 0; + oContentVisible; + oContentScrollable; + + sItemSelector; + sItemSelectedSelector; + sItemCheckedSelector; + sItemFocusedSelector; + + sLastUid = ''; + oCallbacks = {}; + /** - * @constructor * @param {koProperty} koList * @param {koProperty} koSelectedItem * @param {koProperty} koFocusedItem @@ -28,7 +51,6 @@ class Selector this.focusedItem = koFocusedItem || ko.observable(null); this.selectedItem = koSelectedItem || ko.observable(null); - this.selectedItemUseCallback = true; this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300); @@ -79,19 +101,11 @@ class Selector this.selectedItem = this.selectedItem.extend({toggleSubscribeProperty: [this, 'selected']}); this.focusedItem = this.focusedItem.extend({toggleSubscribeProperty: [null, 'focused']}); - this.iSelectNextHelper = 0; - this.iFocusedNextHelper = 0; - this.oContentVisible = null; - this.oContentScrollable = null; - this.sItemSelector = sItemSelector; this.sItemSelectedSelector = sItemSelectedSelector; this.sItemCheckedSelector = sItemCheckedSelector; this.sItemFocusedSelector = sItemFocusedSelector; - this.sLastUid = ''; - this.oCallbacks = {}; - this.focusedItem.subscribe((item) => { if (item) { @@ -253,7 +267,7 @@ class Selector mFocused = null; mSelected = null; - }, this); + }); } itemSelected(item) { diff --git a/dev/Common/Translator.js b/dev/Common/Translator.js index 87a5f0cb0..e28ee8aaf 100644 --- a/dev/Common/Translator.js +++ b/dev/Common/Translator.js @@ -216,8 +216,10 @@ export function initOnStartOrLangChange(startCallback, langCallback = null) { startCallback(); } - - langCallback(); + if (langCallback) + { + langCallback(); + } }); } else if (startCallback) diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 793c93595..40cec8b3b 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -508,26 +508,16 @@ export function createCommandLegacy(context, fExecute, fCanExecute = true) if (isFunc(fCanExecute)) { - fResult.canExecute = ko.computed(() => fResult.enabled() && fCanExecute.call(context)); + fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(context)); } else { - fResult.canExecute = ko.computed(() => fResult.enabled() && !!fCanExecute); + fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute); } return fResult; } -/** - * @param {Function} fExecute - * @param {(Function|boolean|null)=} fCanExecute = true - * @returns {Function} - */ -export function createCommand(fExecute, fCanExecute = true) -{ - return createCommandLegacy(null, fExecute, fCanExecute); -} - /** * @param {string} theme * @returns {string} @@ -1264,8 +1254,8 @@ export function changeTheme(value, themeTrigger = noop) if (url) { url = url.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + value + '/-/'); - url = url.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/'); - url = url.toString().replace(/\/Hash\/[^\/]+\//, '/Hash/-/'); + url = url.replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/'); + url = url.replace(/\/Hash\/[^\/]+\//, '/Hash/-/'); if ('Json/' !== url.substring(url.length - 5, url.length)) { diff --git a/dev/Component/AbstracCheckbox.js b/dev/Component/AbstracCheckbox.js index f0951610f..bc853c37a 100644 --- a/dev/Component/AbstracCheckbox.js +++ b/dev/Component/AbstracCheckbox.js @@ -6,7 +6,6 @@ import {AbstractComponent} from 'Component/Abstract'; class AbstracCheckbox extends AbstractComponent { /** - * @constructor * @param {Object} params = {} */ constructor(params = {}) { diff --git a/dev/Component/AbstracRadio.js b/dev/Component/AbstracRadio.js index 49be11e24..bd084fd5a 100644 --- a/dev/Component/AbstracRadio.js +++ b/dev/Component/AbstracRadio.js @@ -7,7 +7,6 @@ import {AbstractComponent} from 'Component/Abstract'; class AbstracRadio extends AbstractComponent { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/Abstract.js b/dev/Component/Abstract.js index ae8fd6e97..e1bdebec1 100644 --- a/dev/Component/Abstract.js +++ b/dev/Component/Abstract.js @@ -5,9 +5,7 @@ import {isUnd} from 'Common/Utils'; class AbstractComponent { - constructor() { - this.disposable = []; - } + disposable = []; dispose() { this.disposable.forEach((funcToDispose) => { diff --git a/dev/Component/AbstractInput.js b/dev/Component/AbstractInput.js index 86067f235..157ca69e2 100644 --- a/dev/Component/AbstractInput.js +++ b/dev/Component/AbstractInput.js @@ -7,7 +7,6 @@ import {AbstractComponent} from 'Component/Abstract'; class AbstractInput extends AbstractComponent { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/MaterialDesign/Checkbox.js b/dev/Component/MaterialDesign/Checkbox.js index e975a04e2..a5c3f0bb6 100644 --- a/dev/Component/MaterialDesign/Checkbox.js +++ b/dev/Component/MaterialDesign/Checkbox.js @@ -7,7 +7,6 @@ import {AbstracCheckbox} from 'Component/AbstracCheckbox'; class CheckboxMaterialDesignComponent extends AbstracCheckbox { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/SaveTrigger.js b/dev/Component/SaveTrigger.js index b66cf00b7..e31de40c9 100644 --- a/dev/Component/SaveTrigger.js +++ b/dev/Component/SaveTrigger.js @@ -6,7 +6,6 @@ import {AbstractComponent, componentExportHelper} from 'Component/Abstract'; class SaveTriggerComponent extends AbstractComponent { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/Script.js b/dev/Component/Script.js index d70e2d28b..8edbe9105 100644 --- a/dev/Component/Script.js +++ b/dev/Component/Script.js @@ -5,7 +5,6 @@ import {AbstractComponent, componentExportHelper} from 'Component/Abstract'; class ScriptComponent extends AbstractComponent { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/Select.js b/dev/Component/Select.js index 444d809be..3a315c105 100644 --- a/dev/Component/Select.js +++ b/dev/Component/Select.js @@ -7,7 +7,6 @@ import {AbstractInput} from 'Component/AbstractInput'; class SelectComponent extends AbstractInput { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/Component/TextArea.js b/dev/Component/TextArea.js index 99ed82498..f881a0804 100644 --- a/dev/Component/TextArea.js +++ b/dev/Component/TextArea.js @@ -8,7 +8,6 @@ const DEFAULT_ROWS = 5; class TextAreaComponent extends AbstractInput { /** - * @constructor * @param {Object} params */ constructor(params) { diff --git a/dev/External/ko.js b/dev/External/ko.js index bfab0e838..bd3fd1ae4 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -581,7 +581,7 @@ ko.bindingHandlers.initFixedTrigger = { if ($container) { $win.resize(() => { - const offset = $container.offset(); + const offset = $container ? $container.offset() : null; if (offset && offset.top) { $el.css('top', offset.top + top); @@ -654,7 +654,10 @@ ko.bindingHandlers.draggable = { handle: '.dragHandle', cursorAt: {top: 22, left: 3}, refreshPositions: true, - scroll: true + scroll: true, + drag: null, + stop: null, + helper: null }; if (droppableSelector) @@ -733,7 +736,10 @@ ko.bindingHandlers.droppable = { fOutCallback = fAllValueFunc && fAllValueFunc.droppableOut ? fAllValueFunc.droppableOut : null, conf = { tolerance: 'pointer', - hoverClass: 'droppableHover' + hoverClass: 'droppableHover', + drop: null, + over: null, + out: null }; if (fValueFunc) diff --git a/dev/Knoin/AbstractModel.js b/dev/Knoin/AbstractModel.js index fb273ea9c..f170b123b 100644 --- a/dev/Knoin/AbstractModel.js +++ b/dev/Knoin/AbstractModel.js @@ -4,13 +4,15 @@ import {isArray, disposeObject} from 'Common/Utils'; class AbstractModel { + sModelName = ''; + disposables = []; + /** - * @param {string} modelName + * @param {string} modelName = '' */ - constructor(modelName) + constructor(modelName = '') { this.sModelName = modelName || ''; - this.disposables = []; } regDisposables(value) { diff --git a/dev/Knoin/AbstractScreen.js b/dev/Knoin/AbstractScreen.js index 1661774de..6d3acb373 100644 --- a/dev/Knoin/AbstractScreen.js +++ b/dev/Knoin/AbstractScreen.js @@ -5,9 +5,12 @@ import {isArray, isNonEmptyArray, noop} from 'Common/Utils'; class AbstractScreen { + oCross = null; + sScreenName; + aViewModels; + constructor(screenName, viewModels = []) { - this.oCross = null; this.sScreenName = screenName; this.aViewModels = isArray(viewModels) ? viewModels : []; } @@ -54,8 +57,11 @@ class AbstractScreen fMatcher = _.bind(this.onRoute || noop, this); route = crossroads.create(); - _.each(routes, (aItem) => { - route.addRoute(aItem[0], fMatcher).rules = aItem[1]; + _.each(routes, (item) => { + if (item && route) + { + route.addRoute(item[0], fMatcher).rules = item[1]; + } }); this.oCross = route; diff --git a/dev/Knoin/AbstractViewNext.js b/dev/Knoin/AbstractViewNext.js index c3db46c2c..6adc66eb2 100644 --- a/dev/Knoin/AbstractViewNext.js +++ b/dev/Knoin/AbstractViewNext.js @@ -7,18 +7,16 @@ import {$win, keyScope} from 'Common/Globals'; class AbstractViewNext { - constructor() { - this.bDisabeCloseOnEsc = false; - this.sDefaultKeyScope = KeyState.None; - this.sCurrentKeyScope = this.sDefaultKeyScope; + bDisabeCloseOnEsc = false; + sDefaultKeyScope = KeyState.None; + sCurrentKeyScope = KeyState.None; - this.viewModelVisibility = ko.observable(false); - this.modalVisibility = ko.observable(false).extend({rateLimit: 0}); + viewModelVisibility = ko.observable(false); + modalVisibility = ko.observable(false).extend({rateLimit: 0}); - this.viewModelName = ''; - this.viewModelNames = []; - this.viewModelDom = null; - } + viewModelName = ''; + viewModelNames = []; + viewModelDom = null; /** * @returns {void} diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 092159d01..69a7e7b02 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -10,7 +10,7 @@ import {$html, aViewModels as VIEW_MODELS, popupVisibilityNames} from 'Common/Gl import { isArray, isUnd, pString, log, isFunc, - createCommand, delegateRun, isNonEmptyArray + createCommandLegacy, delegateRun, isNonEmptyArray } from 'Common/Utils'; let @@ -35,6 +35,16 @@ export function hideLoading() $('#rl-loading').hide().remove(); } +/** + * @param {Function} fExecute + * @param {(Function|boolean|null)=} fCanExecute = true + * @returns {Function} + */ +export function createCommand(fExecute, fCanExecute = true) +{ + return createCommandLegacy(null, fExecute, fCanExecute); +} + /** * @param {Function} SettingsViewModelClass * @param {string} template @@ -98,15 +108,35 @@ export function screen(screenName) return ('' !== screenName && !isUnd(SCREENS[screenName])) ? SCREENS[screenName] : null; } +/** + * @param {Function} ViewModelClassToShow + * @returns {Function|null} + */ +export function getScreenPopup(PopuViewModelClass) +{ + let result = null; + if (PopuViewModelClass) + { + result = PopuViewModelClass; + if (PopuViewModelClass.default) + { + result = PopuViewModelClass.default; + } + } + + return result; +} + /** * @param {Function} ViewModelClassToHide * @returns {void} */ export function hideScreenPopup(ViewModelClassToHide) { - if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) + const ModalView = getScreenPopup(ViewModelClassToHide); + if (ModalView && ModalView.__vm && ModalView.__dom) { - ViewModelClassToHide.__vm.modalVisibility(false); + ModalView.__vm.modalVisibility(false); } } @@ -231,19 +261,20 @@ export function buildViewModel(ViewModelClass, vmScreen) */ export function showScreenPopup(ViewModelClassToShow, params = []) { - if (ViewModelClassToShow) + const ModalView = getScreenPopup(ViewModelClassToShow); + if (ModalView) { - buildViewModel(ViewModelClassToShow); + buildViewModel(ModalView); - if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) + if (ModalView.__vm && ModalView.__dom) { - delegateRun(ViewModelClassToShow.__vm, 'onBeforeShow', params || []); + delegateRun(ModalView.__vm, 'onBeforeShow', params || []); - ViewModelClassToShow.__vm.modalVisibility(true); + ModalView.__vm.modalVisibility(true); - delegateRun(ViewModelClassToShow.__vm, 'onShow', params || []); + delegateRun(ModalView.__vm, 'onShow', params || []); - vmRunHook('view-model-on-show', ViewModelClassToShow, params || []); + vmRunHook('view-model-on-show', ModalView, params || []); } } } @@ -254,13 +285,14 @@ export function showScreenPopup(ViewModelClassToShow, params = []) */ export function warmUpScreenPopup(ViewModelClassToShow) { - if (ViewModelClassToShow) + const ModalView = getScreenPopup(ViewModelClassToShow); + if (ModalView) { - buildViewModel(ViewModelClassToShow); + buildViewModel(ModalView); - if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) + if (ModalView.__vm && ModalView.__dom) { - delegateRun(ViewModelClassToShow.__vm, 'onWarmUp'); + delegateRun(ModalView.__vm, 'onWarmUp'); } } } @@ -271,7 +303,8 @@ export function warmUpScreenPopup(ViewModelClassToShow) */ export function isPopupVisible(ViewModelClassToShow) { - return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; + const ModalView = getScreenPopup(ViewModelClassToShow); + return ModalView && ModalView.__vm ? ModalView.__vm.modalVisibility() : false; } /** @@ -394,7 +427,7 @@ export function screenOnRoute(screenName, subPart) } // -- - cross = vmScreen.__cross ? vmScreen.__cross() : null; + cross = vmScreen && vmScreen.__cross ? vmScreen.__cross() : null; if (cross) { cross.parse(subPart); @@ -515,6 +548,15 @@ function viewDecorator({name, type, templateID}) }; } +/** + * @param {Object} params + * @returns {Function} + */ +function popupDecorator({name, templateID}) +{ + return viewDecorator({name, type: ViewType.Popup, templateID}); +} + /** * @param {Function} canExecute * @returns {Function} @@ -548,4 +590,8 @@ function commandDecorator(canExecute = true) }; } -export {commandDecorator, commandDecorator as command, viewDecorator, viewDecorator as view, viewDecorator as viewModel}; +export { + commandDecorator, commandDecorator as command, + viewDecorator, viewDecorator as view, viewDecorator as viewModel, + popupDecorator, popupDecorator as popup +}; diff --git a/dev/Model/Email.js b/dev/Model/Email.js index 126314be8..8cac4b118 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -3,6 +3,11 @@ import {trim, pString, encodeHtml} from 'Common/Utils'; class EmailModel { + email = ''; + name = ''; + dkimStatus = ''; + dkimValue = ''; + /** * @param {string=} email = '' * @param {string=} name = '' diff --git a/dev/Promises/AbstractAjax.js b/dev/Promises/AbstractAjax.js index 2b4fa4ae0..c609dcf44 100644 --- a/dev/Promises/AbstractAjax.js +++ b/dev/Promises/AbstractAjax.js @@ -14,9 +14,11 @@ import {AbstractBasicPromises} from 'Promises/AbstractBasic'; class AbstractAjaxPromises extends AbstractBasicPromises { + oRequests = {}; + constructor() { super(); - this.oRequests = {}; + this.clear(); } diff --git a/dev/Promises/AbstractBasic.js b/dev/Promises/AbstractBasic.js index 57a87b296..8dc62062a 100644 --- a/dev/Promises/AbstractBasic.js +++ b/dev/Promises/AbstractBasic.js @@ -5,9 +5,7 @@ import {isArray} from 'Common/Utils'; class AbstractBasicPromises { - constructor() { - this.oPromisesStack = {}; - } + oPromisesStack = {}; func(fFunc) { fFunc(); diff --git a/dev/Screen/AbstractSettings.js b/dev/Screen/AbstractSettings.js index e875bcab5..10c25a7a1 100644 --- a/dev/Screen/AbstractSettings.js +++ b/dev/Screen/AbstractSettings.js @@ -86,9 +86,10 @@ class AbstractSettingsScreen extends AbstractScreen RoutedSettingsViewModel.__builded = true; RoutedSettingsViewModel.__vm = settingsScreen; + const tmpl = {name: RoutedSettingsViewModel.__rlSettingsData.Template}; ko.applyBindingAccessorsToNode(viewModelDom[0], { translatorInit: true, - template: () => ({name: RoutedSettingsViewModel.__rlSettingsData.Template}) + template: () => tmpl }, settingsScreen); delegateRun(settingsScreen, 'onBuild', [viewModelDom]); diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index aa3a4c6ca..de09b4139 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -4,13 +4,15 @@ import ko from 'ko'; import { settingsSaveHelperSimpleFunction, - defautOptionsAfterRender, createCommand, + defautOptionsAfterRender, inArray, trim, boolToAjax } from 'Common/Utils'; import {SaveSettingsStep, StorageResultType, Magics} from 'Common/Enums'; import {i18n} from 'Common/Translator'; import {settingsGet} from 'Storage/Settings'; +import Remote from 'Remote/Admin/Ajax'; +import {command} from 'Knoin/Knoin'; class ContactsAdminSettings { @@ -21,7 +23,6 @@ class ContactsAdminSettings this.contactsSync = ko.observable(!!settingsGet('ContactsSync')); const - Remote = require('Remote/Admin/Ajax'), supportedTypes = [], types = ['sqlite', 'mysql', 'pgsql'], getTypeName = (name) => { @@ -111,27 +112,26 @@ class ContactsAdminSettings this.testContactsError = ko.observable(false); this.testContactsErrorMessage = ko.observable(''); - this.testContactsCommand = createCommand(() => { - - this.testContactsSuccess(false); - this.testContactsError(false); - this.testContactsErrorMessage(''); - this.testing(true); - - Remote.testContacts(this.onTestContactsResponse, { - 'ContactsPdoType': this.contactsType(), - 'ContactsPdoDsn': this.pdoDsn(), - 'ContactsPdoUser': this.pdoUser(), - 'ContactsPdoPassword': this.pdoPassword() - }); - - }, () => '' !== this.pdoDsn() && '' !== this.pdoUser()); - this.contactsType(settingsGet('ContactsPdoType')); this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); } + @command((self) => '' !== self.pdoDsn() && '' !== self.pdoUser()) + testContactsCommand() { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + this.testing(true); + + Remote.testContacts(this.onTestContactsResponse, { + 'ContactsPdoType': this.contactsType(), + 'ContactsPdoDsn': this.pdoDsn(), + 'ContactsPdoUser': this.pdoUser(), + 'ContactsPdoPassword': this.pdoPassword() + }); + } + onTestContactsResponse(result, data) { this.testContactsSuccess(false); this.testContactsError(false); @@ -166,7 +166,6 @@ class ContactsAdminSettings onBuild() { _.delay(() => { const - Remote = require('Remote/Admin/Ajax'), f1 = settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this), f3 = settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this), f4 = settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this), diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index 5af10f8d2..560b2a1c8 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -2,7 +2,7 @@ import _ from '_'; import ko from 'ko'; -import {createCommand, trim, boolToAjax} from 'Common/Utils'; +import {trim, boolToAjax} from 'Common/Utils'; import {phpInfo} from 'Common/Links'; import {StorageResultType, Magics} from 'Common/Enums'; @@ -13,6 +13,8 @@ import CapaAdminStore from 'Stores/Admin/Capa'; import Remote from 'Remote/Admin/Ajax'; +import {command} from 'Knoin/Knoin'; + class SecurityAdminSettings { constructor() { @@ -77,35 +79,36 @@ class SecurityAdminSettings this.adminPasswordNewError(false); }); - this.saveNewAdminPasswordCommand = createCommand(() => { - - if ('' === trim(this.adminLogin())) - { - this.adminLoginError(true); - return false; - } - - if (this.adminPasswordNew() !== this.adminPasswordNew2()) - { - this.adminPasswordNewError(true); - return false; - } - - this.adminPasswordUpdateError(false); - this.adminPasswordUpdateSuccess(false); - - Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, { - 'Login': this.adminLogin(), - 'Password': this.adminPassword(), - 'NewPassword': this.adminPasswordNew() - }); - - return true; - }, () => '' !== trim(this.adminLogin()) && '' !== this.adminPassword()); - this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); } + @command((self) => '' !== trim(self.adminLogin()) && '' !== self.adminPassword()) + saveNewAdminPasswordCommand() { + + if ('' === trim(this.adminLogin())) + { + this.adminLoginError(true); + return false; + } + + if (this.adminPasswordNew() !== this.adminPasswordNew2()) + { + this.adminPasswordNewError(true); + return false; + } + + this.adminPasswordUpdateError(false); + this.adminPasswordUpdateSuccess(false); + + Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, { + 'Login': this.adminLogin(), + 'Password': this.adminPassword(), + 'NewPassword': this.adminPasswordNew() + }); + + return true; + } + showTwoFactorDropper() { this.twoFactorDropperUser(''); this.isTwoFactorDropperShown(true); diff --git a/dev/Settings/User/ChangePassword.js b/dev/Settings/User/ChangePassword.js index 087011b0b..3b9db0841 100644 --- a/dev/Settings/User/ChangePassword.js +++ b/dev/Settings/User/ChangePassword.js @@ -3,12 +3,12 @@ import _ from '_'; import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; -import {createCommand} from 'Common/Utils'; import {getNotificationFromResponse, i18n} from 'Common/Translator'; import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; +import {command} from 'Knoin/Knoin'; class ChangePasswordUserSettings { @@ -43,30 +43,30 @@ class ChangePasswordUserSettings this.passwordMismatch(false); }); - this.saveNewPasswordCommand = createCommand(() => { - if (this.newPassword() !== this.newPassword2()) - { - this.passwordMismatch(true); - this.errorDescription(i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH')); - } - else - { - this.changeProcess(true); - - this.passwordUpdateError(false); - this.passwordUpdateSuccess(false); - this.currentPassword.error(false); - this.passwordMismatch(false); - this.errorDescription(''); - - Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); - } - - }, () => !this.changeProcess() && '' !== this.currentPassword() && '' !== this.newPassword() && '' !== this.newPassword2()); - this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this); } + @command((self) => !self.changeProcess() && '' !== self.currentPassword() && '' !== self.newPassword() && '' !== self.newPassword2()) + saveNewPasswordCommand() { + if (this.newPassword() !== this.newPassword2()) + { + this.passwordMismatch(true); + this.errorDescription(i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH')); + } + else + { + this.changeProcess(true); + + this.passwordUpdateError(false); + this.passwordUpdateSuccess(false); + this.currentPassword.error(false); + this.passwordMismatch(false); + this.errorDescription(''); + + Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); + } + } + onHide() { this.changeProcess(false); this.currentPassword(''); diff --git a/dev/Settings/User/Filters.js b/dev/Settings/User/Filters.js index 5a1f89e19..da05af366 100644 --- a/dev/Settings/User/Filters.js +++ b/dev/Settings/User/Filters.js @@ -2,20 +2,17 @@ import _ from '_'; import ko from 'ko'; +import {windowResizeCallback, isArray, trim, delegateRunOnDestroy} from 'Common/Utils'; import {StorageResultType, Notification} from 'Common/Enums'; import {getNotification} from 'Common/Translator'; -import { - windowResizeCallback, createCommand, isArray, trim, delegateRunOnDestroy -} from 'Common/Utils'; - -import {showScreenPopup} from 'Knoin/Knoin'; - import FilterStore from 'Stores/User/Filter'; import Remote from 'Remote/User/Ajax'; import {FilterModel} from 'Model/Filter'; +import {showScreenPopup, command} from 'Knoin/Knoin'; + class FiltersUserSettings { constructor() { @@ -46,41 +43,6 @@ class FiltersUserSettings this.filterForDeletion = ko.observable(null).deleteAccessHelper(); - this.saveChanges = createCommand(() => { - if (!this.filters.saving()) - { - if (this.filterRaw.active() && '' === trim(this.filterRaw())) - { - this.filterRaw.error(true); - return false; - } - - this.filters.saving(true); - this.saveErrorText(''); - - Remote.filtersSave((result, data) => { - this.filters.saving(false); - - if (StorageResultType.Success === result && data && data.Result) - { - this.haveChanges(false); - this.updateList(); - } - else if (data && data.ErrorCode) - { - this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode)); - } - else - { - this.saveErrorText(getNotification(Notification.CantSaveFilters)); - } - - }, this.filters(), this.filterRaw(), this.filterRaw.active()); - } - - return true; - }, () => this.haveChanges()); - this.filters.subscribe(() => { this.haveChanges(true); }); @@ -100,6 +62,42 @@ class FiltersUserSettings }); } + @command((self) => self.haveChanges()) + saveChangesCommand() { + if (!this.filters.saving()) + { + if (this.filterRaw.active() && '' === trim(this.filterRaw())) + { + this.filterRaw.error(true); + return false; + } + + this.filters.saving(true); + this.saveErrorText(''); + + Remote.filtersSave((result, data) => { + this.filters.saving(false); + + if (StorageResultType.Success === result && data && data.Result) + { + this.haveChanges(false); + this.updateList(); + } + else if (data && data.ErrorCode) + { + this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode)); + } + else + { + this.saveErrorText(getNotification(Notification.CantSaveFilters)); + } + + }, this.filters(), this.filterRaw(), this.filterRaw.active()); + } + + return true; + } + scrollableOptions(wrapper) { return { handle: '.drag-handle', diff --git a/dev/Settings/User/Social.js b/dev/Settings/User/Social.js index 31ec24b8b..a2a7b4977 100644 --- a/dev/Settings/User/Social.js +++ b/dev/Settings/User/Social.js @@ -1,10 +1,10 @@ -import {createCommand} from 'Common/Utils'; - import SocialStore from 'Stores/Social'; import {getApp} from 'Helper/Apps/User'; +import {command} from 'Knoin/Knoin'; + class SocialUserSettings { constructor() { @@ -29,39 +29,45 @@ class SocialUserSettings this.twitterActions = SocialStore.twitter.loading; this.twitterLoggined = SocialStore.twitter.loggined; this.twitterUserName = SocialStore.twitter.userName; + } - this.connectGoogle = createCommand(() => { - if (!this.googleLoggined()) - { - getApp().googleConnect(); - } - }, () => !this.googleLoggined() && !this.googleActions()); + @command((self) => !self.googleLoggined() && !self.googleActions()) + connectGoogleCommand() { + if (!this.googleLoggined()) + { + getApp().googleConnect(); + } + } - this.disconnectGoogle = createCommand(() => { - getApp().googleDisconnect(); - }); + @command() + disconnectGoogleCommand() { + getApp().googleDisconnect(); + } - this.connectFacebook = createCommand(() => { - if (!this.facebookLoggined()) - { - getApp().facebookConnect(); - } - }, () => !this.facebookLoggined() && !this.facebookActions()); + @command((self) => !self.facebookLoggined() && !self.facebookActions()) + connectFacebookCommand() { + if (!this.facebookLoggined()) + { + getApp().facebookConnect(); + } + } - this.disconnectFacebook = createCommand(() => { - getApp().facebookDisconnect(); - }); + @command() + disconnectFacebookCommand() { + getApp().facebookDisconnect(); + } - this.connectTwitter = createCommand(() => { - if (!this.twitterLoggined()) - { - getApp().twitterConnect(); - } - }, () => !this.twitterLoggined() && !this.twitterActions()); + @command((self) => !self.twitterLoggined() && !self.twitterActions()) + connectTwitterCommand() { + if (!this.twitterLoggined()) + { + getApp().twitterConnect(); + } + } - this.disconnectTwitter = createCommand(() => { - getApp().twitterDisconnect(); - }); + @command() + disconnectTwitterCommand() { + getApp().twitterDisconnect(); } } diff --git a/dev/View/Popup/Account.js b/dev/View/Popup/Account.js index b231d9484..9dc4dc16a 100644 --- a/dev/View/Popup/Account.js +++ b/dev/View/Popup/Account.js @@ -2,19 +2,18 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; -import {trim, createCommand} from 'Common/Utils'; +import {trim} from 'Common/Utils'; import {getNotification} from 'Common/Translator'; import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Account', - type: ViewType.Popup, templateID: 'PopupsAccount' }) class AccountPopupView extends AbstractViewNext @@ -43,51 +42,51 @@ class AccountPopupView extends AbstractViewNext this.submitErrorAdditional = ko.observable(''); this.emailFocus = ko.observable(false); + } - this.addAccountCommand = createCommand(() => { + @command((self) => !self.submitRequest()) + addAccountCommand() { - this.emailError('' === trim(this.email())); - this.passwordError('' === trim(this.password())); + this.emailError('' === trim(this.email())); + this.passwordError('' === trim(this.password())); - if (this.emailError() || this.passwordError()) + if (this.emailError() || this.passwordError()) + { + return false; + } + + this.submitRequest(true); + + Remote.accountSetup((result, data) => { + + this.submitRequest(false); + if (StorageResultType.Success === result && data) { - return false; - } - - this.submitRequest(true); - - Remote.accountSetup((result, data) => { - - this.submitRequest(false); - if (StorageResultType.Success === result && data) + if (data.Result) { - if (data.Result) - { - getApp().accountsAndIdentities(); - this.cancelCommand(); - } - else - { - this.submitError(data.ErrorCode ? getNotification(data.ErrorCode) : - getNotification(Notification.UnknownError)); - - if (data.ErrorMessageAdditional) - { - this.submitErrorAdditional(data.ErrorMessageAdditional); - } - } + getApp().accountsAndIdentities(); + this.cancelCommand(); } else { - this.submitError(getNotification(Notification.UnknownError)); - this.submitErrorAdditional(''); + this.submitError(data.ErrorCode ? getNotification(data.ErrorCode) : + getNotification(Notification.UnknownError)); + + if (data.ErrorMessageAdditional) + { + this.submitErrorAdditional(data.ErrorMessageAdditional); + } } + } + else + { + this.submitError(getNotification(Notification.UnknownError)); + this.submitErrorAdditional(''); + } - }, this.email(), this.password(), this.isNew()); + }, this.email(), this.password(), this.isNew()); - return true; - - }, () => !this.submitRequest()); + return true; } clearPopup() { @@ -118,4 +117,4 @@ class AccountPopupView extends AbstractViewNext } } -module.exports = AccountPopupView; +export {AccountPopupView, AccountPopupView as default}; diff --git a/dev/View/Popup/Activate.js b/dev/View/Popup/Activate.js index 06a0ba353..5f8f5a4b6 100644 --- a/dev/View/Popup/Activate.js +++ b/dev/View/Popup/Activate.js @@ -2,7 +2,7 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; -import {trim, isUnd, createCommand} from 'Common/Utils'; +import {trim, isUnd} from 'Common/Utils'; import {RAINLOOP_TRIAL_KEY} from 'Common/Consts'; import {i18n, getNotification} from 'Common/Translator'; @@ -11,12 +11,11 @@ import * as Settings from 'Storage/Settings'; import Remote from 'Remote/Admin/Ajax'; import LicenseStore from 'Stores/Admin/License'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Activate', - type: ViewType.Popup, templateID: 'PopupsActivate' }) class ActivatePopupView extends AbstractViewNext @@ -48,54 +47,54 @@ class ActivatePopupView extends AbstractViewNext this.licenseTrigger(!this.licenseTrigger()); } }); + } - this.activateCommand = createCommand(() => { + @command((self) => !self.activateProcess() && '' !== self.domain() && '' !== self.key() && !self.activationSuccessed()) + activateCommand() { - this.activateProcess(true); - if (this.validateSubscriptionKey()) - { - Remote.licensingActivate((sResult, oData) => { + this.activateProcess(true); + if (this.validateSubscriptionKey()) + { + Remote.licensingActivate((sResult, oData) => { - this.activateProcess(false); - if (StorageResultType.Success === sResult && oData.Result) + this.activateProcess(false); + if (StorageResultType.Success === sResult && oData.Result) + { + if (true === oData.Result) { - if (true === oData.Result) - { - this.activationSuccessed(true); - this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED')); - this.activateText.isError(false); - } - else - { - this.activateText(oData.Result); - this.activateText.isError(true); - this.key.focus(true); - } - } - else if (oData.ErrorCode) - { - this.activateText(getNotification(oData.ErrorCode)); - this.activateText.isError(true); - this.key.focus(true); + this.activationSuccessed(true); + this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED')); + this.activateText.isError(false); } else { - this.activateText(getNotification(Notification.UnknownError)); + this.activateText(oData.Result); this.activateText.isError(true); this.key.focus(true); } + } + else if (oData.ErrorCode) + { + this.activateText(getNotification(oData.ErrorCode)); + this.activateText.isError(true); + this.key.focus(true); + } + else + { + this.activateText(getNotification(Notification.UnknownError)); + this.activateText.isError(true); + this.key.focus(true); + } - }, this.domain(), this.key()); - } - else - { - this.activateProcess(false); - this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY')); - this.activateText.isError(true); - this.key.focus(true); - } - - }, () => !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed()); + }, this.domain(), this.key()); + } + else + { + this.activateProcess(false); + this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY')); + this.activateText.isError(true); + this.key.focus(true); + } } onShow(isTrial) { @@ -127,4 +126,4 @@ class ActivatePopupView extends AbstractViewNext } } -module.exports = ActivatePopupView; +export {ActivatePopupView, ActivatePopupView as default}; diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index 7c3ccbd35..91a636adf 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -1,17 +1,16 @@ import ko from 'ko'; -import {trim, delegateRun, createCommand, log} from 'Common/Utils'; +import {trim, delegateRun, log} from 'Common/Utils'; import PgpStore from 'Stores/User/Pgp'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/AddOpenPgpKey', - type: ViewType.Popup, templateID: 'PopupsAddOpenPgpKey' }) class AddOpenPgpKeyPopupView extends AbstractViewNext @@ -28,80 +27,81 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext this.key.error(false); this.key.errorMessage(''); }); + } - this.addOpenPgpKeyCommand = createCommand(() => { + @command() + addOpenPgpKeyCommand() { - const - reg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, - openpgpKeyring = PgpStore.openpgpKeyring; + const + reg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, + openpgpKeyring = PgpStore.openpgpKeyring; - let keyTrimmed = trim(this.key()); + let keyTrimmed = trim(this.key()); - if (/[\n]/.test(keyTrimmed)) + if (/[\n]/.test(keyTrimmed)) + { + keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n'); + } + + this.key.error('' === keyTrimmed); + this.key.errorMessage(''); + + if (!openpgpKeyring || this.key.error()) + { + return false; + } + + let + match = null, + count = 30, + done = false; + + do + { + match = reg.exec(keyTrimmed); + if (match && 0 < count) { - keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n'); - } - - this.key.error('' === keyTrimmed); - this.key.errorMessage(''); - - if (!openpgpKeyring || this.key.error()) - { - return false; - } - - let - match = null, - count = 30, - done = false; - - do - { - match = reg.exec(keyTrimmed); - if (match && 0 < count) + if (match[0] && match[1] && match[2] && match[1] === match[2]) { - if (match[0] && match[1] && match[2] && match[1] === match[2]) + let err = null; + if ('PRIVATE' === match[1]) { - let err = null; - if ('PRIVATE' === match[1]) - { - err = openpgpKeyring.privateKeys.importKey(match[0]); - } - else if ('PUBLIC' === match[1]) - { - err = openpgpKeyring.publicKeys.importKey(match[0]); - } - - if (err) - { - this.key.error(true); - this.key.errorMessage(err && err[0] ? '' + err[0] : ''); - log(err); - } + err = openpgpKeyring.privateKeys.importKey(match[0]); + } + else if ('PUBLIC' === match[1]) + { + err = openpgpKeyring.publicKeys.importKey(match[0]); } - count -= 1; - done = false; - } - else - { - done = true; + if (err) + { + this.key.error(true); + this.key.errorMessage(err && err[0] ? '' + err[0] : ''); + log(err); + } } + + count -= 1; + done = false; } - while (!done); - - openpgpKeyring.store(); - - getApp().reloadOpenPgpKeys(); - - if (this.key.error()) + else { - return false; + done = true; } + } + while (!done); - delegateRun(this, 'cancelCommand'); - return true; - }); + openpgpKeyring.store(); + + getApp().reloadOpenPgpKeys(); + + if (this.key.error()) + { + return false; + } + + delegateRun(this, 'cancelCommand'); + return true; } clearPopup() { @@ -119,4 +119,4 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext } } -module.exports = AddOpenPgpKeyPopupView; +export {AddOpenPgpKeyPopupView, AddOpenPgpKeyPopupView as default}; diff --git a/dev/View/Popup/AdvancedSearch.js b/dev/View/Popup/AdvancedSearch.js index 0044b8bc9..0437a1784 100644 --- a/dev/View/Popup/AdvancedSearch.js +++ b/dev/View/Popup/AdvancedSearch.js @@ -2,18 +2,17 @@ import _ from '_'; import ko from 'ko'; -import {trim, createCommand} from 'Common/Utils'; +import {trim} from 'Common/Utils'; import {i18n, trigger as translatorTrigger} from 'Common/Translator'; import {searchSubtractFormatDateHelper} from 'Common/Momentor'; import MessageStore from 'Stores/User/Message'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/AdvancedSearch', - type: ViewType.Popup, templateID: 'PopupsAdvancedSearch' }) class AdvancedSearchPopupView extends AbstractViewNext @@ -33,16 +32,6 @@ class AdvancedSearchPopupView extends AbstractViewNext this.starred = ko.observable(false); this.unseen = ko.observable(false); - this.searchCommand = createCommand(() => { - const search = this.buildSearchString(); - if ('' !== search) - { - MessageStore.mainMessageListSearch(search); - } - - this.cancelCommand(); - }); - this.selectedDates = ko.computed(() => { translatorTrigger(); return [ @@ -57,6 +46,17 @@ class AdvancedSearchPopupView extends AbstractViewNext }); } + @command() + searchCommand() { + const search = this.buildSearchString(); + if ('' !== search) + { + MessageStore.mainMessageListSearch(search); + } + + this.cancelCommand(); + } + parseSearchStringValue(search) { const parts = (search || '').split(/[\s]+/g); _.each(parts, (part) => { @@ -171,4 +171,4 @@ class AdvancedSearchPopupView extends AbstractViewNext } } -module.exports = AdvancedSearchPopupView; +export {AdvancedSearchPopupView, AdvancedSearchPopupView as default}; diff --git a/dev/View/Popup/Ask.js b/dev/View/Popup/Ask.js index e92f55b2e..04818a3fb 100644 --- a/dev/View/Popup/Ask.js +++ b/dev/View/Popup/Ask.js @@ -6,12 +6,11 @@ import {KeyState} from 'Common/Enums'; import {isFunc} from 'Common/Utils'; import {i18n} from 'Common/Translator'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Ask', - type: ViewType.Popup, templateID: 'PopupsAsk' }) class AskPopupView extends AbstractViewNext @@ -122,4 +121,4 @@ class AskPopupView extends AbstractViewNext } } -module.exports = AskPopupView; +export {AskPopupView, AskPopupView as default}; diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 952d844da..5d42e1730 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -13,7 +13,7 @@ import { } from 'Common/Enums'; import { - trim, isArray, isNormal, createCommand, delegateRun, + trim, isArray, isNormal, delegateRun, isNonEmptyArray, clearBqSwitcher, replySubjectAdd, encodeHtml, noopFalse, inFocus, delegateRunOnDestroy, pInt, isUnd @@ -46,12 +46,11 @@ import {ComposeAttachmentModel} from 'Model/ComposeAttachment'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType, isPopupVisible, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin'; +import {popup, command, isPopupVisible, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Compose', - type: ViewType.Popup, templateID: 'PopupsCompose' }) class ComposePopupView extends AbstractViewNext @@ -311,199 +310,9 @@ class ComposePopupView extends AbstractViewNext this.canBeSentOrSaved = ko.computed(() => !this.sending() && !this.saving()); - this.deleteCommand = createCommand(() => { - const PopupsAskViewModel = require('View/Popup/Ask'); - if (!isPopupVisible(PopupsAskViewModel) && this.modalVisibility()) - { - showScreenPopup(PopupsAskViewModel, [i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), () => { - if (this.modalVisibility()) - { - getApp().deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]); - hideScreenPopup(ComposePopupView); - } - }]); - } - - }, () => this.isDraftFolderMessage()); - this.sendMessageResponse = _.bind(this.sendMessageResponse, this); this.saveMessageResponse = _.bind(this.saveMessageResponse, this); - this.sendCommand = createCommand(() => { - - const - sTo = trim(this.to()), - sCc = trim(this.cc()), - sBcc = trim(this.bcc()); - let - sSentFolder = FolderStore.sentFolder(); - - this.attachmentsInProcessError(false); - this.attachmentsInErrorError(false); - this.emptyToError(false); - - if (0 < this.attachmentsInProcess().length) - { - this.attachmentsInProcessError(true); - this.attachmentsPlace(true); - } - else if (0 < this.attachmentsInError().length) - { - this.attachmentsInErrorError(true); - this.attachmentsPlace(true); - } - - if ('' === sTo && '' === sCc && '' === sBcc) - { - this.emptyToError(true); - } - - if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) - { - if (SettingsStore.replySameFolder()) - { - if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length) - { - sSentFolder = this.aDraftInfo[2]; - } - } - - if (!this.allowFolders) - { - sSentFolder = UNUSED_OPTION_VALUE; - } - - if ('' === sSentFolder) - { - showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Sent]); - } - else - { - this.sendError(false); - this.sending(true); - - if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) - { - const flagsCache = getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]); - if (flagsCache) - { - if ('forward' === this.aDraftInfo[0]) - { - flagsCache[3] = true; - } - else - { - flagsCache[2] = true; - } - - setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache); - getApp().reloadFlagsCurrentMessageListAndMessageFromCache(); - setFolderHash(this.aDraftInfo[2], ''); - } - } - - sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder; - - setFolderHash(this.draftFolder(), ''); - setFolderHash(sSentFolder, ''); - - Remote.sendMessage( - this.sendMessageResponse, - this.currentIdentity() ? this.currentIdentity().id() : '', - this.draftFolder(), - this.draftUid(), - sSentFolder, - sTo, - this.cc(), - this.bcc(), - this.replyTo(), - this.subject(), - this.oEditor ? this.oEditor.isHtml() : false, - this.oEditor ? this.oEditor.getData(true) : '', - this.prepearAttachmentsForSendOrSave(), - this.aDraftInfo, - this.sInReplyTo, - this.sReferences, - this.requestDsn(), - this.requestReadReceipt(), - this.markAsImportant() - ); - } - } - - }, this.canBeSentOrSaved); - - this.saveCommand = createCommand(() => { - - if (!this.allowFolders) - { - return false; - } - - if (FolderStore.draftFolderNotEnabled()) - { - showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Draft]); - } - else - { - this.savedError(false); - this.saving(true); - - this.autosaveStart(); - - setFolderHash(FolderStore.draftFolder(), ''); - - Remote.saveMessage( - this.saveMessageResponse, - this.currentIdentity() ? this.currentIdentity().id() : '', - this.draftFolder(), - this.draftUid(), - FolderStore.draftFolder(), - this.to(), - this.cc(), - this.bcc(), - this.replyTo(), - this.subject(), - this.oEditor ? this.oEditor.isHtml() : false, - this.oEditor ? this.oEditor.getData(true) : '', - this.prepearAttachmentsForSendOrSave(), - this.aDraftInfo, - this.sInReplyTo, - this.sReferences, - this.markAsImportant() - ); - } - - return true; - - }, this.canBeSentOrSaved); - - this.skipCommand = createCommand(() => { - - this.bSkipNextHide = true; - - if (this.modalVisibility() && !this.saving() && !this.sending() && - !FolderStore.draftFolderNotEnabled()) - { - this.saveCommand(); - } - - this.tryToClosePopup(); - - }, this.canBeSentOrSaved); - - this.contactsCommand = createCommand(() => { - - if (this.allowContacts) - { - this.skipCommand(); - _.delay(() => { - showScreenPopup(require('View/Popup/Contacts'), [true, this.sLastFocusedField]); - }, Magics.Time200ms); - } - - }, () => this.allowContacts); - Events.sub('interval.2m', () => { if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && !this.savedError()) @@ -519,37 +328,12 @@ class ComposePopupView extends AbstractViewNext this.dropboxEnabled = SocialStore.dropbox.enabled; this.dropboxApiKey = SocialStore.dropbox.apiKey; - this.dropboxCommand = createCommand(() => { - - if (window.Dropbox) - { - window.Dropbox.choose({ - success: (files) => { - if (files && files[0] && files[0].link) - { - this.addDropboxAttachment(files[0]); - } - }, - linkType: 'direct', - multiselect: false - }); - } - - return true; - - }, () => this.dropboxEnabled()); - this.driveEnabled = ko.observable(bXMLHttpRequestSupported && !!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialDrive') && !!Settings.settingsGet('GoogleClientID') && !!Settings.settingsGet('GoogleApiKey')); this.driveVisible = ko.observable(false); - this.driveCommand = createCommand(() => { - this.driveOpenPopup(); - return true; - }, () => this.driveEnabled()); - this.driveCallback = _.bind(this.driveCallback, this); this.onMessageUploadAttachments = _.bind(this.onMessageUploadAttachments, this); @@ -565,6 +349,219 @@ class ComposePopupView extends AbstractViewNext this.iTimer = 0; } + @command((self) => self.canBeSentOrSaved()) + sendCommand() { + + const + sTo = trim(this.to()), + sCc = trim(this.cc()), + sBcc = trim(this.bcc()); + let + sSentFolder = FolderStore.sentFolder(); + + this.attachmentsInProcessError(false); + this.attachmentsInErrorError(false); + this.emptyToError(false); + + if (0 < this.attachmentsInProcess().length) + { + this.attachmentsInProcessError(true); + this.attachmentsPlace(true); + } + else if (0 < this.attachmentsInError().length) + { + this.attachmentsInErrorError(true); + this.attachmentsPlace(true); + } + + if ('' === sTo && '' === sCc && '' === sBcc) + { + this.emptyToError(true); + } + + if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) + { + if (SettingsStore.replySameFolder()) + { + if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length) + { + sSentFolder = this.aDraftInfo[2]; + } + } + + if (!this.allowFolders) + { + sSentFolder = UNUSED_OPTION_VALUE; + } + + if ('' === sSentFolder) + { + showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Sent]); + } + else + { + this.sendError(false); + this.sending(true); + + if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) + { + const flagsCache = getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]); + if (flagsCache) + { + if ('forward' === this.aDraftInfo[0]) + { + flagsCache[3] = true; + } + else + { + flagsCache[2] = true; + } + + setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache); + getApp().reloadFlagsCurrentMessageListAndMessageFromCache(); + setFolderHash(this.aDraftInfo[2], ''); + } + } + + sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder; + + setFolderHash(this.draftFolder(), ''); + setFolderHash(sSentFolder, ''); + + Remote.sendMessage( + this.sendMessageResponse, + this.currentIdentity() ? this.currentIdentity().id() : '', + this.draftFolder(), + this.draftUid(), + sSentFolder, + sTo, + this.cc(), + this.bcc(), + this.replyTo(), + this.subject(), + this.oEditor ? this.oEditor.isHtml() : false, + this.oEditor ? this.oEditor.getData(true) : '', + this.prepearAttachmentsForSendOrSave(), + this.aDraftInfo, + this.sInReplyTo, + this.sReferences, + this.requestDsn(), + this.requestReadReceipt(), + this.markAsImportant() + ); + } + } + } + + @command((self) => self.canBeSentOrSaved()) + saveCommand() { + + if (!this.allowFolders) + { + return false; + } + + if (FolderStore.draftFolderNotEnabled()) + { + showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Draft]); + } + else + { + this.savedError(false); + this.saving(true); + + this.autosaveStart(); + + setFolderHash(FolderStore.draftFolder(), ''); + + Remote.saveMessage( + this.saveMessageResponse, + this.currentIdentity() ? this.currentIdentity().id() : '', + this.draftFolder(), + this.draftUid(), + FolderStore.draftFolder(), + this.to(), + this.cc(), + this.bcc(), + this.replyTo(), + this.subject(), + this.oEditor ? this.oEditor.isHtml() : false, + this.oEditor ? this.oEditor.getData(true) : '', + this.prepearAttachmentsForSendOrSave(), + this.aDraftInfo, + this.sInReplyTo, + this.sReferences, + this.markAsImportant() + ); + } + + return true; + } + + @command((self) => self.isDraftFolderMessage()) + deleteCommand() { + const PopupsAskViewModel = require('View/Popup/Ask'); + if (!isPopupVisible(PopupsAskViewModel) && this.modalVisibility()) + { + showScreenPopup(PopupsAskViewModel, [i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), () => { + if (this.modalVisibility()) + { + getApp().deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]); + hideScreenPopup(ComposePopupView); + } + }]); + } + } + + @command((self) => self.canBeSentOrSaved()) + skipCommand() { + + this.bSkipNextHide = true; + + if (this.modalVisibility() && !this.saving() && !this.sending() && + !FolderStore.draftFolderNotEnabled()) + { + this.saveCommand(); + } + + this.tryToClosePopup(); + } + + @command((self) => self.allowContacts) + contactsCommand() { + if (this.allowContacts) + { + this.skipCommand(); + _.delay(() => { + showScreenPopup(require('View/Popup/Contacts'), [true, this.sLastFocusedField]); + }, Magics.Time200ms); + } + } + + @command((self) => self.dropboxEnabled()) + dropboxCommand() { + if (window.Dropbox) + { + window.Dropbox.choose({ + success: (files) => { + if (files && files[0] && files[0].link) + { + this.addDropboxAttachment(files[0]); + } + }, + linkType: 'direct', + multiselect: false + }); + } + return true; + } + + @command((self) => self.driveEnabled()) + driveCommand() { + this.driveOpenPopup(); + return true; + } + autosaveFunction() { if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && !this.savedError()) @@ -1991,4 +1988,4 @@ class ComposePopupView extends AbstractViewNext } } -module.exports = ComposePopupView; +export {ComposePopupView, ComposePopupView as default}; diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index c217548bc..0324c098b 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -5,8 +5,7 @@ import ko from 'ko'; import key from 'key'; import { - inArray, createCommand, - pString, log, isUnd, trim, + inArray, pString, log, isUnd, trim, defautOptionsAfterRender } from 'Common/Utils'; @@ -17,14 +16,13 @@ import PgpStore from 'Stores/User/Pgp'; import {EmailModel} from 'Model/Email'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; const KEY_NAME_SUBSTR = -8; -@view({ +@popup({ name: 'View/Popup/ComposeOpenPgp', - type: ViewType.Popup, templateID: 'PopupsComposeOpenPgp' }) class ComposeOpenPgpPopupView extends AbstractViewNext @@ -92,210 +90,6 @@ class ComposeOpenPgpPopupView extends AbstractViewNext this.resultCallback = null; - // commands - this.doCommand = createCommand(() => { - - let - result = true, - privateKey = null, - aPublicKeys = []; - - this.submitRequest(true); - - if (result && this.sign()) - { - if (!this.signKey()) - { - this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND')); - result = false; - } - else if (!this.signKey().key) - { - this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', { - 'EMAIL': this.signKey().email - })); - - result = false; - } - - if (result) - { - const privateKeys = this.signKey().key.getNativeKeys(); - privateKey = privateKeys[0] || null; - - try - { - if (privateKey) - { - privateKey.decrypt(pString(this.password())); - } - } - catch (e) - { - privateKey = null; - } - - if (!privateKey) - { - this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND')); - result = false; - } - } - } - - if (result && this.encrypt()) - { - if (0 === this.encryptKeys().length) - { - this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND')); - result = false; - } - else if (this.encryptKeys()) - { - aPublicKeys = []; - - _.each(this.encryptKeys(), (oKey) => { - if (oKey && oKey.key) - { - aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys()))); - } - else if (oKey && oKey.email) - { - this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', { - 'EMAIL': oKey.email - })); - - result = false; - } - }); - - if (result && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length)) - { - result = false; - } - } - } - - if (result && this.resultCallback) - { - _.delay(() => { - - let pgpPromise = null; - - try - { - if (privateKey && 0 === aPublicKeys.length) - { - pgpPromise = PgpStore.openpgp.sign({ - data: this.text(), - privateKeys: [privateKey] - }); - } - else if (privateKey && 0 < aPublicKeys.length) - { - pgpPromise = PgpStore.openpgp.encrypt({ - data: this.text(), - publicKeys: aPublicKeys, - privateKeys: [privateKey] - }); - } - else if (!privateKey && 0 < aPublicKeys.length) - { - pgpPromise = PgpStore.openpgp.encrypt({ - data: this.text(), - publicKeys: aPublicKeys - }); - } - } - catch (e) - { - log(e); - - this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { - 'ERROR': '' + e - })); - } - - if (pgpPromise) - { - try - { - pgpPromise.then((mData) => { - this.resultCallback(mData.data); - this.cancelCommand(); - }).catch((e) => { - this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { - 'ERROR': '' + e - })); - }); - } - catch (e) - { - this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { - 'ERROR': '' + e - })); - } - } - - this.submitRequest(false); - - }, Magics.Time20ms); - } - else - { - this.submitRequest(false); - } - - return result; - - }, () => !this.submitRequest() && (this.sign() || this.encrypt())); - - this.selectCommand = createCommand(() => { - - const - keyId = this.selectedPrivateKey(), - option = keyId ? _.find(this.privateKeysOptions(), (item) => item && keyId === item.id) : null; - - if (option) - { - this.signKey({ - 'empty': !option.key, - 'selected': ko.observable(!!option.key), - 'users': option.key.users, - 'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(), - 'key': option.key - }); - } - }); - - this.addCommand = createCommand(() => { - - const - keyId = this.selectedPublicKey(), - keys = this.encryptKeys(), - option = keyId ? _.find(this.publicKeysOptions(), (item) => (item && keyId === item.id)) : null; - - if (option) - { - keys.push({ - 'empty': !option.key, - 'selected': ko.observable(!!option.key), - 'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id), - 'users': option.key.users, - 'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(), - 'key': option.key - }); - - this.encryptKeys(keys); - } - }); - - this.updateCommand = createCommand(() => { - _.each(this.encryptKeys(), (oKey) => { - oKey.removable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.key.id); - }); - }); - this.selectedPrivateKey.subscribe((value) => { if (value) { @@ -328,6 +122,211 @@ class ComposeOpenPgpPopupView extends AbstractViewNext this.deletePublickKey = _.bind(this.deletePublickKey, this); } + @command((self) => !self.submitRequest() && (self.sign() || self.encrypt())) + doCommand() { + + let + result = true, + privateKey = null, + aPublicKeys = []; + + this.submitRequest(true); + + if (result && this.sign()) + { + if (!this.signKey()) + { + this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND')); + result = false; + } + else if (!this.signKey().key) + { + this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', { + 'EMAIL': this.signKey().email + })); + + result = false; + } + + if (result) + { + const privateKeys = this.signKey().key.getNativeKeys(); + privateKey = privateKeys[0] || null; + + try + { + if (privateKey) + { + privateKey.decrypt(pString(this.password())); + } + } + catch (e) + { + privateKey = null; + } + + if (!privateKey) + { + this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND')); + result = false; + } + } + } + + if (result && this.encrypt()) + { + if (0 === this.encryptKeys().length) + { + this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND')); + result = false; + } + else if (this.encryptKeys()) + { + aPublicKeys = []; + + _.each(this.encryptKeys(), (oKey) => { + if (oKey && oKey.key) + { + aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys()))); + } + else if (oKey && oKey.email) + { + this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', { + 'EMAIL': oKey.email + })); + + result = false; + } + }); + + if (result && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length)) + { + result = false; + } + } + } + + if (result && this.resultCallback) + { + _.delay(() => { + + let pgpPromise = null; + + try + { + if (privateKey && 0 === aPublicKeys.length) + { + pgpPromise = PgpStore.openpgp.sign({ + data: this.text(), + privateKeys: [privateKey] + }); + } + else if (privateKey && 0 < aPublicKeys.length) + { + pgpPromise = PgpStore.openpgp.encrypt({ + data: this.text(), + publicKeys: aPublicKeys, + privateKeys: [privateKey] + }); + } + else if (!privateKey && 0 < aPublicKeys.length) + { + pgpPromise = PgpStore.openpgp.encrypt({ + data: this.text(), + publicKeys: aPublicKeys + }); + } + } + catch (e) + { + log(e); + + this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { + 'ERROR': '' + e + })); + } + + if (pgpPromise) + { + try + { + pgpPromise.then((mData) => { + this.resultCallback(mData.data); + this.cancelCommand(); + }).catch((e) => { + this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { + 'ERROR': '' + e + })); + }); + } + catch (e) + { + this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', { + 'ERROR': '' + e + })); + } + } + + this.submitRequest(false); + + }, Magics.Time20ms); + } + else + { + this.submitRequest(false); + } + + return result; + } + + @command() + selectCommand() { + const + keyId = this.selectedPrivateKey(), + option = keyId ? _.find(this.privateKeysOptions(), (item) => item && keyId === item.id) : null; + + if (option) + { + this.signKey({ + 'empty': !option.key, + 'selected': ko.observable(!!option.key), + 'users': option.key.users, + 'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(), + 'key': option.key + }); + } + } + + @command() + addCommand() { + + const + keyId = this.selectedPublicKey(), + keys = this.encryptKeys(), + option = keyId ? _.find(this.publicKeysOptions(), (item) => (item && keyId === item.id)) : null; + + if (option) + { + keys.push({ + 'empty': !option.key, + 'selected': ko.observable(!!option.key), + 'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id), + 'users': option.key.users, + 'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(), + 'key': option.key + }); + + this.encryptKeys(keys); + } + } + + @command() + updateCommand() { + _.each(this.encryptKeys(), (oKey) => { + oKey.removable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.key.id); + }); + } + deletePublickKey(publicKey) { this.encryptKeys.remove(publicKey); } @@ -459,4 +458,4 @@ class ComposeOpenPgpPopupView extends AbstractViewNext } } -module.exports = ComposeOpenPgpPopupView; +export {ComposeOpenPgpPopupView, ComposeOpenPgpPopupView as default}; diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 5edbdb7da..18ed3d090 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -13,7 +13,7 @@ import { import { delegateRunOnDestroy, computedPagenatorHelper, - inArray, trim, windowResizeCallback, createCommand, + inArray, trim, windowResizeCallback, isNonEmptyArray, fakeMd5, pInt, isUnd } from 'Common/Utils'; @@ -37,12 +37,11 @@ import {ContactPropertyModel} from 'Model/ContactProperty'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin'; +import {popup, command, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Contacts', - type: ViewType.Popup, templateID: 'PopupsContacts' }) class ContactsPopupView extends AbstractViewNext @@ -210,155 +209,6 @@ class ContactsPopupView extends AbstractViewNext this.selector.on('onItemGetUid', (contact) => (contact ? contact.generateUid() : '')); - this.newCommand = createCommand(() => { - this.populateViewContact(null); - this.currentContact(null); - }); - - this.deleteCommand = createCommand(() => { - this.deleteSelectedContacts(); - this.emptySelection(true); - }, () => 0 < this.contactsCheckedOrSelected().length); - - this.newMessageCommand = createCommand(() => { - - if (!Settings.capa(Capa.Composer)) - { - return false; - } - - let - aE = [], - toEmails = null, - ccEmails = null, - bccEmails = null; - - const aC = this.contactsCheckedOrSelected(); - if (isNonEmptyArray(aC)) - { - aE = _.map(aC, (oItem) => { - if (oItem) - { - const - data = oItem.getNameAndEmailHelper(), - email = data ? new EmailModel(data[0], data[1]) : null; - - if (email && email.validate()) - { - return email; - } - } - - return null; - }); - - aE = _.compact(aE); - } - - if (isNonEmptyArray(aE)) - { - this.bBackToCompose = false; - - hideScreenPopup(require('View/Popup/Contacts')); - - switch (this.sLastComposeFocusedField) - { - case 'cc': - ccEmails = aE; - break; - case 'bcc': - bccEmails = aE; - break; - case 'to': - default: - toEmails = aE; - break; - } - - this.sLastComposeFocusedField = ''; - - _.delay(() => { - showScreenPopup(require('View/Popup/Compose'), [ComposeType.Empty, null, toEmails, ccEmails, bccEmails]); - }, Magics.Time200ms); - } - - return true; - - }, () => 0 < this.contactsCheckedOrSelected().length); - - this.clearCommand = createCommand(() => { - this.search(''); - }); - - this.saveCommand = createCommand(() => { - - this.viewSaving(true); - this.viewSaveTrigger(SaveSettingsStep.Animate); - - const - requestUid = fakeMd5(), - properties = []; - - _.each(this.viewProperties(), (oItem) => { - if (oItem.type() && '' !== trim(oItem.value())) - { - properties.push([oItem.type(), oItem.value(), oItem.typeStr()]); - } - }); - - Remote.contactSave((sResult, oData) => { - - let res = false; - this.viewSaving(false); - - if (StorageResultType.Success === sResult && oData && oData.Result && - oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID)) - { - if ('' === this.viewID()) - { - this.viewID(pInt(oData.Result.ResultID)); - } - - this.reloadContactList(); - res = true; - } - - _.delay(() => { - this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult); - }, Magics.Time350ms); - - if (res) - { - this.watchDirty(false); - - _.delay(() => { - this.viewSaveTrigger(SaveSettingsStep.Idle); - }, Magics.Time1s); - } - - }, requestUid, this.viewID(), properties); - - }, () => { - const - bV = this.viewHasNonEmptyRequaredProperties(), - bReadOnly = this.viewReadOnly(); - return !this.viewSaving() && bV && !bReadOnly; - }); - - this.syncCommand = createCommand(() => { - - getApp().contactsSync((result, data) => { - if (StorageResultType.Success !== result || !data || !data.Result) - { - window.alert(getNotification( - data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError)); - } - - this.reloadContactList(true); - }); - - }, () => !this.contacts.syncing() && !this.contacts.importing()); - this.bDropPageAfterDelete = false; this.watchDirty = ko.observable(false); @@ -378,6 +228,157 @@ class ContactsPopupView extends AbstractViewNext this.sDefaultKeyScope = KeyState.ContactList; } + @command() + newCommand() { + this.populateViewContact(null); + this.currentContact(null); + } + + @command((self) => 0 < self.contactsCheckedOrSelected().length) + deleteCommand() { + this.deleteSelectedContacts(); + this.emptySelection(true); + } + + @command((self) => 0 < self.contactsCheckedOrSelected().length) + newMessageCommand() { + + if (!Settings.capa(Capa.Composer)) + { + return false; + } + + let + aE = [], + toEmails = null, + ccEmails = null, + bccEmails = null; + + const aC = this.contactsCheckedOrSelected(); + if (isNonEmptyArray(aC)) + { + aE = _.map(aC, (oItem) => { + if (oItem) + { + const + data = oItem.getNameAndEmailHelper(), + email = data ? new EmailModel(data[0], data[1]) : null; + + if (email && email.validate()) + { + return email; + } + } + + return null; + }); + + aE = _.compact(aE); + } + + if (isNonEmptyArray(aE)) + { + this.bBackToCompose = false; + + hideScreenPopup(require('View/Popup/Contacts')); + + switch (this.sLastComposeFocusedField) + { + case 'cc': + ccEmails = aE; + break; + case 'bcc': + bccEmails = aE; + break; + case 'to': + default: + toEmails = aE; + break; + } + + this.sLastComposeFocusedField = ''; + + _.delay(() => { + showScreenPopup(require('View/Popup/Compose'), [ComposeType.Empty, null, toEmails, ccEmails, bccEmails]); + }, Magics.Time200ms); + } + + return true; + } + + @command() + clearCommand() { + this.search(''); + } + + @command((self) => { + const + bV = self.viewHasNonEmptyRequaredProperties(), + bReadOnly = self.viewReadOnly(); + return !self.viewSaving() && bV && !bReadOnly; + }) + saveCommand() { + + this.viewSaving(true); + this.viewSaveTrigger(SaveSettingsStep.Animate); + + const + requestUid = fakeMd5(), + properties = []; + + _.each(this.viewProperties(), (oItem) => { + if (oItem.type() && '' !== trim(oItem.value())) + { + properties.push([oItem.type(), oItem.value(), oItem.typeStr()]); + } + }); + + Remote.contactSave((sResult, oData) => { + + let res = false; + this.viewSaving(false); + + if (StorageResultType.Success === sResult && oData && oData.Result && + oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID)) + { + if ('' === this.viewID()) + { + this.viewID(pInt(oData.Result.ResultID)); + } + + this.reloadContactList(); + res = true; + } + + _.delay(() => { + this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult); + }, Magics.Time350ms); + + if (res) + { + this.watchDirty(false); + + _.delay(() => { + this.viewSaveTrigger(SaveSettingsStep.Idle); + }, Magics.Time1s); + } + + }, requestUid, this.viewID(), properties); + } + + @command((self) => !self.contacts.syncing() && !self.contacts.importing()) + syncCommand() { + getApp().contactsSync((result, data) => { + if (StorageResultType.Success !== result || !data || !data.Result) + { + window.alert(getNotification( + data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError)); + } + + this.reloadContactList(true); + }); + } + getPropertyPlaceholder(type) { let result = ''; switch (type) @@ -722,4 +723,4 @@ class ContactsPopupView extends AbstractViewNext } } -module.exports = ContactsPopupView; +export {ContactsPopupView, ContactsPopupView as default}; diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index 10b19de10..e55444025 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -5,7 +5,7 @@ import ko from 'ko'; import {StorageResultType, ServerSecure, Ports, Notification} from 'Common/Enums'; import {IMAP_DEFAULT_PORT, SIEVE_DEFAULT_PORT, SMTP_DEFAULT_PORT} from 'Common/Consts'; import {bMobileDevice} from 'Common/Globals'; -import {createCommand, trim, pInt, pString} from 'Common/Utils'; +import {trim, pInt, pString} from 'Common/Utils'; import {i18n} from 'Common/Translator'; import CapaAdminStore from 'Stores/Admin/Capa'; @@ -14,12 +14,11 @@ import Remote from 'Remote/Admin/Ajax'; import {getApp} from 'Helper/Apps/Admin'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Domain', - type: ViewType.Popup, templateID: 'PopupsDomain' }) class DomainPopupView extends AbstractViewNext @@ -141,79 +140,6 @@ class DomainPopupView extends AbstractViewNext this.canBeTested = ko.computed(() => !this.testing() && this.domainIsComputed()); this.canBeSaved = ko.computed(() => !this.saving() && this.domainIsComputed()); - this.createOrAddCommand = createCommand(() => { - this.saving(true); - Remote.createOrUpdateDomain( - _.bind(this.onDomainCreateOrSaveResponse, this), - !this.edit(), - this.name(), - - this.imapServer(), - pInt(this.imapPort()), - this.imapSecure(), - this.imapShortLogin(), - - this.useSieve(), - this.sieveAllowRaw(), - this.sieveServer(), - pInt(this.sievePort()), - this.sieveSecure(), - - this.smtpServer(), - pInt(this.smtpPort()), - this.smtpSecure(), - this.smtpShortLogin(), - this.smtpAuth(), - this.smtpPhpMail(), - - this.whiteList() - ); - }, this.canBeSaved); - - this.testConnectionCommand = createCommand(() => { - - this.page('main'); - - this.testingDone(false); - this.testingImapError(false); - this.testingSieveError(false); - this.testingSmtpError(false); - this.testing(true); - - Remote.testConnectionForDomain( - _.bind(this.onTestConnectionResponse, this), - this.name(), - - this.imapServer(), - pInt(this.imapPort()), - this.imapSecure(), - - this.useSieve(), - this.sieveServer(), - pInt(this.sievePort()), - this.sieveSecure(), - - this.smtpServer(), - pInt(this.smtpPort()), - this.smtpSecure(), - this.smtpAuth(), - this.smtpPhpMail() - ); - }, this.canBeTested); - - this.whiteListCommand = createCommand(() => { - this.page('white-list'); - }); - - this.backCommand = createCommand(() => { - this.page('main'); - }); - - this.sieveCommand = createCommand(() => { - this.sieveSettings(!this.sieveSettings()); - this.clearTesting(); - }); - this.page.subscribe(() => { this.sieveSettings(false); }); @@ -293,6 +219,84 @@ class DomainPopupView extends AbstractViewNext }); } + @command((self) => self.canBeSaved()) + createOrAddCommand() { + this.saving(true); + Remote.createOrUpdateDomain( + _.bind(this.onDomainCreateOrSaveResponse, this), + !this.edit(), + this.name(), + + this.imapServer(), + pInt(this.imapPort()), + this.imapSecure(), + this.imapShortLogin(), + + this.useSieve(), + this.sieveAllowRaw(), + this.sieveServer(), + pInt(this.sievePort()), + this.sieveSecure(), + + this.smtpServer(), + pInt(this.smtpPort()), + this.smtpSecure(), + this.smtpShortLogin(), + this.smtpAuth(), + this.smtpPhpMail(), + + this.whiteList() + ); + } + + @command((self) => self.canBeTested()) + testConnectionCommand() { + + this.page('main'); + + this.testingDone(false); + this.testingImapError(false); + this.testingSieveError(false); + this.testingSmtpError(false); + this.testing(true); + + Remote.testConnectionForDomain( + _.bind(this.onTestConnectionResponse, this), + this.name(), + + this.imapServer(), + pInt(this.imapPort()), + this.imapSecure(), + + this.useSieve(), + this.sieveServer(), + pInt(this.sievePort()), + this.sieveSecure(), + + this.smtpServer(), + pInt(this.smtpPort()), + this.smtpSecure(), + this.smtpAuth(), + this.smtpPhpMail() + ); + } + + @command() + whiteListCommand() { + this.page('white-list'); + } + + @command() + backCommand() { + this.page('main'); + } + + @command() + sieveCommand() { + this.sieveSettings(!this.sieveSettings()); + this.clearTesting(); + } + onTestConnectionResponse(sResult, oData) { this.testing(false); if (StorageResultType.Success === sResult && oData.Result) @@ -462,4 +466,4 @@ class DomainPopupView extends AbstractViewNext } } -module.exports = DomainPopupView; +export {DomainPopupView, DomainPopupView as default}; diff --git a/dev/View/Popup/DomainAlias.js b/dev/View/Popup/DomainAlias.js index 589b8ca27..cc4d17a31 100644 --- a/dev/View/Popup/DomainAlias.js +++ b/dev/View/Popup/DomainAlias.js @@ -4,7 +4,6 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; import {bMobileDevice} from 'Common/Globals'; -import {createCommand} from 'Common/Utils'; import {i18n} from 'Common/Translator'; import DomainStore from 'Stores/Admin/Domain'; @@ -13,12 +12,11 @@ import Remote from 'Remote/Admin/Ajax'; import {getApp} from 'Helper/Apps/Admin'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/DomainAlias', - type: ViewType.Popup, templateID: 'PopupsDomainAlias' }) class DomainAliasPopupView extends AbstractViewNext @@ -42,18 +40,19 @@ class DomainAliasPopupView extends AbstractViewNext this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias()); - this.createCommand = createCommand(() => { - this.saving(true); - Remote.createDomainAlias( - this.onDomainAliasCreateOrSaveResponse, - this.name(), - this.alias() - ); - }, this.canBeSaved); - this.onDomainAliasCreateOrSaveResponse = _.bind(this.onDomainAliasCreateOrSaveResponse, this); } + @command((self) => self.canBeSaved()) + createCommand() { + this.saving(true); + Remote.createDomainAlias( + this.onDomainAliasCreateOrSaveResponse, + this.name(), + this.alias() + ); + } + onDomainAliasCreateOrSaveResponse(result, data) { this.saving(false); if (StorageResultType.Success === result && data) @@ -96,4 +95,4 @@ class DomainAliasPopupView extends AbstractViewNext } } -module.exports = DomainAliasPopupView; +export {DomainAliasPopupView, DomainAliasPopupView as default}; diff --git a/dev/View/Popup/Filter.js b/dev/View/Popup/Filter.js index bf0558f98..25fb5bb78 100644 --- a/dev/View/Popup/Filter.js +++ b/dev/View/Popup/Filter.js @@ -4,18 +4,17 @@ import ko from 'ko'; import {FiltersAction, FilterConditionField, FilterConditionType} from 'Common/Enums'; import {bMobileDevice} from 'Common/Globals'; -import {defautOptionsAfterRender, createCommand, delegateRun} from 'Common/Utils'; +import {defautOptionsAfterRender, delegateRun} from 'Common/Utils'; import {i18n, initOnStartOrLangChange} from 'Common/Translator'; import FilterStore from 'Stores/User/Filter'; import FolderStore from 'Stores/User/Folder'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Filter', - type: ViewType.Popup, templateID: 'PopupsFilter' }) class FilterPopupView extends AbstractViewNext @@ -43,34 +42,6 @@ class FilterPopupView extends AbstractViewNext } }); - this.saveFilter = createCommand(() => { - - if (this.filter()) - { - if (FiltersAction.MoveTo === this.filter().actionType()) - { - this.filter().actionValue(this.selectedFolderValue()); - } - - if (!this.filter().verify()) - { - return false; - } - - if (this.fTrueCallback) - { - this.fTrueCallback(this.filter()); - } - - if (this.modalVisibility()) - { - delegateRun(this, 'closeCommand'); - } - } - - return true; - }); - this.actionTypeOptions = ko.observableArray([]); this.fieldOptions = ko.observableArray([]); this.typeOptions = ko.observableArray([]); @@ -81,6 +52,35 @@ class FilterPopupView extends AbstractViewNext this.modules.subscribe(this.populateOptions, this); } + @command() + saveFilterCommand() { + + if (this.filter()) + { + if (FiltersAction.MoveTo === this.filter().actionType()) + { + this.filter().actionValue(this.selectedFolderValue()); + } + + if (!this.filter().verify()) + { + return false; + } + + if (this.fTrueCallback) + { + this.fTrueCallback(this.filter()); + } + + if (this.modalVisibility()) + { + delegateRun(this, 'closeCommand'); + } + } + + return true; + } + populateOptions() { this.actionTypeOptions([]); @@ -191,4 +191,4 @@ class FilterPopupView extends AbstractViewNext } } -module.exports = FilterPopupView; +export {FilterPopupView, FilterPopupView as default}; diff --git a/dev/View/Popup/FolderClear.js b/dev/View/Popup/FolderClear.js index c0ba3a0ae..d0948973a 100644 --- a/dev/View/Popup/FolderClear.js +++ b/dev/View/Popup/FolderClear.js @@ -2,7 +2,6 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; -import {createCommand} from 'Common/Utils'; import {i18n, getNotification} from 'Common/Translator'; import {setFolderHash} from 'Common/Cache'; @@ -12,12 +11,11 @@ import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/FolderClear', - type: ViewType.Popup, templateID: 'PopupsFolderClear' }) class FolderClearPopupView extends AbstractViewNext @@ -42,51 +40,51 @@ class FolderClearPopupView extends AbstractViewNext this.dangerDescHtml = ko.computed( () => i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {'FOLDER': this.folderNameForClear()}) ); + } - this.clearCommand = createCommand(() => { + @command((self) => { + const + folder = self.selectedFolder(), + isClearing = self.clearingProcess(); - const folderToClear = this.selectedFolder(); - if (folderToClear) - { - MessageStore.message(null); - MessageStore.messageList([]); + return !isClearing && null !== folder; + }) + clearCommand() { - this.clearingProcess(true); + const folderToClear = this.selectedFolder(); + if (folderToClear) + { + MessageStore.message(null); + MessageStore.messageList([]); - folderToClear.messageCountAll(0); - folderToClear.messageCountUnread(0); + this.clearingProcess(true); - setFolderHash(folderToClear.fullNameRaw, ''); + folderToClear.messageCountAll(0); + folderToClear.messageCountUnread(0); - Remote.folderClear((result, data) => { + setFolderHash(folderToClear.fullNameRaw, ''); - this.clearingProcess(false); - if (StorageResultType.Success === result && data && data.Result) + Remote.folderClear((result, data) => { + + this.clearingProcess(false); + if (StorageResultType.Success === result && data && data.Result) + { + getApp().reloadMessageList(true); + this.cancelCommand(); + } + else + { + if (data && data.ErrorCode) { - getApp().reloadMessageList(true); - this.cancelCommand(); + this.clearingError(getNotification(data.ErrorCode)); } else { - if (data && data.ErrorCode) - { - this.clearingError(getNotification(data.ErrorCode)); - } - else - { - this.clearingError(getNotification(Notification.MailServerError)); - } + this.clearingError(getNotification(Notification.MailServerError)); } - }, folderToClear.fullNameRaw); - } - - }, () => { - const - folder = this.selectedFolder(), - isClearing = this.clearingProcess(); - - return !isClearing && null !== folder; - }); + } + }, folderToClear.fullNameRaw); + } } clearPopup() { @@ -103,4 +101,4 @@ class FolderClearPopupView extends AbstractViewNext } } -module.exports = FolderClearPopupView; +export {FolderClearPopupView, FolderClearPopupView as default}; diff --git a/dev/View/Popup/FolderCreate.js b/dev/View/Popup/FolderCreate.js index 3e28a823f..8e1526f29 100644 --- a/dev/View/Popup/FolderCreate.js +++ b/dev/View/Popup/FolderCreate.js @@ -4,7 +4,7 @@ import ko from 'ko'; import {Notification} from 'Common/Enums'; import {UNUSED_OPTION_VALUE} from 'Common/Consts'; import {bMobileDevice} from 'Common/Globals'; -import {trim, createCommand, defautOptionsAfterRender, folderListOptionsBuilder} from 'Common/Utils'; +import {trim, defautOptionsAfterRender, folderListOptionsBuilder} from 'Common/Utils'; import FolderStore from 'Stores/User/Folder'; @@ -12,12 +12,11 @@ import Promises from 'Promises/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/FolderCreate', - type: ViewType.Popup, templateID: 'PopupsFolderCreate' }) class FolderCreateView extends AbstractViewNext @@ -49,27 +48,26 @@ class FolderCreateView extends AbstractViewNext }); - // commands - this.createFolder = createCommand(() => { - - let parentFolderName = this.selectedParentValue(); - if ('' === parentFolderName && 1 < FolderStore.namespace.length) - { - parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1); - } - - getApp().foldersPromisesActionHelper( - Promises.folderCreate(this.folderName(), parentFolderName, FolderStore.foldersCreating), - Notification.CantCreateFolder - ); - - this.cancelCommand(); - - }, () => this.simpleFolderNameValidation(this.folderName())); - this.defautOptionsAfterRender = defautOptionsAfterRender; } + @command((self) => self.simpleFolderNameValidation(self.folderName())) + createFolderCommand() { + + let parentFolderName = this.selectedParentValue(); + if ('' === parentFolderName && 1 < FolderStore.namespace.length) + { + parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1); + } + + getApp().foldersPromisesActionHelper( + Promises.folderCreate(this.folderName(), parentFolderName, FolderStore.foldersCreating), + Notification.CantCreateFolder + ); + + this.cancelCommand(); + } + simpleFolderNameValidation(sName) { return (/^[^\\\/]+$/g).test(trim(sName)); } @@ -92,4 +90,4 @@ class FolderCreateView extends AbstractViewNext } } -module.exports = FolderCreateView; +export {FolderCreateView, FolderCreateView as default}; diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index 28c7eb56e..0c4842c46 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -12,12 +12,11 @@ import FolderStore from 'Stores/User/Folder'; import * as Settings from 'Storage/Settings'; import Remote from 'Remote/User/Ajax'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/FolderSystem', - type: ViewType.Popup, templateID: 'PopupsFolderSystem' }) class FolderSystemPopupView extends AbstractViewNext @@ -110,4 +109,4 @@ class FolderSystemPopupView extends AbstractViewNext } } -module.exports = FolderSystemPopupView; +export {FolderSystemPopupView, FolderSystemPopupView as default}; diff --git a/dev/View/Popup/Identity.js b/dev/View/Popup/Identity.js index d74db0c54..966e1f029 100644 --- a/dev/View/Popup/Identity.js +++ b/dev/View/Popup/Identity.js @@ -3,19 +3,18 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; import {bMobileDevice} from 'Common/Globals'; -import {createCommand, trim, fakeMd5} from 'Common/Utils'; +import {trim, fakeMd5} from 'Common/Utils'; import {getNotification} from 'Common/Translator'; import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Identity', - type: ViewType.Popup, templateID: 'PopupsIdentity' }) class IdentityPopupView extends AbstractViewNext @@ -58,68 +57,68 @@ class IdentityPopupView extends AbstractViewNext this.showReplyTo(true); } }); + } - this.addOrEditIdentityCommand = createCommand(() => { + @command((self) => !self.submitRequest()) + addOrEditIdentityCommand() { - if (this.signature && this.signature.__fetchEditorValue) + if (this.signature && this.signature.__fetchEditorValue) + { + this.signature.__fetchEditorValue(); + } + + if (!this.email.hasError()) + { + this.email.hasError('' === trim(this.email())); + } + + if (this.email.hasError()) + { + if (!this.owner()) { - this.signature.__fetchEditorValue(); + this.email.focused(true); } - if (!this.email.hasError()) - { - this.email.hasError('' === trim(this.email())); - } + return false; + } - if (this.email.hasError()) + if (this.replyTo.hasError()) + { + this.replyTo.focused(true); + return false; + } + + if (this.bcc.hasError()) + { + this.bcc.focused(true); + return false; + } + + this.submitRequest(true); + + Remote.identityUpdate((result, data) => { + + this.submitRequest(false); + if (StorageResultType.Success === result && data) { - if (!this.owner()) + if (data.Result) { - this.email.focused(true); + getApp().accountsAndIdentities(); + this.cancelCommand(); } - - return false; - } - - if (this.replyTo.hasError()) - { - this.replyTo.focused(true); - return false; - } - - if (this.bcc.hasError()) - { - this.bcc.focused(true); - return false; - } - - this.submitRequest(true); - - Remote.identityUpdate((result, data) => { - - this.submitRequest(false); - if (StorageResultType.Success === result && data) + else if (data.ErrorCode) { - if (data.Result) - { - getApp().accountsAndIdentities(); - this.cancelCommand(); - } - else if (data.ErrorCode) - { - this.submitError(getNotification(data.ErrorCode)); - } - } - else - { - this.submitError(getNotification(Notification.UnknownError)); + this.submitError(getNotification(data.ErrorCode)); } + } + else + { + this.submitError(getNotification(Notification.UnknownError)); + } - }, this.id, this.email(), this.name(), this.replyTo(), this.bcc(), this.signature(), this.signatureInsertBefore()); + }, this.id, this.email(), this.name(), this.replyTo(), this.bcc(), this.signature(), this.signatureInsertBefore()); - return true; - - }, () => !this.submitRequest()); + return true; } clearPopup() { @@ -184,4 +183,4 @@ class IdentityPopupView extends AbstractViewNext } } -module.exports = IdentityPopupView; +export {IdentityPopupView, IdentityPopupView as default}; diff --git a/dev/View/Popup/KeyboardShortcutsHelp.js b/dev/View/Popup/KeyboardShortcutsHelp.js index b61108907..9a583dffc 100644 --- a/dev/View/Popup/KeyboardShortcutsHelp.js +++ b/dev/View/Popup/KeyboardShortcutsHelp.js @@ -4,12 +4,11 @@ import key from 'key'; import {KeyState, Magics} from 'Common/Enums'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/KeyboardShortcutsHelp', - type: ViewType.Popup, templateID: 'PopupsKeyboardShortcutsHelp' }) class KeyboardShortcutsHelpPopupView extends AbstractViewNext @@ -52,4 +51,4 @@ class KeyboardShortcutsHelpPopupView extends AbstractViewNext } } -module.exports = KeyboardShortcutsHelpPopupView; +export {KeyboardShortcutsHelpPopupView, KeyboardShortcutsHelpPopupView as default}; diff --git a/dev/View/Popup/Languages.js b/dev/View/Popup/Languages.js index 88e2e7181..34f9056a5 100644 --- a/dev/View/Popup/Languages.js +++ b/dev/View/Popup/Languages.js @@ -4,12 +4,12 @@ import ko from 'ko'; import {convertLangName} from 'Common/Utils'; -import {view, ViewType} from 'Knoin/Knoin'; +// import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Languages', - type: ViewType.Popup, templateID: 'PopupsLanguages' }) class LanguagesPopupView extends AbstractViewNext @@ -73,4 +73,4 @@ class LanguagesPopupView extends AbstractViewNext } } -module.exports = LanguagesPopupView; +export {LanguagesPopupView, LanguagesPopupView as default}; diff --git a/dev/View/Popup/MessageOpenPgp.js b/dev/View/Popup/MessageOpenPgp.js index e6592460a..3e155fdc1 100644 --- a/dev/View/Popup/MessageOpenPgp.js +++ b/dev/View/Popup/MessageOpenPgp.js @@ -4,15 +4,14 @@ import ko from 'ko'; import key from 'key'; import $ from '$'; -import {createCommand, pString, log} from 'Common/Utils'; +import {pString, log} from 'Common/Utils'; import {KeyState, Magics} from 'Common/Enums'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/MessageOpenPgp', - type: ViewType.Popup, templateID: 'PopupsMessageOpenPgp' }) class MessageOpenPgpPopupView extends AbstractViewNext @@ -33,60 +32,59 @@ class MessageOpenPgpPopupView extends AbstractViewNext this.submitRequest = ko.observable(false); - // commands - this.doCommand = createCommand(() => { + this.sDefaultKeyScope = KeyState.PopupMessageOpenPGP; + } - this.submitRequest(true); + @command((self) => !self.submitRequest()) + doCommand() { - _.delay(() => { + this.submitRequest(true); - let privateKey = null; + _.delay(() => { - try + let privateKey = null; + + try + { + if (this.resultCallback && this.selectedKey()) { - if (this.resultCallback && this.selectedKey()) - { - const privateKeys = this.selectedKey().getNativeKeys(); - privateKey = privateKeys && privateKeys[0] ? privateKeys[0] : null; + const privateKeys = this.selectedKey().getNativeKeys(); + privateKey = privateKeys && privateKeys[0] ? privateKeys[0] : null; - if (privateKey) + if (privateKey) + { + try { - try + if (!privateKey.decrypt(pString(this.password()))) { - if (!privateKey.decrypt(pString(this.password()))) - { - log('Error: Private key cannot be decrypted'); - privateKey = null; - } - } - catch (e) - { - log(e); + log('Error: Private key cannot be decrypted'); privateKey = null; } } - else + catch (e) { - log('Error: Private key cannot be found'); + log(e); + privateKey = null; } } + else + { + log('Error: Private key cannot be found'); + } } - catch (e) - { - log(e); - privateKey = null; - } + } + catch (e) + { + log(e); + privateKey = null; + } - this.submitRequest(false); + this.submitRequest(false); - this.cancelCommand(); - this.resultCallback(privateKey); + this.cancelCommand(); + this.resultCallback(privateKey); - }, Magics.Time100ms); - - }, () => !this.submitRequest()); - - this.sDefaultKeyScope = KeyState.PopupMessageOpenPGP; + }, Magics.Time100ms); } clearPopup() { @@ -162,4 +160,4 @@ class MessageOpenPgpPopupView extends AbstractViewNext } } -module.exports = MessageOpenPgpPopupView; +export {MessageOpenPgpPopupView, MessageOpenPgpPopupView as default}; diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index 9c6cc974b..33db706c3 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -3,18 +3,17 @@ import _ from '_'; import ko from 'ko'; import {Magics} from 'Common/Enums'; -import {trim, log, createCommand, delegateRun, pInt} from 'Common/Utils'; +import {trim, log, delegateRun, pInt} from 'Common/Utils'; import PgpStore from 'Stores/User/Pgp'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/NewOpenPgpKey', - type: ViewType.Popup, templateID: 'PopupsNewOpenPgpKey' }) class NewOpenPgpKeyPopupView extends AbstractViewNext @@ -36,66 +35,67 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext this.email.subscribe(() => { this.email.error(false); }); + } - this.generateOpenPgpKeyCommand = createCommand(() => { + @command() + generateOpenPgpKeyCommand() { - const - userId = {}, - openpgpKeyring = PgpStore.openpgpKeyring; + const + userId = {}, + openpgpKeyring = PgpStore.openpgpKeyring; - this.email.error('' === trim(this.email())); - if (!openpgpKeyring || this.email.error()) - { - return false; - } + this.email.error('' === trim(this.email())); + if (!openpgpKeyring || this.email.error()) + { + return false; + } - userId.email = this.email(); - if ('' !== this.name()) - { - userId.name = this.name(); - } + userId.email = this.email(); + if ('' !== this.name()) + { + userId.name = this.name(); + } - this.submitRequest(true); - this.submitError(''); + this.submitRequest(true); + this.submitError(''); - _.delay(() => { + _.delay(() => { - try { + try { - PgpStore.openpgp.generateKey({ - userIds: [userId], - numBits: pInt(this.keyBitLength()), - passphrase: trim(this.password()) - }).then((keyPair) => { + PgpStore.openpgp.generateKey({ + userIds: [userId], + numBits: pInt(this.keyBitLength()), + passphrase: trim(this.password()) + }).then((keyPair) => { - this.submitRequest(false); + this.submitRequest(false); - if (keyPair && keyPair.privateKeyArmored) - { - openpgpKeyring.privateKeys.importKey(keyPair.privateKeyArmored); - openpgpKeyring.publicKeys.importKey(keyPair.publicKeyArmored); + if (keyPair && keyPair.privateKeyArmored) + { + openpgpKeyring.privateKeys.importKey(keyPair.privateKeyArmored); + openpgpKeyring.publicKeys.importKey(keyPair.publicKeyArmored); - openpgpKeyring.store(); + openpgpKeyring.store(); - getApp().reloadOpenPgpKeys(); - delegateRun(this, 'cancelCommand'); - } + getApp().reloadOpenPgpKeys(); + delegateRun(this, 'cancelCommand'); + } - }).catch((e) => { - this.submitRequest(false); - this.showError(e); - }); - } - catch (e) - { + }).catch((e) => { this.submitRequest(false); this.showError(e); - } + }); + } + catch (e) + { + this.submitRequest(false); + this.showError(e); + } - }, Magics.Time100ms); + }, Magics.Time100ms); - return true; - }); + return true; } showError(e) { @@ -126,4 +126,4 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext } } -module.exports = NewOpenPgpKeyPopupView; +export {NewOpenPgpKeyPopupView, NewOpenPgpKeyPopupView as default}; diff --git a/dev/View/Popup/Plugin.js b/dev/View/Popup/Plugin.js index 8afab1c44..94530fc9e 100644 --- a/dev/View/Popup/Plugin.js +++ b/dev/View/Popup/Plugin.js @@ -4,17 +4,16 @@ import ko from 'ko'; import key from 'key'; import {KeyState, Magics, StorageResultType, Notification} from 'Common/Enums'; -import {createCommand, isNonEmptyArray, delegateRun} from 'Common/Utils'; +import {isNonEmptyArray, delegateRun} from 'Common/Utils'; import {getNotification, i18n} from 'Common/Translator'; import Remote from 'Remote/Admin/Ajax'; -import {view, ViewType, isPopupVisible, showScreenPopup} from 'Knoin/Knoin'; +import {popup, command, isPopupVisible, showScreenPopup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Plugin', - type: ViewType.Popup, templateID: 'PopupsPlugin' }) class PluginPopupView extends AbstractViewNext @@ -43,31 +42,31 @@ class PluginPopupView extends AbstractViewNext 'content': () => `
${this.readme()}
` }; - this.saveCommand = createCommand(() => { - - const list = {}; - list.Name = this.name(); - - _.each(this.configures(), (oItem) => { - let value = oItem.value(); - if (false === value || true === value) - { - value = value ? '1' : '0'; - } - list['_' + oItem.Name] = value; - }); - - this.saveError(''); - Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list); - - }, this.hasConfiguration); - this.bDisabeCloseOnEsc = true; this.sDefaultKeyScope = KeyState.All; this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), Magics.Time200ms); } + @command((self) => self.hasConfiguration()) + saveCommand() { + + const list = {}; + list.Name = this.name(); + + _.each(this.configures(), (oItem) => { + let value = oItem.value(); + if (false === value || true === value) + { + value = value ? '1' : '0'; + } + list['_' + oItem.Name] = value; + }); + + this.saveError(''); + Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list); + } + onPluginSettingsUpdateResponse(result, data) { if (StorageResultType.Success === result && data && data.Result) { @@ -138,4 +137,4 @@ class PluginPopupView extends AbstractViewNext } } -module.exports = PluginPopupView; +export {PluginPopupView, PluginPopupView as default}; diff --git a/dev/View/Popup/Template.js b/dev/View/Popup/Template.js index 8b28e1954..aef5cae89 100644 --- a/dev/View/Popup/Template.js +++ b/dev/View/Popup/Template.js @@ -2,7 +2,7 @@ import ko from 'ko'; import {StorageResultType, Notification} from 'Common/Enums'; -import {trim, isNormal, createCommand} from 'Common/Utils'; +import {trim, isNormal} from 'Common/Utils'; import {getNotification} from 'Common/Translator'; import {HtmlEditor} from 'Common/HtmlEditor'; @@ -10,12 +10,11 @@ import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/Template', - type: ViewType.Popup, templateID: 'PopupsTemplate' }) class TemplatePopupView extends AbstractViewNext @@ -46,46 +45,46 @@ class TemplatePopupView extends AbstractViewNext this.submitRequest = ko.observable(false); this.submitError = ko.observable(''); + } - this.addTemplateCommand = createCommand(() => { + @command((self) => !self.submitRequest()) + addTemplateCommand() { - this.populateBodyFromEditor(); + this.populateBodyFromEditor(); - this.name.error('' === trim(this.name())); - this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body())); + this.name.error('' === trim(this.name())); + this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body())); - if (this.name.error() || this.body.error()) + if (this.name.error() || this.body.error()) + { + return false; + } + + this.submitRequest(true); + + Remote.templateSetup((result, data) => { + + this.submitRequest(false); + if (StorageResultType.Success === result && data) { - return false; + if (data.Result) + { + getApp().templates(); + this.cancelCommand(); + } + else if (data.ErrorCode) + { + this.submitError(getNotification(data.ErrorCode)); + } + } + else + { + this.submitError(getNotification(Notification.UnknownError)); } - this.submitRequest(true); + }, this.id(), this.name(), this.body()); - Remote.templateSetup((result, data) => { - - this.submitRequest(false); - if (StorageResultType.Success === result && data) - { - if (data.Result) - { - getApp().templates(); - this.cancelCommand(); - } - else if (data.ErrorCode) - { - this.submitError(getNotification(data.ErrorCode)); - } - } - else - { - this.submitError(getNotification(Notification.UnknownError)); - } - - }, this.id(), this.name(), this.body()); - - return true; - - }, () => !this.submitRequest()); + return true; } clearPopup() { @@ -183,4 +182,4 @@ class TemplatePopupView extends AbstractViewNext } } -module.exports = TemplatePopupView; +export {TemplatePopupView, TemplatePopupView as default}; diff --git a/dev/View/Popup/TwoFactorConfiguration.js b/dev/View/Popup/TwoFactorConfiguration.js index 49209dca0..4fce32efb 100644 --- a/dev/View/Popup/TwoFactorConfiguration.js +++ b/dev/View/Popup/TwoFactorConfiguration.js @@ -14,12 +14,11 @@ import Remote from 'Remote/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, ViewType, showScreenPopup} from 'Knoin/Knoin'; +import {popup, showScreenPopup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/TwoFactorConfiguration', - type: ViewType.Popup, templateID: 'PopupsTwoFactorConfiguration' }) class TwoFactorConfigurationPopupView extends AbstractViewNext @@ -214,4 +213,4 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext } } -module.exports = TwoFactorConfigurationPopupView; +export {TwoFactorConfigurationPopupView, TwoFactorConfigurationPopupView as default}; diff --git a/dev/View/Popup/TwoFactorTest.js b/dev/View/Popup/TwoFactorTest.js index 8eb0a6149..842c31f97 100644 --- a/dev/View/Popup/TwoFactorTest.js +++ b/dev/View/Popup/TwoFactorTest.js @@ -3,16 +3,14 @@ import ko from 'ko'; import {StorageResultType} from 'Common/Enums'; import {bMobileDevice} from 'Common/Globals'; -import {createCommand} from 'Common/Utils'; import Remote from 'Remote/User/Ajax'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup, command} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/TwoFactorTest', - type: ViewType.Popup, templateID: 'PopupsTwoFactorTest' }) class TwoFactorTestPopupView extends AbstractViewNext @@ -27,24 +25,23 @@ class TwoFactorTestPopupView extends AbstractViewNext this.koTestedTrigger = null; this.testing = ko.observable(false); + } - // commands - this.testCode = createCommand(() => { + @command((self) => '' !== self.code() && !self.testing()) + testCodeCommand() { - this.testing(true); - Remote.testTwoFactor((result, data) => { + this.testing(true); + Remote.testTwoFactor((result, data) => { - this.testing(false); - this.code.status(StorageResultType.Success === result && data && !!data.Result); + this.testing(false); + this.code.status(StorageResultType.Success === result && data && !!data.Result); - if (this.koTestedTrigger && this.code.status()) - { - this.koTestedTrigger(true); - } + if (this.koTestedTrigger && this.code.status()) + { + this.koTestedTrigger(true); + } - }, this.code()); - - }, () => '' !== this.code() && !this.testing()); + }, this.code()); } clearPopup() { @@ -70,4 +67,4 @@ class TwoFactorTestPopupView extends AbstractViewNext } } -module.exports = TwoFactorTestPopupView; +export {TwoFactorTestPopupView, TwoFactorTestPopupView as default}; diff --git a/dev/View/Popup/ViewOpenPgpKey.js b/dev/View/Popup/ViewOpenPgpKey.js index b7d4e1256..4a660baba 100644 --- a/dev/View/Popup/ViewOpenPgpKey.js +++ b/dev/View/Popup/ViewOpenPgpKey.js @@ -5,12 +5,11 @@ import key from 'key'; import {KeyState} from 'Common/Enums'; import {selectElement} from 'Common/Utils'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/ViewOpenPgpKey', - type: ViewType.Popup, templateID: 'PopupsTwoFactorTest' }) class ViewOpenPgpKeyPopupView extends AbstractViewNext @@ -53,4 +52,4 @@ class ViewOpenPgpKeyPopupView extends AbstractViewNext } } -module.exports = ViewOpenPgpKeyPopupView; +export {ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default}; diff --git a/dev/View/Popup/WelcomePage.js b/dev/View/Popup/WelcomePage.js index 8c27dc902..72abbfeda 100644 --- a/dev/View/Popup/WelcomePage.js +++ b/dev/View/Popup/WelcomePage.js @@ -3,12 +3,11 @@ import ko from 'ko'; import Promises from 'Promises/User/Ajax'; -import {view, ViewType} from 'Knoin/Knoin'; +import {popup} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; -@view({ +@popup({ name: 'View/Popup/WelcomePage', - type: ViewType.Popup, templateID: 'PopupsWelcomePage' }) class WelcomePagePopupView extends AbstractViewNext @@ -45,4 +44,4 @@ class WelcomePagePopupView extends AbstractViewNext } } -module.exports = WelcomePagePopupView; +export {WelcomePagePopupView, WelcomePagePopupView as default}; diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 1dcf74403..3f5d97a69 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -22,8 +22,7 @@ import { import { inArray, isArray, isNonEmptyArray, trim, noop, windowResize, windowResizeCallback, inFocus, - removeSelection, removeInFocus, mailToHelper, - createCommand + removeSelection, removeInFocus, mailToHelper } from 'Common/Utils'; import Audio from 'Common/Audio'; @@ -52,7 +51,7 @@ import Promises from 'Promises/User/Ajax'; import {getApp} from 'Helper/Apps/User'; -import {view, command, ViewType, showScreenPopup} from 'Knoin/Knoin'; +import {view, command, ViewType, showScreenPopup, createCommand} from 'Knoin/Knoin'; import {AbstractViewNext} from 'Knoin/AbstractViewNext'; @view({ diff --git a/dev/admin.js b/dev/admin.js index 75b836765..d551991ad 100644 --- a/dev/admin.js +++ b/dev/admin.js @@ -1,4 +1,4 @@ - +/* @flow */ import bootstrap from 'bootstrap'; import App from 'App/Admin'; diff --git a/dev/app.js b/dev/app.js index 08aa049d5..7c6b53d1c 100644 --- a/dev/app.js +++ b/dev/app.js @@ -1,4 +1,4 @@ - +/* @flow */ import bootstrap from 'bootstrap'; import App from 'App/User'; diff --git a/dev/bootstrap.js b/dev/bootstrap.js index 1a7b99f79..5ded282af 100644 --- a/dev/bootstrap.js +++ b/dev/bootstrap.js @@ -1,4 +1,4 @@ - +/* @flow */ import window from 'window'; import {killCtrlACtrlS, detectDropdownVisibility, createCommandLegacy, domReady} from 'Common/Utils'; import {$win, $html, data as GlobalsData, bMobileDevice} from 'Common/Globals'; diff --git a/gulpfile.js b/gulpfile.js index 56c84cf36..18187832b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -391,20 +391,33 @@ gulp.task('js:admin', ['js:webpack'], function() { }); // - min -gulp.task('js:min', ['js:app', 'js:admin'], function() { +gulp.task('js:es5:min', ['js:app', 'js:admin'], function() { return gulp.src(cfg.paths.staticJS + '*.js') .pipe(ignore.exclude('*.next.js')) .pipe(replace(/"rainloop\/v\/([^\/]+)\/static\/js\/"/g, '"rainloop/v/$1/static/js/min/"')) .pipe(rename({suffix: '.min'})) .pipe(uglify({ mangle: true, - compress: true + compress: true, + 'screw-ie8': true })) .pipe(eol('\n', true)) .pipe(gulp.dest(cfg.paths.staticMinJS)) .on('error', gutil.log); }); +gulp.task('js:es6:min', ['js:app', 'js:admin'], function() { + return cfg.next ? gulp.src(cfg.paths.staticJS + '*.next.js') + .pipe(replace(/"rainloop\/v\/([^\/]+)\/static\/js\/"/g, '"rainloop/v/$1/static/js/min/"')) + // TODO + .pipe(eol('\n', true)) + .pipe(rename({suffix: '.min'})) + .pipe(gulp.dest(cfg.paths.staticMinJS)) + .on('error', gutil.log) : true; +}); + +gulp.task('js:min', ['js:es5:min', 'js:es6:min']); + // lint gulp.task('js:eslint', function() { return gulp.src(cfg.paths.globjs) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index ea27ddfc1..91d170c25 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -162,9 +162,9 @@ "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz" }, "async-each": { - "version": "1.0.0", + "version": "1.0.1", "from": "async-each@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.0.tgz" + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz" }, "autolinker": { "version": "1.1.0", @@ -633,9 +633,9 @@ "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz" }, "binary-extensions": { - "version": "1.5.0", + "version": "1.6.0", "from": "binary-extensions@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.5.0.tgz" + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.6.0.tgz" }, "binaryextensions": { "version": "1.0.1", @@ -685,9 +685,9 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz" }, "brorand": { - "version": "1.0.5", + "version": "1.0.6", "from": "brorand@>=1.0.1 <2.0.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz" + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.6.tgz" }, "browserify-aes": { "version": "1.0.6", @@ -940,7 +940,17 @@ "readable-stream": { "version": "2.0.6", "from": "readable-stream@>=2.0.0 <2.1.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "dependencies": { + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -1161,7 +1171,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -1191,9 +1215,9 @@ "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz" }, "enhanced-resolve": { - "version": "2.2.2", + "version": "2.3.0", "from": "enhanced-resolve@>=2.2.0 <3.0.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-2.2.2.tgz" + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-2.3.0.tgz" }, "errno": { "version": "0.1.4", @@ -1738,7 +1762,22 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.1.4 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -1878,7 +1917,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.2 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -1994,7 +2047,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -2187,9 +2254,9 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.5.tgz" }, "inherits": { - "version": "2.0.1", + "version": "2.0.3", "from": "inherits@>=2.0.1 <2.1.0", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" }, "ini": { "version": "1.3.4", @@ -2964,7 +3031,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -3367,7 +3448,14 @@ "supports-color": { "version": "3.1.2", "from": "supports-color@>=3.1.2 <4.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz" + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "dependencies": { + "has-flag": { + "version": "1.0.0", + "from": "has-flag@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" + } + } } } }, @@ -3402,9 +3490,9 @@ "resolved": "https://registry.npmjs.org/private/-/private-0.1.6.tgz" }, "process": { - "version": "0.11.8", + "version": "0.11.9", "from": "process@>=0.11.0 <0.12.0", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.8.tgz" + "resolved": "https://registry.npmjs.org/process/-/process-0.11.9.tgz" }, "process-nextick-args": { "version": "1.0.7", @@ -3647,7 +3735,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -3910,7 +4012,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.2 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -3937,7 +4053,21 @@ "readable-stream": { "version": "2.1.5", "from": "readable-stream@>=2.0.2 <3.0.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "dependencies": { + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0" + } + } } } }, @@ -4046,7 +4176,19 @@ "readable-stream": { "version": "2.0.6", "from": "readable-stream@>=2.0.0 <2.1.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz" + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "dependencies": { + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz" + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + } + } } } }, @@ -4241,7 +4383,14 @@ "util": { "version": "0.10.3", "from": "util@>=0.10.3 <0.11.0", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz" + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "dependencies": { + "inherits": { + "version": "2.0.1", + "from": "inherits@2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + } + } }, "util-deprecate": { "version": "1.0.2", @@ -4338,9 +4487,9 @@ "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz" }, "webpack": { - "version": "2.1.0-beta.21", - "from": "webpack@>=2.1.0-beta.21 <3.0.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-2.1.0-beta.21.tgz", + "version": "2.1.0-beta.22", + "from": "webpack@2.1.0-beta.22", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-2.1.0-beta.22.tgz", "dependencies": { "async": { "version": "1.5.2", diff --git a/package.json b/package.json index f5496f83d..9adb4ce14 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "style-loader": "^0.13.1", "tinycon": "github:tommoor/tinycon", "underscore": "^1.8.3", - "webpack": "^2.1.0-beta.21", + "webpack": "2.1.0-beta.22", "webpack-notifier": "1.4.1" } } diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsFilter.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsFilter.html index b82169a7e..47d2d4c75 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsFilter.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsFilter.html @@ -1,64 +1,64 @@ -
- -
+
+ +
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsFolderCreate.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsFolderCreate.html index 82b86e105..b1c57bc2e 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsFolderCreate.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsFolderCreate.html @@ -1,42 +1,42 @@ -
- -
+
+ +
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorTest.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorTest.html index 92cc80b06..ae416930c 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorTest.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorTest.html @@ -1,34 +1,34 @@ -
- -
+
+ +
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/SettingsFilters.html b/rainloop/v/0.0.0/app/templates/Views/User/SettingsFilters.html index 6f2454cdf..eb3132d01 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/SettingsFilters.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/SettingsFilters.html @@ -1,106 +1,106 @@ -
-
-
- -     - -
-
-
- -
-
-
-
-
- -    - -
-
-
-
-
-
- -    - -
-
-
-
-
-
-
-
-
-
-						:
-						
-					
- -
-
-
-
- - - - - - - - - - - - - - - - - -
- - - - - - - -    - - - - - - - - - -
-
-
-
-
+
+
+
+ +     + +
+
+
+ +
+
+
+
+
+ +    + +
+
+
+
+
+
+ +    + +
+
+
+
+
+
+
+
+
+
+						:
+						
+					
+ +
+
+
+
+ + + + + + + + + + + + + + + + + +
+ + + + + + + +    + + + + + + + + + +
+
+
+
+
\ No newline at end of file diff --git a/rainloop/v/0.0.0/app/templates/Views/User/SettingsSocial.html b/rainloop/v/0.0.0/app/templates/Views/User/SettingsSocial.html index be95614d7..397cd25be 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/SettingsSocial.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/SettingsSocial.html @@ -1,101 +1,101 @@ -
-
-
- -
-
- -
-
-
-

-
-
-
- - -    - - -
-
- -
-
-
-
- -
-
- -
-
-
-

-
-
-
- - -    - - -
-
- -
-
-
-
- -
-
- -
-
-
-

-
-
-
- - -    - - -
-
- -
-
+
+
+
+ +
+
+ +
+
+
+

+
+
+
+ + +    + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+

+
+
+
+ + +    + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+

+
+
+
+ + +    + + +
+
+ +
+
\ No newline at end of file diff --git a/webpack.config.builder.js b/webpack.config.builder.js index 72b512fc6..00cc0b179 100644 --- a/webpack.config.builder.js +++ b/webpack.config.builder.js @@ -3,9 +3,9 @@ var path = require('path'), webpack = require('webpack'), devPath = path.resolve(__dirname, 'dev'), - CopyWebpackPlugin = require('copy-webpack-plugin'), - WebpackNotifierPlugin = require('webpack-notifier'); + WebpackNotifierPlugin = require('webpack-notifier'), + loose = true; module.exports = function(publicPath, pro, es6) { return { @@ -54,29 +54,29 @@ module.exports = function(publicPath, pro, es6) { include: [devPath], query: !es6 ? { cacheDirectory: true, - presets: [['es2015', {loose: true, modules: false}], 'es2016', 'stage-0'], + presets: [['es2015', {loose: loose, modules: false}], 'es2016', 'stage-0'], plugins: ['transform-runtime', 'transform-decorators-legacy'] } : { cacheDirectory: true, plugins: [ // es2015 -["transform-es2015-template-literals", {loose: true}], +["transform-es2015-template-literals", {loose: loose}], "transform-es2015-literals", "transform-es2015-function-name", // ["transform-es2015-arrow-functions")], "transform-es2015-block-scoped-functions", -// ["transform-es2015-classes", {loose: true}], +// ["transform-es2015-classes", {loose: loose}], // "transform-es2015-object-super", "transform-es2015-shorthand-properties", "transform-es2015-duplicate-keys", -["transform-es2015-computed-properties", {loose: true}], -["transform-es2015-for-of", {loose: true}], +["transform-es2015-computed-properties", {loose: loose}], +["transform-es2015-for-of", {loose: loose}], "transform-es2015-sticky-regex", "transform-es2015-unicode-regex", // "check-es2015-constants", -//["transform-es2015-spread", {loose: true}], +//["transform-es2015-spread", {loose: loose}], // "transform-es2015-parameters", -//["transform-es2015-destructuring", {loose: true}], +//["transform-es2015-destructuring", {loose: loose}], // "transform-es2015-block-scoping", "transform-es2015-typeof-symbol", // ["transform-regenerator", { async: false, asyncGenerators: false }],