mirror of
https://github.com/penpot/penpot.git
synced 2026-04-26 19:58:09 +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
|
||||
"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]
|
||||
(ptk/reify ::remove-empty-properties
|
||||
ptk/WatchEvent
|
||||
@ -191,25 +192,29 @@
|
||||
|
||||
variant-components (cfv/find-variant-components data objects variant-id)
|
||||
|
||||
properties-empty (->> variant-components
|
||||
(mapcat :variant-properties)
|
||||
(group-by :name)
|
||||
(mapv (fn [[_ v]]
|
||||
(->> v (mapv :value) (remove empty?))))
|
||||
(mapv empty?))
|
||||
properties-empty-pos (->> variant-components
|
||||
(mapcat :variant-properties)
|
||||
(group-by :name)
|
||||
(map-indexed
|
||||
(fn [i [_ v]]
|
||||
[i (->> v
|
||||
(map :value)
|
||||
(remove empty?)
|
||||
empty?)]))
|
||||
(reverse))
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/with-objects objects))
|
||||
|
||||
changes (reduce
|
||||
(fn [changes [idx property-empty?]]
|
||||
(fn [changes [pos property-empty?]]
|
||||
(if property-empty?
|
||||
(-> changes
|
||||
(clvp/generate-remove-property variant-id idx))
|
||||
(clvp/generate-remove-property variant-id pos))
|
||||
changes))
|
||||
changes
|
||||
(map-indexed vector properties-empty))
|
||||
properties-empty-pos)
|
||||
|
||||
undo-id (js/Symbol)]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user