mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -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 :as cto]
|
||||||
[app.common.types.token-theme :as ctot]
|
[app.common.types.token-theme :as ctot]
|
||||||
[app.common.types.tokens-list :as ctol]
|
[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.typographies-list :as ctyl]
|
||||||
[app.common.types.typography :as ctt]
|
[app.common.types.typography :as ctt]
|
||||||
[clojure.set :as set]))
|
[clojure.set :as set]))
|
||||||
|
@ -256,7 +257,8 @@
|
||||||
[:mod-token-set
|
[:mod-token-set
|
||||||
[:map {:title "ModTokenSetChange"}
|
[:map {:title "ModTokenSetChange"}
|
||||||
[:type [:= :mod-token-set]]
|
[:type [:= :mod-token-set]]
|
||||||
[:id ::ctot/token-set]]]
|
[:id ::sm/uuid]
|
||||||
|
[:token-set ::ctot/token-set]]]
|
||||||
|
|
||||||
[:del-token-set
|
[:del-token-set
|
||||||
[:map {:title "DelTokenSetChange"}
|
[:map {:title "DelTokenSetChange"}
|
||||||
|
@ -758,6 +760,18 @@
|
||||||
[data {:keys [id]}]
|
[data {:keys [id]}]
|
||||||
(ctol/delete-token data 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
|
;; === Operations
|
||||||
(defmethod process-operation :set
|
(defmethod process-operation :set
|
||||||
[on-changed shape op]
|
[on-changed shape op]
|
||||||
|
|
|
@ -716,7 +716,7 @@
|
||||||
prev-token-set (get-in library-data [:token-set token-set-id])]
|
prev-token-set (get-in library-data [:token-set token-set-id])]
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes conj {:type :del-token-set :id token-set-id})
|
(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))))
|
(apply-changes-local))))
|
||||||
|
|
||||||
(defn add-token
|
(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
|
create-set? (-> token-changes
|
||||||
(pcb/add-token-set {:id (uuid/next)
|
(pcb/add-token-set {:id (uuid/next)
|
||||||
:name "Global"
|
:name "Global"
|
||||||
:items [(:id token)]}))
|
:tokens [(:id token)]}))
|
||||||
:else (let [updated-token-set (if (contains? token-set (:id token))
|
:else (let [updated-token-set (if (contains? token-set (:id token))
|
||||||
token-set
|
token-set
|
||||||
(update token-set :items conj (:id token)))]
|
(update token-set :tokens conj (:id token)))]
|
||||||
(-> token-changes
|
(-> token-changes
|
||||||
(pcb/update-token-set token-set updated-token-set))))]
|
(pcb/update-token-set token-set updated-token-set))))]
|
||||||
|
(js/console.log "changes" changes)
|
||||||
(rx/of (dch/commit-changes changes)))))))
|
(rx/of (dch/commit-changes changes)))))))
|
||||||
|
|
||||||
(defn delete-token
|
(defn delete-token
|
||||||
|
|
Loading…
Add table
Reference in a new issue