2015-12-14 20:31:21 +02:00
|
|
|
(ns uxbox.ui.workspace
|
|
|
|
(:require [sablono.core :as html :refer-macros [html]]
|
|
|
|
[rum.core :as rum]
|
|
|
|
[uxbox.router :as r]
|
|
|
|
[uxbox.rstore :as rs]
|
|
|
|
[uxbox.state :as s]
|
2015-12-20 20:19:07 +02:00
|
|
|
[uxbox.data.workspace :as dw]
|
2015-12-17 16:43:58 +02:00
|
|
|
[uxbox.ui.util :as util]
|
2015-12-17 18:34:15 +02:00
|
|
|
[uxbox.ui.mixins :as mx]
|
2015-12-23 00:42:24 +02:00
|
|
|
[uxbox.ui.workspace.keyboard :as wkbd]
|
2015-12-17 12:51:36 +02:00
|
|
|
[uxbox.ui.workspace.base :as wb]
|
2015-12-18 17:42:42 +02:00
|
|
|
[uxbox.ui.workspace.lateralmenu :refer (lateralmenu)]
|
|
|
|
[uxbox.ui.workspace.pagesmngr :refer (pagesmngr)]
|
|
|
|
[uxbox.ui.workspace.header :refer (header)]
|
|
|
|
[uxbox.ui.workspace.rules :refer (h-rule v-rule)]
|
2015-12-18 19:14:57 +02:00
|
|
|
[uxbox.ui.workspace.workarea :refer (workarea aside)]))
|
2015-12-15 15:41:11 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Workspace
|
2015-12-15 13:00:10 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2015-12-14 20:31:21 +02:00
|
|
|
|
2015-12-22 20:25:38 +02:00
|
|
|
(defn- workspace-render
|
2015-12-14 20:31:21 +02:00
|
|
|
[own projectid]
|
2015-12-23 00:42:24 +02:00
|
|
|
(let [workspace (rum/react wb/workspace-state)]
|
2015-12-18 19:14:57 +02:00
|
|
|
(html
|
|
|
|
[:div
|
|
|
|
(header)
|
|
|
|
[:main.main-content
|
|
|
|
[:section.workspace-content
|
|
|
|
;; Lateral Menu (left side)
|
|
|
|
(lateralmenu)
|
|
|
|
|
|
|
|
;; Pages management lightbox
|
|
|
|
(pagesmngr)
|
|
|
|
|
|
|
|
;; Rules
|
|
|
|
(h-rule)
|
|
|
|
(v-rule)
|
|
|
|
|
|
|
|
;; Canvas
|
|
|
|
(workarea)]
|
|
|
|
|
|
|
|
;; Aside
|
|
|
|
(when-not (empty? (:toolboxes workspace))
|
|
|
|
(aside))]])))
|
|
|
|
|
2015-12-22 20:25:38 +02:00
|
|
|
(defn- workspace-will-mount
|
2015-12-15 13:00:10 +02:00
|
|
|
[own]
|
|
|
|
(let [[projectid pageid] (:rum/props own)]
|
2015-12-20 20:19:07 +02:00
|
|
|
(rs/emit! (dw/initialize projectid pageid))
|
2015-12-15 13:00:10 +02:00
|
|
|
own))
|
2015-12-14 20:31:21 +02:00
|
|
|
|
2015-12-22 20:25:38 +02:00
|
|
|
(defn- workspace-transfer-state
|
2015-12-16 00:40:14 +02:00
|
|
|
[old-state state]
|
|
|
|
(let [[projectid pageid] (:rum/props state)]
|
2015-12-20 20:19:07 +02:00
|
|
|
(rs/emit! (dw/initialize projectid pageid))
|
|
|
|
state))
|
2015-12-16 00:40:14 +02:00
|
|
|
|
2015-12-14 20:31:21 +02:00
|
|
|
(def ^:static workspace
|
|
|
|
(util/component
|
|
|
|
{:render workspace-render
|
2015-12-15 13:00:10 +02:00
|
|
|
:will-mount workspace-will-mount
|
2015-12-16 00:40:14 +02:00
|
|
|
:transfer-state workspace-transfer-state
|
2015-12-14 20:31:21 +02:00
|
|
|
:name "workspace"
|
2015-12-23 00:42:24 +02:00
|
|
|
:mixins [mx/static rum/reactive wkbd/mixin]}))
|
2015-12-14 20:31:21 +02:00
|
|
|
|