Removes children when flattening a group or bool shape

This commit is contained in:
alonso.torres 2021-09-20 16:30:26 +02:00
parent 74f3d551f2
commit 778a542e1c
4 changed files with 129 additions and 17 deletions

View file

@ -13,7 +13,7 @@
.align-group {
padding: 0 $x-small;
display: flex;
justify-content: start;
justify-content: flex-start;
width: 50%;
&:not(:last-child) {

View file

@ -6,6 +6,8 @@
(ns app.main.data.workspace.path.shapes-to-path
(:require
[app.common.pages :as cp]
[app.common.pages.changes-builder :as cb]
[app.common.path.shapes-to-path :as upsp]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.state-helpers :as wsh]
@ -15,7 +17,20 @@
(defn convert-selected-to-path []
(ptk/reify ::convert-selected-to-path
ptk/WatchEvent
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (wsh/lookup-selected state)]
(rx/of (dch/update-shapes selected #(upsp/convert-to-path % objects)))))))
(watch [it state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state)
selected (wsh/lookup-selected state)
children-ids
(into #{}
(mapcat #(cp/get-children % objects))
selected)
changes
(-> (cb/empty-changes it page-id)
(cb/with-objects objects)
(cb/remove-objects children-ids)
(cb/update-shapes selected #(upsp/convert-to-path % objects)))]
(rx/of (dch/commit-changes changes))))))