🐛 Fix restore totally deleted variant should add props as name

This commit is contained in:
Pablo Alba 2025-05-07 15:03:50 +02:00 committed by Pablo Alba
parent e271caa32b
commit 6b300d516b
2 changed files with 5 additions and 15 deletions

View file

@ -450,12 +450,12 @@
changes
(rest moved-shapes))
changes (cond-> changes
;; Transform variant info into name when restoring into a parent that is not a variant-container
(and is-variant? parent (not (ctk/is-variant-container? parent)))
;; Transform variant info into name when restoring into a parent that is not a variant-container,
;; or when restoring into a variant-container that doesn't exists anymore
(and is-variant?
(or (and parent (not (ctk/is-variant-container? parent)))
(nil? restoring-into-parent)))
(clvp/generate-make-shapes-no-variant [first-shape])
;; Remove variant info when restoring into a variant-container that doesn't exists anymore
(and is-variant? (nil? restoring-into-parent))
(clvp/generate-delete-variant-info first-shape)
;; Add variant info and rename when restoring into a variant-container
(ctk/is-variant-container? restoring-into-parent)
(clvp/generate-make-shapes-variant [first-shape] restoring-into-parent))]

View file

@ -93,16 +93,6 @@
related-components)]
changes))
(defn generate-delete-variant-info
[changes shape]
(-> changes
(pcb/update-component (:component-id shape)
#(dissoc % :variant-id :variant-properties)
{:apply-changes-local-library? true})
(pcb/update-shapes [(:id shape)]
#(dissoc % :variant-id :variant-name))))
(defn- generate-make-shape-no-variant
[changes shape]
(let [new-name (ctv/variant-name-to-name shape)