mirror of https://github.com/logseq/logseq
fix: allow UI and validation to know what property types have :position
this is done by configuring user-built-in-allowed-schema-attributes and then using the helper fn to check it Fix LOG-2955pull/10838/head
parent
c47b936900
commit
56a81f9671
|
@ -21,17 +21,14 @@
|
|||
"Valid schema :type for closed values"
|
||||
#{:default :number :url :date :page})
|
||||
|
||||
(def closed-value-property-position-types
|
||||
"Valid schema :type for closed values"
|
||||
#{:default :number :url})
|
||||
|
||||
(assert (set/subset? closed-value-property-types (set user-built-in-property-types))
|
||||
"All closed value types are valid property types")
|
||||
|
||||
(def ^:private user-built-in-allowed-schema-attributes
|
||||
"Map of types to their set of allowed :schema attributes"
|
||||
(merge-with into
|
||||
(zipmap closed-value-property-types (repeat #{:values :position}))
|
||||
(zipmap closed-value-property-types (repeat #{:values}))
|
||||
(zipmap #{:default :number :url} (repeat #{:position}))
|
||||
{:number #{:cardinality}
|
||||
:date #{:cardinality}
|
||||
:url #{:cardinality}
|
||||
|
|
|
@ -141,8 +141,7 @@
|
|||
class? (contains? (:block/type block) "class")
|
||||
property-type (get-in property [:block/schema :type])
|
||||
save-property-fn (fn [] (components-pu/update-property! property @*property-name @*property-schema))
|
||||
enable-closed-values? (contains? db-property-type/closed-value-property-types (or property-type :default))
|
||||
enable-position? (contains? db-property-type/closed-value-property-position-types (or property-type :default))]
|
||||
enable-closed-values? (contains? db-property-type/closed-value-property-types (or property-type :default))]
|
||||
[:div.property-configure.flex.flex-1.flex-col
|
||||
{:on-mouse-down #(state/set-state! :editor/mouse-down-from-property-configure? true)
|
||||
:on-mouse-up #(state/set-state! :editor/mouse-down-from-property-configure? nil)}
|
||||
|
@ -252,7 +251,7 @@
|
|||
(closed-value/choices property *property-name *property-schema opts)]])
|
||||
|
||||
(when (and enable-closed-values?
|
||||
enable-position?
|
||||
(db-property-type/property-type-allows-schema-attribute? (:type @*property-schema) :position)
|
||||
(seq (:values @*property-schema)))
|
||||
(let [position (:position @*property-schema)
|
||||
choices (map
|
||||
|
|
Loading…
Reference in New Issue