mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 16:30:37 -05:00
✨ Rename component root when renaming a component
This commit is contained in:
parent
f4374c5046
commit
96e6ba77be
2 changed files with 11 additions and 5 deletions
|
@ -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]}]
|
||||
|
|
|
@ -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}))))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue