0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Set renaming

This commit is contained in:
Florian Schroedl 2024-09-25 14:59:20 +02:00
parent d2ed6b5501
commit 9c1a509fa4
5 changed files with 10 additions and 28 deletions

View file

@ -292,7 +292,6 @@
[:mod-token-set
[:map {:title "ModTokenSetChange"}
[:type [:= :mod-token-set]]
[:id ::sm/uuid]
[:name :string]
[:token-set ::ctot/token-set]]]

View file

@ -745,8 +745,8 @@
(defn update-token-set
[changes token-set prev-token-set]
(-> changes
(update :redo-changes conj {:type :mod-token-set :id (:id token-set) :name (:name prev-token-set) :token-set token-set})
(update :undo-changes conj {:type :mod-token-set :id (:id token-set) :name (:name prev-token-set) :token-set (or prev-token-set token-set)})
(update :redo-changes conj {:type :mod-token-set :name (:name prev-token-set) :token-set token-set})
(update :undo-changes conj {:type :mod-token-set :name (:name prev-token-set) :token-set (or prev-token-set token-set)})
(apply-changes-local)))
(defn delete-token-set

View file

@ -19,27 +19,9 @@
[:modified-at {:optional true} ::sm/inst]
[:sets [:set {:gen/max 10 :gen/min 1} ::sm/uuid]]])
(sm/register! ::token-set-group-ref
[:map
[:id ::sm/uuid]
[:type [:= :group]]])
(sm/register! ::token-set-ref
[:map
[:id ::sm/uuid]
[:type [:= :set]]])
(sm/register! ::token-set-group
[:map {:title "TokenSetGroup"}
[:id ::sm/uuid]
[:name :string]
[:items [:vector {:gen/max 10 :gen/min 1}
[:or ::token-set-group-ref ::token-set-ref]]]])
(sm/register! ::token-set
[:map {:title "TokenSet"}
[:id ::sm/uuid]
[:name :string]
[:description {:optional true} :string]
[:description {:optional true} [:maybe :string]]
[:modified-at {:optional true} ::sm/inst]
[:tokens [:vector {:gen/max 10 :gen/min 1} ::sm/uuid]]])
[:tokens :any]])

View file

@ -182,11 +182,12 @@
(set-selected-token-set-id (:name new-token-set))
(dch/commit-changes changes)))))))
(defn update-token-set [token-set]
(defn update-token-set [set-name token-set]
(ptk/reify ::update-token-set
ptk/WatchEvent
(watch [it state _]
(let [prev-token-set (wtts/get-token-set (:id token-set) state)
(let [prev-token-set (some-> (get-tokens-lib state)
(ctob/get-set set-name))
changes (-> (pcb/empty-changes it)
(pcb/update-token-set token-set prev-token-set))]
(rx/of

View file

@ -31,8 +31,8 @@
(dom/stop-propagation event)
(st/emit! (wdt/delete-token-set (dm/legacy nil) name)))
(defn on-update-token-set [token-set]
(st/emit! (wdt/update-token-set token-set)))
(defn on-update-token-set [set-name token-set]
(st/emit! (wdt/update-token-set set-name token-set)))
(defn on-create-token-set [token-set]
(st/emit! (wdt/create-token-set token-set)))
@ -159,7 +159,7 @@
:on-edit on-edit
:on-toggle on-toggle-token-set
:on-submit #(do
(on-update-token-set %)
(on-update-token-set (:name token-set) %)
(on-reset))
:on-cancel on-reset}]))
(when new?