Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Andrey Antukh
2022-02-01 16:14:52 +01:00
13 changed files with 178 additions and 72 deletions

View File

@@ -56,29 +56,33 @@
(update :undo-changes d/preconj del-change)))))
(defn change-parent
[changes parent-id shapes]
(assert (contains? (meta changes) ::objects) "Call (with-objects) first to use this function")
([changes parent-id shapes] (change-parent changes parent-id shapes nil))
([changes parent-id shapes index]
(assert (contains? (meta changes) ::objects) "Call (with-objects) first to use this function")
(let [objects (::objects (meta changes))
set-parent-change
{:type :mov-objects
:parent-id parent-id
:page-id (::page-id (meta changes))
:shapes (->> shapes (mapv :id))}
(let [objects (::objects (meta changes))
set-parent-change
(cond-> {:type :mov-objects
:parent-id parent-id
:page-id (::page-id (meta changes))
:shapes (->> shapes (mapv :id))}
mk-undo-change
(fn [change-set shape]
(d/preconj
change-set
{:type :mov-objects
:page-id (::page-id (meta changes))
:parent-id (:parent-id shape)
:shapes [(:id shape)]
:index (cp/position-on-parent (:id shape) objects)}))]
(some? index)
(assoc :index index))
(-> changes
(update :redo-changes conj set-parent-change)
(update :undo-changes #(reduce mk-undo-change % shapes)))))
mk-undo-change
(fn [change-set shape]
(d/preconj
change-set
{:type :mov-objects
:page-id (::page-id (meta changes))
:parent-id (:parent-id shape)
:shapes [(:id shape)]
:index (cp/position-on-parent (:id shape) objects)}))]
(-> changes
(update :redo-changes conj set-parent-change)
(update :undo-changes #(reduce mk-undo-change % shapes))))))
(defn- generate-operation
"Given an object old and new versions and an attribute will append into changes

View File

@@ -255,7 +255,7 @@
(let [data (s/explain-data spec data)]
(throw (ex/error :type :validation
:code :spec-validation
::s/problems (::s/problems data)))))
::ex/data data))))
result))
(defmacro instrument!