fix: new property should save without error

Also cleaned up duplicate label approaches for property type
This commit is contained in:
Gabriel Horner
2023-10-09 13:55:53 -04:00
parent 32e9e6c06d
commit ae716143e3
2 changed files with 10 additions and 8 deletions

View File

@@ -276,6 +276,12 @@
(update-property! property @*property-name @*property-schema)))))))
dropdown-opts)]))
(defn- property-type-label
[property-type]
(if (= property-type :default)
"Text"
((comp string/capitalize name) property-type)))
(rum/defcs ^:large-vars/cleanup-todo property-config <
rum/reactive
(rum/local nil ::property-name)
@@ -322,18 +328,14 @@
(let [schema-types (->> (concat db-property/user-builtin-schema-types
(when built-in-property?
db-property/internal-builtin-schema-types))
(map (comp string/capitalize name))
(map (fn [type]
{:label (if (= type "Default") "Text" type)
{:label (property-type-label type)
:disabled disabled?
:value type
:selected (= (keyword (string/lower-case type))
(:type @*property-schema))})))]
:selected (= type (:type @*property-schema))})))]
[:div.col-span-2
(if property-type
(if (= property-type :default)
"Text"
((comp string/capitalize name) property-type))
(property-type-label property-type)
(ui/select schema-types
(fn [_e v]
(let [type (keyword (string/lower-case v))]

View File

@@ -261,7 +261,7 @@
properties]}]
{:pre [(uuid? property-uuid)]}
(when-let [property (db/entity [:block/uuid property-uuid])]
(let [type (get property [:block/schema :type])]
(let [type (get-in property [:block/schema :type])]
(when-not (and type (:type property-schema) (not= type (:type property-schema))) ; property type changed
(when (and (= :many (:cardinality property-schema))
(not= :many (:cardinality (:block/schema property))))