diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-08-31 15:09:53 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-08-31 15:52:16 +0200 |
commit | d644cba38ff06369cc43c1ebd08d344fd1d248ea (patch) | |
tree | bad4bcef1f549132792301cf134b3c8234ad1d13 /client/lib/escapeActions.js | |
parent | cc88e78483d2f39048d3558193f0c82b711c12c8 (diff) | |
download | wekan-d644cba38ff06369cc43c1ebd08d344fd1d248ea.tar.gz wekan-d644cba38ff06369cc43c1ebd08d344fd1d248ea.tar.bz2 wekan-d644cba38ff06369cc43c1ebd08d344fd1d248ea.zip |
Replace the component bounded `cachedValue` by a global `UnsavedEdits`
This new draft saving system is currently only implemented for the
card description and comment. We need better a component
inheritance/composition model to support this for all editable fields.
Fixes #186
Diffstat (limited to 'client/lib/escapeActions.js')
-rw-r--r-- | client/lib/escapeActions.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/client/lib/escapeActions.js b/client/lib/escapeActions.js index fa113bf3..ff793b1d 100644 --- a/client/lib/escapeActions.js +++ b/client/lib/escapeActions.js @@ -17,10 +17,10 @@ EscapeActions = { 'inlinedForm', 'detailsPane', 'multiselection', - 'sidebarView' + 'sidebarView', ], - register: function(label, action, condition = () => true, options = {}) { + register(label, action, condition = () => true, options = {}) { const priority = this.hierarchy.indexOf(label); if (priority === -1) { throw Error('You must define the label in the EscapeActions hierarchy'); @@ -33,35 +33,35 @@ EscapeActions = { let noClickEscapeOn = options.noClickEscapeOn; - this._actions[priority] = { + this._actions = _.sortBy([...this._actions, { priority, condition, action, noClickEscapeOn, - enabledOnClick - }; + enabledOnClick, + }], (action) => action.priority); }, - executeLowest: function() { + executeLowest() { return this._execute({ multipleAction: false }); }, - executeAll: function() { + executeAll() { return this._execute({ multipleActions: true }); }, - executeUpTo: function(maxLabel) { + executeUpTo(maxLabel) { return this._execute({ maxLabel: maxLabel, multipleActions: true }); }, - clickExecute: function(target, maxLabel) { + clickExecute(target, maxLabel) { if (this._nextclickPrevented) { this._nextclickPrevented = false; } else { @@ -74,18 +74,18 @@ EscapeActions = { } }, - preventNextClick: function() { + preventNextClick() { this._nextclickPrevented = true; }, - _stopClick: function(action, clickTarget) { + _stopClick(action, clickTarget) { if (! _.isString(action.noClickEscapeOn)) return false; else return $(clickTarget).closest(action.noClickEscapeOn).length > 0; }, - _execute: function(options) { + _execute(options) { const maxLabel = options.maxLabel; const multipleActions = options.multipleActions; const isClick = !! options.isClick; @@ -99,8 +99,7 @@ EscapeActions = { else maxPriority = this.hierarchy.indexOf(maxLabel); - for (let i = 0; i < this._actions.length; i++) { - let currentAction = this._actions[i]; + for (let currentAction of this._actions) { if (currentAction.priority > maxPriority) return executedAtLeastOne; |