mirror of
https://github.com/penpot/penpot.git
synced 2026-09-08 13:09:22 +00:00
🐛 Remove empty properties starting with the last one (#6757)
* 🐛 Remove empty properties starting with the last one * ✨ MR changes --------- Co-authored-by: Pablo Alba <pablo.alba@kaleidos.net>
This commit is contained in:
parent
7cd0e28c3b
commit
2de0c90fc7
@ -179,7 +179,8 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn remove-empty-properties
|
(defn remove-empty-properties
|
||||||
"Remove a property for all components when its value is empty for all of them"
|
"Remove every empty property for all components when their respective values are empty
|
||||||
|
for all of them"
|
||||||
[variant-id]
|
[variant-id]
|
||||||
(ptk/reify ::remove-empty-properties
|
(ptk/reify ::remove-empty-properties
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
@ -191,25 +192,29 @@
|
|||||||
|
|
||||||
variant-components (cfv/find-variant-components data objects variant-id)
|
variant-components (cfv/find-variant-components data objects variant-id)
|
||||||
|
|
||||||
properties-empty (->> variant-components
|
properties-empty-pos (->> variant-components
|
||||||
(mapcat :variant-properties)
|
(mapcat :variant-properties)
|
||||||
(group-by :name)
|
(group-by :name)
|
||||||
(mapv (fn [[_ v]]
|
(map-indexed
|
||||||
(->> v (mapv :value) (remove empty?))))
|
(fn [i [_ v]]
|
||||||
(mapv empty?))
|
[i (->> v
|
||||||
|
(map :value)
|
||||||
|
(remove empty?)
|
||||||
|
empty?)]))
|
||||||
|
(reverse))
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it page-id)
|
changes (-> (pcb/empty-changes it page-id)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/with-objects objects))
|
(pcb/with-objects objects))
|
||||||
|
|
||||||
changes (reduce
|
changes (reduce
|
||||||
(fn [changes [idx property-empty?]]
|
(fn [changes [pos property-empty?]]
|
||||||
(if property-empty?
|
(if property-empty?
|
||||||
(-> changes
|
(-> changes
|
||||||
(clvp/generate-remove-property variant-id idx))
|
(clvp/generate-remove-property variant-id pos))
|
||||||
changes))
|
changes))
|
||||||
changes
|
changes
|
||||||
(map-indexed vector properties-empty))
|
properties-empty-pos)
|
||||||
|
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user