From 9ed6d23041599e09c2bcc758979f2c58e89cdcc7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 12 Jun 2020 10:51:09 +0200 Subject: [PATCH] :bug: Group shapes in the correct parent. --- frontend/src/uxbox/main/data/workspace.cljs | 49 ++++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index d5b4f16ff..8ad41e9de 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -1236,29 +1236,34 @@ (when (not-empty selected) (let [page-id (get-in state [:workspace-page :id]) objects (get-in state [:workspace-data page-id :objects]) - selected-objects (map (partial get objects) selected) - selrect (geom/selection-rect selected-objects) - frame-id (-> selected-objects first :frame-id) - group (-> (group-shape id frame-id selected selrect) - (geom/setup selrect)) - index (->> (get-in objects [frame-id :shapes]) - (map-indexed vector) - (filter #(selected (second %))) - (ffirst)) - rchanges [{:type :add-obj - :id id - :frame-id frame-id - :obj group - :index index} - {:type :mov-objects - :parent-id id - :shapes (vec selected)}] - uchanges [{:type :mov-objects - :parent-id frame-id - :shapes (vec selected)} - {:type :del-obj - :id id}]] + items (map #(get objects %) selected) + selrect (geom/selection-rect items) + frame-id (-> items first :frame-id) + parent-id (-> items first :parent-id) + group (-> (group-shape id frame-id selected selrect) + (geom/setup selrect)) + + index (->> (get-in objects [frame-id :shapes]) + (map-indexed vector) + (filter #(selected (second %))) + (ffirst)) + + rchanges [{:type :add-obj + :id id + :frame-id frame-id + :parent-id parent-id + :obj group + :index index} + {:type :mov-objects + :parent-id id + :shapes (vec selected)}] + uchanges [{:type :mov-objects + :parent-id frame-id + :shapes (vec selected)} + {:type :del-obj + :id id}]] + (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}) (dws/select-shapes #{id}))))))))