0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

Rename component root when renaming a component

This commit is contained in:
Andrés Moya 2020-11-06 08:53:55 +01:00 committed by Alonso Torres
parent f4374c5046
commit 96e6ba77be
2 changed files with 11 additions and 5 deletions

View file

@ -963,14 +963,14 @@
:objects (d/index-by :id shapes)}))
(defmethod process-change :mod-component
[data {:keys [id name shapes]}]
[data {:keys [id name objects]}]
(update-in data [:components id]
#(cond-> %
(some? name)
(assoc :name name)
(some? shapes)
(assoc :objects (d/index-by :id shapes)))))
(some? objects)
(assoc :objects objects))))
(defmethod process-change :del-component
[data {:keys [id]}]

View file

@ -261,14 +261,20 @@
ptk/WatchEvent
(watch [_ state stream]
(let [component (get-in state [:workspace-data :components id])
objects (get component :objects)
new-objects (assoc-in objects
[(:id component) :name]
new-name)
rchanges [{:type :mod-component
:id id
:name new-name}]
:name new-name
:objects new-objects}]
uchanges [{:type :mod-component
:id id
:name (:name component)}]]
:name (:name component)
:objects objects}]]
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))