mirror of
https://github.com/penpot/penpot.git
synced 2025-06-12 18:51:40 +02:00
parent
d8b21aa350
commit
1835b496d1
2 changed files with 23 additions and 38 deletions
|
@ -288,7 +288,6 @@
|
||||||
"Check if the current situation allows grouping
|
"Check if the current situation allows grouping
|
||||||
of the currently selected shapes."
|
of the currently selected shapes."
|
||||||
[selected shapes-map]
|
[selected shapes-map]
|
||||||
;; TODO: transducers
|
|
||||||
(let [xform (comp (map shapes-map)
|
(let [xform (comp (map shapes-map)
|
||||||
(map :group))
|
(map :group))
|
||||||
groups (into #{} xform selected)]
|
groups (into #{} xform selected)]
|
||||||
|
@ -298,11 +297,12 @@
|
||||||
"Check if the current situation allows ungrouping
|
"Check if the current situation allows ungrouping
|
||||||
of the currently selected shapes."
|
of the currently selected shapes."
|
||||||
[selected shapes-map]
|
[selected shapes-map]
|
||||||
(let [xform (comp (map shapes-map)
|
(let [shapes (into #{} (map shapes-map) selected)
|
||||||
(map :group))
|
groups (into #{} (map :group) shapes)]
|
||||||
groups (into #{} xform selected)]
|
(or (and (= 1 (count shapes))
|
||||||
(and (= 1 (count groups))
|
(= :group (:type (first shapes))))
|
||||||
(not (nil? (first groups))))))
|
(and (= 1 (count groups))
|
||||||
|
(not (nil? (first groups)))))))
|
||||||
|
|
||||||
(mx/defc layers-tools
|
(mx/defc layers-tools
|
||||||
"Layers widget options buttons."
|
"Layers widget options buttons."
|
||||||
|
|
|
@ -435,13 +435,10 @@
|
||||||
:shapes {1 {:id 1 :page 1 :group 3}
|
:shapes {1 {:id 1 :page 1 :group 3}
|
||||||
2 {:id 2 :page 1 :group 3}
|
2 {:id 2 :page 1 :group 3}
|
||||||
3 {:id 3 :page 1 :type :group :items [1 2]}}}
|
3 {:id 3 :page 1 :type :group :items [1 2]}}}
|
||||||
|
expected {:workspace {:selected #{1 2}}
|
||||||
expected (-> initial
|
:pages {1 {:id 1 :shapes [1 2]}}
|
||||||
(assoc-in [:workspace :selected] #{1 2})
|
:shapes {1 {:id 1 :page 1}
|
||||||
(assoc-in [:pages 1 :shapes] [1 2])
|
2 {:id 2 :page 1}}}]
|
||||||
(update-in [:shapes 1] dissoc :group)
|
|
||||||
(update-in [:shapes 2] dissoc :group)
|
|
||||||
(update-in [:shapes] dissoc 3))]
|
|
||||||
(let [result (impl/degroup-shapes initial [3] 1)]
|
(let [result (impl/degroup-shapes initial [3] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
@ -455,12 +452,10 @@
|
||||||
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
||||||
3 {:id 3 :page 1 :group 2}}}
|
3 {:id 3 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1, :shapes [1]}},
|
||||||
(assoc-in [:workspace :selected] #{3})
|
:shapes {1 {:id 1, :page 1, :type :group, :items [3]},
|
||||||
(assoc-in [:pages 1 :shapes] [1])
|
3 {:id 3, :page 1, :group 1}},
|
||||||
(update-in [:shapes] dissoc 2)
|
:workspace {:selected #{3}}}]
|
||||||
(assoc-in [:shapes 1 :items] [3])
|
|
||||||
(assoc-in [:shapes 3 :group] 1))]
|
|
||||||
(let [result (impl/degroup-shapes initial [2] 1)]
|
(let [result (impl/degroup-shapes initial [2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
@ -475,13 +470,9 @@
|
||||||
3 {:id 3 :page 1 :group 1}
|
3 {:id 3 :page 1 :group 1}
|
||||||
4 {:id 4 :page 1 :group 2}}}
|
4 {:id 4 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1, :shapes [3 4]}},
|
||||||
(assoc-in [:workspace :selected] #{3 4})
|
:shapes {3 {:id 3, :page 1}, 4 {:id 4, :page 1}},
|
||||||
(assoc-in [:pages 1 :shapes] [3 4])
|
:workspace {:selected #{4 3}}}]
|
||||||
(update :shapes dissoc 1)
|
|
||||||
(update :shapes dissoc 2)
|
|
||||||
(update-in [:shapes 3] dissoc :group)
|
|
||||||
(update-in [:shapes 4] dissoc :group))]
|
|
||||||
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
@ -495,12 +486,9 @@
|
||||||
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
||||||
3 {:id 3 :page 1 :group 2}}}
|
3 {:id 3 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1, :shapes [3]}},
|
||||||
(assoc-in [:workspace :selected] #{3})
|
:shapes {3 {:id 3, :page 1}},
|
||||||
(assoc-in [:pages 1 :shapes] [3])
|
:workspace {:selected #{3}}}]
|
||||||
(update :shapes dissoc 1)
|
|
||||||
(update :shapes dissoc 2)
|
|
||||||
(update-in [:shapes 3] dissoc :group))]
|
|
||||||
(let [result (impl/degroup-shapes initial [2 1] 1)]
|
(let [result (impl/degroup-shapes initial [2 1] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
@ -514,12 +502,9 @@
|
||||||
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
||||||
3 {:id 3 :page 1 :group 2}}}
|
3 {:id 3 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1, :shapes [3]}},
|
||||||
(assoc-in [:workspace :selected] #{3})
|
:shapes {3 {:id 3, :page 1}},
|
||||||
(assoc-in [:pages 1 :shapes] [3])
|
:workspace {:selected #{3}}}]
|
||||||
(update :shapes dissoc 1)
|
|
||||||
(update :shapes dissoc 2)
|
|
||||||
(update-in [:shapes 3] dissoc :group))]
|
|
||||||
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue