mirror of
https://github.com/penpot/penpot.git
synced 2025-06-09 00:01:38 +02: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)}))
|
:objects (d/index-by :id shapes)}))
|
||||||
|
|
||||||
(defmethod process-change :mod-component
|
(defmethod process-change :mod-component
|
||||||
[data {:keys [id name shapes]}]
|
[data {:keys [id name objects]}]
|
||||||
(update-in data [:components id]
|
(update-in data [:components id]
|
||||||
#(cond-> %
|
#(cond-> %
|
||||||
(some? name)
|
(some? name)
|
||||||
(assoc :name name)
|
(assoc :name name)
|
||||||
|
|
||||||
(some? shapes)
|
(some? objects)
|
||||||
(assoc :objects (d/index-by :id shapes)))))
|
(assoc :objects objects))))
|
||||||
|
|
||||||
(defmethod process-change :del-component
|
(defmethod process-change :del-component
|
||||||
[data {:keys [id]}]
|
[data {:keys [id]}]
|
||||||
|
|
|
@ -261,14 +261,20 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [component (get-in state [:workspace-data :components id])
|
(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
|
rchanges [{:type :mod-component
|
||||||
:id id
|
:id id
|
||||||
:name new-name}]
|
:name new-name
|
||||||
|
:objects new-objects}]
|
||||||
|
|
||||||
uchanges [{:type :mod-component
|
uchanges [{:type :mod-component
|
||||||
:id id
|
:id id
|
||||||
:name (:name component)}]]
|
:name (:name component)
|
||||||
|
:objects objects}]]
|
||||||
|
|
||||||
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue