♻️ Components refactor: generator for detach-component

This commit is contained in:
Pablo Alba 2024-04-22 13:20:52 +02:00 committed by Andrés Moya
parent 7d44eef4ab
commit 0ed582ebc5
2 changed files with 13 additions and 8 deletions

View file

@ -846,7 +846,7 @@
components-v2))))
(defn- generate-rename-component
(defn generate-rename-component
"Generate the changes for rename the component with the given id, in the current file library."
[changes id new-name library-data components-v2]
(let [[path name] (cfh/parse-path-name new-name)
@ -1808,4 +1808,14 @@
(assoc changes :file-id library-id)))
(defn generate-detach-component
"Generate changes for remove all references to components in the shape,
with the given id and all its children, at the current page."
[changes id file page-id libraries]
(let [container (cfh/get-container file :page page-id)]
(-> changes
(pcb/with-container container)
(pcb/with-objects (:objects container))
(generate-detach-instance container libraries id))))