mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
Fix schema errors
This commit is contained in:
parent
547358d579
commit
bcd4b6d9ec
4 changed files with 57 additions and 4 deletions
|
@ -26,6 +26,7 @@
|
|||
[app.common.types.token :as cto]
|
||||
[app.common.types.token-theme :as ctot]
|
||||
[app.common.types.tokens-list :as ctol]
|
||||
[app.common.types.tokens-theme-list :as ctotl]
|
||||
[app.common.types.typographies-list :as ctyl]
|
||||
[app.common.types.typography :as ctt]
|
||||
[clojure.set :as set]))
|
||||
|
@ -256,7 +257,8 @@
|
|||
[:mod-token-set
|
||||
[:map {:title "ModTokenSetChange"}
|
||||
[:type [:= :mod-token-set]]
|
||||
[:id ::ctot/token-set]]]
|
||||
[:id ::sm/uuid]
|
||||
[:token-set ::ctot/token-set]]]
|
||||
|
||||
[:del-token-set
|
||||
[:map {:title "DelTokenSetChange"}
|
||||
|
@ -758,6 +760,18 @@
|
|||
[data {:keys [id]}]
|
||||
(ctol/delete-token data id))
|
||||
|
||||
(defmethod process-change :add-token-set
|
||||
[data {:keys [token-set]}]
|
||||
(ctotl/add-token-set data token-set))
|
||||
|
||||
(defmethod process-change :mod-token-set
|
||||
[data {:keys [id token-set]}]
|
||||
(ctotl/update-token-set data id merge token-set))
|
||||
|
||||
(defmethod process-change :del-token-set
|
||||
[data {:keys [id]}]
|
||||
(ctotl/delete-token-set data id))
|
||||
|
||||
;; === Operations
|
||||
(defmethod process-operation :set
|
||||
[on-changed shape op]
|
||||
|
|
|
@ -716,7 +716,7 @@
|
|||
prev-token-set (get-in library-data [:token-set token-set-id])]
|
||||
(-> changes
|
||||
(update :redo-changes conj {:type :del-token-set :id token-set-id})
|
||||
(update :undo-changes conj {:type :add-token-set :token prev-token-set})
|
||||
(update :undo-changes conj {:type :add-token-set :token-set prev-token-set})
|
||||
(apply-changes-local))))
|
||||
|
||||
(defn add-token
|
||||
|
|
38
common/src/app/common/types/tokens_theme_list.cljc
Normal file
38
common/src/app/common/types/tokens_theme_list.cljc
Normal file
|
@ -0,0 +1,38 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.common.types.tokens-theme-list
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.time :as dt]))
|
||||
|
||||
(defn- touch
|
||||
"Updates the `modified-at` timestamp of a token set."
|
||||
[token-set]
|
||||
(assoc token-set :modified-at (dt/now)))
|
||||
|
||||
(defn add-token-set
|
||||
[file-data {:keys [index id] :as token-set}]
|
||||
(-> file-data
|
||||
(update :token-set-groups
|
||||
(fn [token-set-groups]
|
||||
(let [exists? (some (partial = id) token-set-groups)]
|
||||
(cond
|
||||
exists? token-set-groups
|
||||
(nil? index) (conj token-set-groups id)
|
||||
:else (d/insert-at-index token-set-groups index [id])))))
|
||||
(update :token-sets-index assoc id token-set)))
|
||||
|
||||
(defn update-token-set
|
||||
[file-data token-id f & args]
|
||||
#_(ex/raise :type :not-implemented)
|
||||
file-data)
|
||||
|
||||
(defn delete-token-set
|
||||
[file-data token-id]
|
||||
#_(ex/raise :type :not-implemented)
|
||||
file-data)
|
|
@ -113,12 +113,13 @@
|
|||
create-set? (-> token-changes
|
||||
(pcb/add-token-set {:id (uuid/next)
|
||||
:name "Global"
|
||||
:items [(:id token)]}))
|
||||
:tokens [(:id token)]}))
|
||||
:else (let [updated-token-set (if (contains? token-set (:id token))
|
||||
token-set
|
||||
(update token-set :items conj (:id token)))]
|
||||
(update token-set :tokens conj (:id token)))]
|
||||
(-> token-changes
|
||||
(pcb/update-token-set token-set updated-token-set))))]
|
||||
(js/console.log "changes" changes)
|
||||
(rx/of (dch/commit-changes changes)))))))
|
||||
|
||||
(defn delete-token
|
||||
|
|
Loading…
Add table
Reference in a new issue