Token theme deletion

This commit is contained in:
Florian Schroedl 2024-09-25 08:16:29 +02:00
parent 844819a50c
commit ec96e7918d
5 changed files with 20 additions and 17 deletions

View file

@ -281,7 +281,7 @@
[:del-token-theme
[:map {:title "DelTokenThemeChange"}
[:type [:= :del-token-theme]]
[:id ::sm/uuid]
[:group :string]
[:name :string]]]
[:add-token-set
@ -885,9 +885,8 @@
(update :sets (partial set-ids->names data))))))))))
(defmethod process-change :del-token-theme
[data {:keys [id group name]}]
[data {:keys [group name]}]
(-> data
(ctotl/delete-token-theme id)
(update :tokens-lib
#(-> %
(ctob/ensure-tokens-lib)

View file

@ -20,7 +20,8 @@
[app.common.types.component :as ctk]
[app.common.types.file :as ctf]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]))
[app.common.uuid :as uuid]
[app.common.types.tokens-lib :as ctob]))
;; Auxiliary functions to help create a set of changes (undo + redo)
@ -724,12 +725,13 @@
(apply-changes-local)))
(defn delete-token-theme
[changes token-theme-id]
[changes group name]
(assert-library! changes)
(let [library-data (::library-data (meta changes))
prev-token-theme (get-in library-data [:token-themes-index token-theme-id])]
prev-token-theme (some-> (get library-data :tokens-lib)
(ctob/get-theme group name))]
(-> changes
(update :redo-changes conj {:type :del-token-theme :id token-theme-id :name (:name prev-token-theme)})
(update :redo-changes conj {:type :del-token-theme :group group :name name})
(update :undo-changes conj {:type :add-token-theme :token-theme prev-token-theme})
(apply-changes-local))))