Răsfoiți Sursa

fix: fixes bug with unusuable :default property

Part of LOG-2953. Also fixes bug when a new property first displays
configure modal and incorrectly shows cardinality for :default property
Gabriel Horner 2 ani în urmă
părinte
comite
d218db4e6f

+ 2 - 0
deps/db/.carve/ignore

@@ -10,3 +10,5 @@ logseq.db.frontend.rules/extract-rules
 logseq.db.frontend.property.type/type-or-closed-value?
 ;; Internal API
 logseq.db.frontend.rules/rules
+;; API
+logseq.db.frontend.property.type/property-types-with-cardinality

+ 3 - 0
deps/db/src/logseq/db/frontend/property/type.cljs

@@ -97,6 +97,9 @@
    :coll     coll?
    :any      some?})
 
+(def property-types-with-cardinality
+  #{:number :date :url :page})
+
 (def property-types-with-db
   "Property types whose validation fn requires a datascript db"
   #{:date :page :template})

+ 8 - 3
src/main/frontend/components/property.cljs

@@ -188,11 +188,16 @@
            [:div.col-span-2
             (ui/select schema-types
                        (fn [_e v]
-                         (let [type (keyword (string/lower-case v))]
-                           (swap! *property-schema assoc :type type)
+                         (let [type (keyword (string/lower-case v))
+                               update-schema-fn (comp
+                                                 (if (contains? db-property-type/property-types-with-cardinality type)
+                                                   identity
+                                                   #(dissoc % :cardinality))
+                                                 #(assoc % :type type))]
+                           (swap! *property-schema update-schema-fn)
                            (components-pu/update-property! property @*property-name @*property-schema))))]))]
 
-      (when-not (contains? #{:checkbox :default :template} (:type @*property-schema))
+      (when (contains? db-property-type/property-types-with-cardinality (:type @*property-schema))
         [:div.grid.grid-cols-4.gap-1.items-center.leading-8
          [:label "Multiple values:"]
          (let [many? (boolean (= :many (:cardinality @*property-schema)))]