mirror of
https://github.com/penpot/penpot.git
synced 2026-09-07 20:49:37 +00:00
✨ Treat empty names as a malformed formula (#7073)
This commit is contained in:
parent
db9349e764
commit
0a02e526ee
@ -71,7 +71,7 @@
|
|||||||
component (ctcl/get-component data component-id true)
|
component (ctcl/get-component data component-id true)
|
||||||
main-id (:main-instance-id component)]
|
main-id (:main-instance-id component)]
|
||||||
(-> changes
|
(-> changes
|
||||||
(pcb/update-shapes [main-id] (if (str/blank? value)
|
(pcb/update-shapes [main-id] (if (nil? value)
|
||||||
#(dissoc % :variant-error)
|
#(dissoc % :variant-error)
|
||||||
#(assoc % :variant-error value))))))
|
#(assoc % :variant-error value))))))
|
||||||
|
|
||||||
|
|||||||
@ -135,25 +135,27 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn update-error
|
(defn update-error
|
||||||
"Updates the error in a component"
|
"Sets or unsets an error for a component"
|
||||||
[component-id value]
|
([component-id]
|
||||||
(ptk/reify ::update-error
|
(update-error component-id nil))
|
||||||
ptk/WatchEvent
|
([component-id value]
|
||||||
(watch [it state _]
|
(ptk/reify ::update-error
|
||||||
(let [page-id (:current-page-id state)
|
ptk/WatchEvent
|
||||||
data (dsh/lookup-file-data state)
|
(watch [it state _]
|
||||||
objects (-> (dsh/get-page data page-id)
|
(let [page-id (:current-page-id state)
|
||||||
(get :objects))
|
data (dsh/lookup-file-data state)
|
||||||
|
objects (-> (dsh/get-page data page-id)
|
||||||
|
(get :objects))
|
||||||
|
|
||||||
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)
|
||||||
(clvp/generate-set-variant-error component-id value))
|
(clvp/generate-set-variant-error component-id value))
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
|
|
||||||
(defn remove-property
|
(defn remove-property
|
||||||
|
|||||||
@ -73,7 +73,7 @@
|
|||||||
(if (ctv/valid-properties-formula? name)
|
(if (ctv/valid-properties-formula? name)
|
||||||
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties (ctv/properties-formula->map name))
|
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties (ctv/properties-formula->map name))
|
||||||
(dwv/remove-empty-properties variant-id)
|
(dwv/remove-empty-properties variant-id)
|
||||||
(dwv/update-error component-id nil))
|
(dwv/update-error component-id))
|
||||||
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties {})
|
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties {})
|
||||||
(dwv/remove-empty-properties variant-id)
|
(dwv/remove-empty-properties variant-id)
|
||||||
(dwv/update-error component-id name)))
|
(dwv/update-error component-id name)))
|
||||||
|
|||||||
@ -339,7 +339,7 @@
|
|||||||
(let [value (d/nilv (str/trim value) "")]
|
(let [value (d/nilv (str/trim value) "")]
|
||||||
(doseq [id component-ids]
|
(doseq [id component-ids]
|
||||||
(st/emit! (dwv/update-property-value id pos value))
|
(st/emit! (dwv/update-property-value id pos value))
|
||||||
(st/emit! (dwv/update-error id nil))))))
|
(st/emit! (dwv/update-error id))))))
|
||||||
|
|
||||||
update-property-name
|
update-property-name
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user