summaryrefslogtreecommitdiffstats
path: root/client/components/forms
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-05-26 20:30:01 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-05-26 20:34:56 +0200
commit40c2411f2a1ce0bbd177f377828f9d6700112b06 (patch)
treebf1f7ab8d94fe3e0edfcde817961d6954c11af4d /client/components/forms
parent1b4fcc67f4ec94ed53a2f86ad6889e551f00815e (diff)
downloadwekan-40c2411f2a1ce0bbd177f377828f9d6700112b06.tar.gz
wekan-40c2411f2a1ce0bbd177f377828f9d6700112b06.tar.bz2
wekan-40c2411f2a1ce0bbd177f377828f9d6700112b06.zip
Implement a new system to handle "escape actions"
The new EscapeActions object decide what to do when the user press the Escape key (such as closing a opened popup or inlined form). This commit also re-introduced the sidebar current view as a sidebar component local state.
Diffstat (limited to 'client/components/forms')
-rw-r--r--client/components/forms/inlinedform.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/client/components/forms/inlinedform.js b/client/components/forms/inlinedform.js
index 2e2b2eba..200a6f9d 100644
--- a/client/components/forms/inlinedform.js
+++ b/client/components/forms/inlinedform.js
@@ -15,7 +15,9 @@
// We can only have one inlined form element opened at a time
// XXX Could we avoid using a global here ? This is used in Mousetrap
// keyboard.js
-currentlyOpenedForm = new ReactiveVar(null);
+var currentlyOpenedForm = new ReactiveVar(null);
+
+var inlinedFormEscapePriority = 30;
BlazeComponent.extendComponent({
template: function() {
@@ -32,9 +34,10 @@ BlazeComponent.extendComponent({
open: function() {
// Close currently opened form, if any
- if (currentlyOpenedForm.get() !== null) {
- currentlyOpenedForm.get().close();
- }
+ // if (currentlyOpenedForm.get() !== null) {
+ // currentlyOpenedForm.get().close();
+ // }
+ EscapeActions.executeLowerThan(inlinedFormEscapePriority);
this.isOpen.set(true);
currentlyOpenedForm.set(this);
},
@@ -46,7 +49,8 @@ BlazeComponent.extendComponent({
},
getValue: function() {
- return this.isOpen.get() && this.find('textarea,input[type=text]').value;
+ var input = this.find('textarea,input[type=text]');
+ return this.isOpen.get() && input && input.value;
},
saveValue: function() {
@@ -66,7 +70,7 @@ BlazeComponent.extendComponent({
'keydown form input, keydown form textarea': function(evt) {
if (evt.keyCode === 27) {
evt.preventDefault();
- this.close();
+ EscapeActions.executeLowest();
}
},
@@ -91,3 +95,9 @@ BlazeComponent.extendComponent({
}];
}
}).register('inlinedForm');
+
+// Press escape to close the currently opened inlinedForm
+EscapeActions.register(inlinedFormEscapePriority,
+ function() { return currentlyOpenedForm.get() !== null; },
+ function() { currentlyOpenedForm.get().close(); }
+);