/
routing.cljs
32 lines (28 loc) · 1.23 KB
/
routing.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns hatti.routing
(:require [om.core :as om]
[secretary.core :as sec :refer-macros [defroute]]
[hatti.views.dataview :refer [activate-view!
activate-settings-view!
activate-integrated-apps-view!]]
[hatti.shared :as shared]
[goog.events :as events]
[goog.history.EventType :as EventType])
(:import goog.History))
(defroute "/:view" {:keys [view]}
"Checks if this view is one of the allowed ones.
If so, switches the selected view via app-state."
(activate-view! view))
(defroute "/:view/:settings-section" {:keys [view settings-section]}
"Show the specific settings view"
(activate-settings-view! view settings-section))
(defroute "/:view/:integrated-apps-section/:app-type"
{:keys [view integrated-apps-section app-type]}
(activate-integrated-apps-view! view integrated-apps-section app-type))
(defn enable-dataview-routing! []
(let [history (History.)
navigation EventType/NAVIGATE]
(sec/set-config! :prefix "#")
(goog.events/listen history
navigation
#(-> % .-token sec/dispatch!))
(doto history (.setEnabled true))))