Treat empty names as a malformed formula (#7073)

This commit is contained in:
Luis de Dios 2025-08-07 07:41:07 +02:00 committed by GitHub
parent db9349e764
commit 0a02e526ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 21 deletions

View File

@ -71,7 +71,7 @@
component (ctcl/get-component data component-id true)
main-id (:main-instance-id component)]
(-> changes
(pcb/update-shapes [main-id] (if (str/blank? value)
(pcb/update-shapes [main-id] (if (nil? value)
#(dissoc % :variant-error)
#(assoc % :variant-error value))))))

View File

@ -135,25 +135,27 @@
(defn update-error
"Updates the error in a component"
[component-id value]
(ptk/reify ::update-error
ptk/WatchEvent
(watch [it state _]
(let [page-id (:current-page-id state)
data (dsh/lookup-file-data state)
objects (-> (dsh/get-page data page-id)
(get :objects))
"Sets or unsets an error for a component"
([component-id]
(update-error component-id nil))
([component-id value]
(ptk/reify ::update-error
ptk/WatchEvent
(watch [it state _]
(let [page-id (:current-page-id state)
data (dsh/lookup-file-data state)
objects (-> (dsh/get-page data page-id)
(get :objects))
changes (-> (pcb/empty-changes it page-id)
(pcb/with-library-data data)
(pcb/with-objects objects)
(clvp/generate-set-variant-error component-id value))
undo-id (js/Symbol)]
(rx/of
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id))))))
changes (-> (pcb/empty-changes it page-id)
(pcb/with-library-data data)
(pcb/with-objects objects)
(clvp/generate-set-variant-error component-id value))
undo-id (js/Symbol)]
(rx/of
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id)))))))
(defn remove-property

View File

@ -73,7 +73,7 @@
(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))
(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 {})
(dwv/remove-empty-properties variant-id)
(dwv/update-error component-id name)))

View File

@ -339,7 +339,7 @@
(let [value (d/nilv (str/trim value) "")]
(doseq [id component-ids]
(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
(mf/use-fn