mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
🐛 Fix design review bugs on variants advanced retrieve (#6948)
This commit is contained in:
parent
9a6989d2ca
commit
b477ca0508
@ -99,7 +99,9 @@
|
|||||||
(= prev-swap-slot swap-ref-id)
|
(= prev-swap-slot swap-ref-id)
|
||||||
(pcb/update-shapes
|
(pcb/update-shapes
|
||||||
[(:id orig-swapped-child)]
|
[(:id orig-swapped-child)]
|
||||||
#(ctk/set-swap-slot % (:shape-ref related-shape-in-new))))
|
#(-> %
|
||||||
|
(ctk/remove-swap-slot)
|
||||||
|
(ctk/set-swap-slot (:shape-ref related-shape-in-new)))))
|
||||||
|
|
||||||
;; Delete new non-swapped item
|
;; Delete new non-swapped item
|
||||||
(cls/generate-delete-shapes ldata page objects (d/ordered-set (:id related-shape-in-new)) {:allow-altering-copies true})
|
(cls/generate-delete-shapes ldata page objects (d/ordered-set (:id related-shape-in-new)) {:allow-altering-copies true})
|
||||||
@ -167,42 +169,51 @@
|
|||||||
(:id orig-ref-shape))
|
(:id orig-ref-shape))
|
||||||
|
|
||||||
;; Creates a map to quickly find a child of the orig-ref-shape by its shape-path
|
;; Creates a map to quickly find a child of the orig-ref-shape by its shape-path
|
||||||
o-ref-shapes-p-map (into {} (map (juxt :id :shape-path)) o-ref-shapes-wp)]
|
o-ref-shapes-p-map (into {} (map (juxt :id :shape-path)) o-ref-shapes-wp)
|
||||||
;; Process each touched children of the original-shape
|
|
||||||
(reduce
|
|
||||||
(fn [changes orig-child-touched]
|
|
||||||
(let [;; If the orig-child-touched was swapped, get its swap-slot
|
|
||||||
swap-slot (ctk/get-swap-slot orig-child-touched)
|
|
||||||
|
|
||||||
;; orig-child-touched is in a copy. Get the referenced shape on the main component
|
|
||||||
;; If there is a swap slot, we will get the referenced shape in another way
|
|
||||||
orig-ref-shape (when-not swap-slot
|
|
||||||
;; TODO Maybe just get it from o-ref-shapes-wp
|
|
||||||
(ctf/find-ref-shape nil container libraries orig-child-touched))
|
|
||||||
|
|
||||||
orig-ref-id (if swap-slot
|
;; Process each touched children of the original-shape
|
||||||
;; If there is a swap slot, find the referenced shape id
|
[changes parents-of-swapped]
|
||||||
(ctf/find-ref-id-for-swapped orig-child-touched container libraries)
|
(reduce
|
||||||
;; If there is not a swap slot, get the id from the orig-ref-shape
|
(fn [[changes parent-of-swapped] orig-child-touched]
|
||||||
(:id orig-ref-shape))
|
(let [;; If the orig-child-touched was swapped, get its swap-slot
|
||||||
|
swap-slot (ctk/get-swap-slot orig-child-touched)
|
||||||
|
|
||||||
;; Get the shape path of the referenced main
|
;; orig-child-touched is in a copy. Get the referenced shape on the main component
|
||||||
shape-path (get o-ref-shapes-p-map orig-ref-id)
|
;; If there is a swap slot, we will get the referenced shape in another way
|
||||||
;; Get its related shape in the children of new-shape: the one that
|
orig-ref-shape (when-not swap-slot
|
||||||
;; has the same shape-path
|
;; TODO Maybe just get it from o-ref-shapes-wp
|
||||||
related-shape-in-new (get new-shapes-map shape-path)]
|
(ctf/find-ref-shape nil container libraries orig-child-touched))
|
||||||
;; If there is a related shape, keep its data
|
|
||||||
(if related-shape-in-new
|
orig-ref-id (if swap-slot
|
||||||
(if swap-slot
|
;; If there is a swap slot, find the referenced shape id
|
||||||
;; If the orig-child-touched was swapped, keep it
|
(ctf/find-ref-id-for-swapped orig-child-touched container libraries)
|
||||||
(keep-swapped-item changes related-shape-in-new orig-child-touched
|
;; If there is not a swap slot, get the id from the orig-ref-shape
|
||||||
ldata page orig-ref-id)
|
(:id orig-ref-shape))
|
||||||
;; If the orig-child-touched wasn't swapped, copy
|
|
||||||
;; the touched attributes into it
|
;; Get the shape path of the referenced main
|
||||||
(cll/update-attrs-on-switch
|
shape-path (get o-ref-shapes-p-map orig-ref-id)
|
||||||
changes related-shape-in-new orig-child-touched
|
;; Get its related shape in the children of new-shape: the one that
|
||||||
new-shape original-shape orig-ref-shape container))
|
;; has the same shape-path
|
||||||
changes)))
|
related-shape-in-new (get new-shapes-map shape-path)
|
||||||
changes
|
parents-of-swapped (if related-shape-in-new
|
||||||
orig-touched)))
|
(conj parent-of-swapped (:parent-id related-shape-in-new))
|
||||||
|
parent-of-swapped)
|
||||||
|
;; If there is a related shape, keep its data
|
||||||
|
changes
|
||||||
|
(if related-shape-in-new
|
||||||
|
(if swap-slot
|
||||||
|
;; If the orig-child-touched was swapped, keep it
|
||||||
|
(keep-swapped-item changes related-shape-in-new orig-child-touched
|
||||||
|
ldata page orig-ref-id)
|
||||||
|
;; If the orig-child-touched wasn't swapped, copy
|
||||||
|
;; the touched attributes into it
|
||||||
|
(cll/update-attrs-on-switch
|
||||||
|
changes related-shape-in-new orig-child-touched
|
||||||
|
new-shape original-shape orig-ref-shape container))
|
||||||
|
changes)]
|
||||||
|
[changes parents-of-swapped]))
|
||||||
|
[changes []]
|
||||||
|
orig-touched)]
|
||||||
|
[changes parents-of-swapped]))
|
||||||
|
|
||||||
|
|||||||
@ -300,9 +300,9 @@
|
|||||||
{}
|
{}
|
||||||
(true? keep-touched?))
|
(true? keep-touched?))
|
||||||
|
|
||||||
changes (if keep-touched?
|
[changes _] (if keep-touched?
|
||||||
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries (:data file))
|
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries (:data file))
|
||||||
changes)
|
[changes nil])
|
||||||
|
|
||||||
|
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes)]
|
||||||
|
|||||||
@ -980,9 +980,11 @@
|
|||||||
(cll/generate-component-swap objects shape ldata page libraries id-new-component
|
(cll/generate-component-swap objects shape ldata page libraries id-new-component
|
||||||
index target-cell keep-props-values keep-touched?))
|
index target-cell keep-props-values keep-touched?))
|
||||||
|
|
||||||
changes (if keep-touched?
|
[changes parents-of-swapped]
|
||||||
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries ldata)
|
(if keep-touched?
|
||||||
changes)]
|
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries ldata)
|
||||||
|
[changes []])
|
||||||
|
all-parents (into all-parents parents-of-swapped)]
|
||||||
|
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user