From f3d4346c0dff3d1586f8d0c3fdf9984610c07e87 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Thu, 15 Aug 2024 18:52:42 +0200 Subject: [PATCH] Add create token-set event --- frontend/src/app/main/data/tokens.cljs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index ddd5f5550..fffd64c65 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -20,6 +20,7 @@ [clojure.data :as data] [cuerdas.core :as str] [potok.v2.core :as ptk] + [app.main.ui.workspace.tokens.changes :as wdt] [app.main.ui.workspace.tokens.token-set :as wtts])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -87,6 +88,20 @@ (update [_ state] (wtts/assoc-selected-token-set-id state id)))) +(defn create-token-set [token-set] + (let [new-token-set (merge + {:id (uuid/next) + :name "Token Set" + :tokens []} + token-set)] + (ptk/reify ::update-create-token + ptk/WatchEvent + (watch [it _ _] + (let [changes (-> (pcb/empty-changes it) + (pcb/add-token-set new-token-set))] + (rx/of + (dch/commit-changes changes))))))) + (defn update-create-token [token] (let [token (update token :id #(or % (uuid/next)))]