Skip to content

Commit

Permalink
workspace duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jun 8, 2016
1 parent ea0e451 commit f892a44
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/cljs/ulysses/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,31 @@
; TODO
db))

(register-handler
:workspace-new-duplicate
(fn [db _]
(if-let [op (:builder-grant-op db)]
(if-let [current (:builder-workspace db)]
(let [id (-> db :workspaces new-id)]
(dispatch [:workspace-switch id])
; NOTE TEMP transfer faculty one by one
(doseq [faculty-id (:builder-workspace-faculties db)]
(dispatch [:add-working-faculty faculty-id]))
(-> db
(update :workspaces
(fn [ws]
(conj ws
; modify current with new id and name mod
(-> current
(assoc :id id)
(update :name #(str % " (dup)"))))))))
; on the default ws
(do
(dispatch [:workspace-new-default])
db))
; no grant op
db)))

; rename current workspace
(register-handler
:workspace-rename
Expand Down
3 changes: 2 additions & 1 deletion src/cljs/ulysses/pages/builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@
[:h3 "Working Team"]
[:div.workspace-actions
[hink #(dispatch [:workspace-new-blank]) btn-attrs "New Blank"]
[hink #(dispatch [:workspace-new-default]) btn-attrs "New from Default"]]]
[hink #(dispatch [:workspace-new-default]) btn-attrs "New from Default"]
[hink #(dispatch [:workspace-new-duplicate]) btn-attrs "Duplicate"]]]
[workspace-header-tabs workspaces workspace-current]]))

(defn workspace-rename [workspace-current]
Expand Down

0 comments on commit f892a44

Please sign in to comment.