🐛 Fix problem with changes files

This commit is contained in:
alonso.torres 2024-02-09 13:08:49 +01:00 committed by Andrés Moya
parent c17d2c1aba
commit 9f6b82dfc0
2 changed files with 59 additions and 51 deletions

View file

@ -41,7 +41,9 @@
(let [changes (empty-changes origin)] (let [changes (empty-changes origin)]
(with-meta changes (with-meta changes
{::page-id page-id}))) {::page-id page-id})))
([]
{:redo-changes []
:undo-changes '()})
([origin] ([origin]
{:redo-changes [] {:redo-changes []
:undo-changes '() :undo-changes '()
@ -109,13 +111,9 @@
(defn concat-changes (defn concat-changes
[changes1 changes2] [changes1 changes2]
{:redo-changes (d/concat-vec (:redo-changes changes1) (-> changes1
(:redo-changes changes2)) (update :redo-changes d/concat-vec (:redo-changes changes2))
:undo-changes (concat (:undo-changes changes1) (update :undo-changes d/concat-vec (:undo-changes changes2))))
(:undo-changes changes2))
:origin (:origin changes1)
:undo-group (:undo-group changes1)
:tags (:tags changes1)})
; TODO: remove this when not needed ; TODO: remove this when not needed
(defn- assert-page-id! (defn- assert-page-id!

View file

@ -1393,7 +1393,9 @@
(defn- update-flex-child-copy-attrs (defn- update-flex-child-copy-attrs
"Synchronizes the attributes inside the flex-child items (main->copy)" "Synchronizes the attributes inside the flex-child items (main->copy)"
[changes _shape-main shape-copy main-container main-component copy-container omit-touched?] [changes _shape-main shape-copy main-container main-component copy-container omit-touched?]
(-> changes (let [do-changes
(fn [cc]
(-> cc
(pcb/with-container copy-container) (pcb/with-container copy-container)
(pcb/with-objects (:objects copy-container)) (pcb/with-objects (:objects copy-container))
(pcb/update-shapes (pcb/update-shapes
@ -1402,12 +1404,14 @@
(let [child-main (ctf/get-ref-shape main-container main-component child-copy)] (let [child-main (ctf/get-ref-shape main-container main-component child-copy)]
(-> child-copy (-> child-copy
(propagate-attrs child-main ctk/swap-keep-attrs omit-touched?)))) (propagate-attrs child-main ctk/swap-keep-attrs omit-touched?))))
{:ignore-touched true}))) {:ignore-touched true})))]
(pcb/concat-changes changes (do-changes (pcb/empty-changes)))))
(defn- update-flex-child-main-attrs (defn- update-flex-child-main-attrs
"Synchronizes the attributes inside the flex-child items (copy->main)" "Synchronizes the attributes inside the flex-child items (copy->main)"
[changes shape-main shape-copy main-container copy-container omit-touched?] [changes shape-main shape-copy main-container copy-container omit-touched?]
(-> changes (let [new-changes
(-> (pcb/empty-changes)
(pcb/with-page main-container) (pcb/with-page main-container)
(pcb/with-objects (:objects main-container)) (pcb/with-objects (:objects main-container))
(pcb/update-shapes (pcb/update-shapes
@ -1416,7 +1420,8 @@
(let [child-copy (ctf/get-shape-in-copy copy-container child-main shape-copy)] (let [child-copy (ctf/get-shape-in-copy copy-container child-main shape-copy)]
(-> child-main (-> child-main
(propagate-attrs child-copy ctk/swap-keep-attrs omit-touched?)))) (propagate-attrs child-copy ctk/swap-keep-attrs omit-touched?))))
{:ignore-touched true}))) {:ignore-touched true}))]
(pcb/concat-changes changes new-changes)))
(defn- update-grid-copy-attrs (defn- update-grid-copy-attrs
"Synchronizes the `layout-grid-cells` property from the main shape to the copies" "Synchronizes the `layout-grid-cells` property from the main shape to the copies"
@ -1429,9 +1434,10 @@
(fn [copy-shape] (fn [copy-shape]
(let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)] (let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)]
[(:id main-shape) (:id copy-shape)])))) [(:id main-shape) (:id copy-shape)]))))
(:shapes shape-copy))] (:shapes shape-copy))
(-> changes new-changes
(-> (pcb/empty-changes)
(pcb/with-container copy-container) (pcb/with-container copy-container)
(pcb/with-objects (:objects copy-container)) (pcb/with-objects (:objects copy-container))
(pcb/update-shapes (pcb/update-shapes
@ -1441,7 +1447,8 @@
(let [copy-cells (:layout-grid-cells shape-copy) (let [copy-cells (:layout-grid-cells shape-copy)
main-cells (-> (ctl/remap-grid-cells shape-main ids-map) :layout-grid-cells)] main-cells (-> (ctl/remap-grid-cells shape-main ids-map) :layout-grid-cells)]
(assoc shape-copy :layout-grid-cells (ctl/merge-cells copy-cells main-cells omit-touched?)))) (assoc shape-copy :layout-grid-cells (ctl/merge-cells copy-cells main-cells omit-touched?))))
{:ignore-touched true})))) {:ignore-touched true}))]
(pcb/concat-changes changes new-changes)))
(defn- update-grid-main-attrs (defn- update-grid-main-attrs
"Synchronizes the `layout-grid-cells` property from the copy to the main shape" "Synchronizes the `layout-grid-cells` property from the copy to the main shape"
@ -1454,8 +1461,10 @@
(fn [main-shape] (fn [main-shape]
(let [copy-shape (ctf/get-shape-in-copy copy-container main-shape shape-copy)] (let [copy-shape (ctf/get-shape-in-copy copy-container main-shape shape-copy)]
[(:id copy-shape) (:id main-shape)])))) [(:id copy-shape) (:id main-shape)]))))
(:shapes shape-main))] (:shapes shape-main))
(-> changes
new-changes
(-> (pcb/empty-changes)
(pcb/with-page main-container) (pcb/with-page main-container)
(pcb/with-objects (:objects main-container)) (pcb/with-objects (:objects main-container))
(pcb/update-shapes (pcb/update-shapes
@ -1464,7 +1473,8 @@
;; Take cells from copy and remap the shapes to assign it to the copy ;; Take cells from copy and remap the shapes to assign it to the copy
(let [new-cells (-> (ctl/remap-grid-cells shape-copy ids-map) :layout-grid-cells)] (let [new-cells (-> (ctl/remap-grid-cells shape-copy ids-map) :layout-grid-cells)]
(assoc shape-main :layout-grid-cells new-cells))) (assoc shape-main :layout-grid-cells new-cells)))
{:ignore-touched true})))) {:ignore-touched true}))]
(pcb/concat-changes changes new-changes)))
(defn- reposition-shape (defn- reposition-shape
[shape origin-root dest-root] [shape origin-root dest-root]