summaryrefslogtreecommitdiffstats
path: root/client/components/sidebar/sidebar.js
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/sidebar/sidebar.js
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/sidebar/sidebar.js')
-rw-r--r--client/components/sidebar/sidebar.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js
index 6e45b5cf..729bc42b 100644
--- a/client/components/sidebar/sidebar.js
+++ b/client/components/sidebar/sidebar.js
@@ -1,3 +1,7 @@
+var defaultView = 'home';
+
+Sidebar = null;
+
BlazeComponent.extendComponent({
template: function() {
return 'sidebar';
@@ -9,9 +13,14 @@ BlazeComponent.extendComponent({
onCreated: function() {
this._isOpen = new ReactiveVar(! Session.get('currentCard'));
+ this._view = new ReactiveVar(defaultView);
Sidebar = this;
},
+ onDestroyed: function() {
+ Sidebar = null;
+ },
+
isOpen: function() {
return this._isOpen.get();
},
@@ -43,7 +52,20 @@ BlazeComponent.extendComponent({
},
isTongueHidden: function() {
- return this.isOpen() && Filter.isActive();
+ return this.isOpen() && this.getView() !== defaultView;
+ },
+
+ getView: function() {
+ return this._view.get();
+ },
+
+ setView: function(view) {
+ view = view || defaultView;
+ this._view.set(view);
+ },
+
+ getViewTemplate: function() {
+ return this.getView() + 'Sidebar';
},
onRendered: function() {
@@ -74,3 +96,8 @@ BlazeComponent.extendComponent({
}]);
}
}).register('sidebar');
+
+EscapeActions.register(40,
+ function() { return Sidebar && Sidebar.getView() !== defaultView; },
+ function() { Sidebar.setView(defaultView); }
+);