Browse Source

fix: remove unused uuid string conversions when handling properties

also renamed anon fn to not have name as existing fn in ns
Gabriel Horner 1 year ago
parent
commit
ee3ecdb464

+ 4 - 18
src/main/frontend/handler/db_based/property.cljs

@@ -57,7 +57,7 @@
                                   [{} property-val-schema])]
                                   [{} property-val-schema])]
     [:fn
     [:fn
      schema-opts
      schema-opts
-     (fn validate-property-value [property-val]
+     (fn property-value-schema [property-val]
        (db-malli-schema/validate-property-value (db/get-db) schema-fn [property property-val] {:new-closed-value? new-closed-value?}))]))
        (db-malli-schema/validate-property-value (db/get-db) schema-fn [property property-val] {:new-closed-value? new-closed-value?}))]))
 
 
 (defn- fail-parse-long
 (defn- fail-parse-long
@@ -78,7 +78,6 @@
     (cond
     (cond
       (fail-parse-long v-str) :number
       (fail-parse-long v-str) :number
       (fail-parse-double v-str) :number
       (fail-parse-double v-str) :number
-      (util/uuid-string? v-str) :page
       (common-util/url? v-str) :url
       (common-util/url? v-str) :url
       (contains? #{"true" "false"} (string/lower-case v-str)) :checkbox
       (contains? #{"true" "false"} (string/lower-case v-str)) :checkbox
       :else :default)
       :else :default)
@@ -87,22 +86,9 @@
 
 
 (defn convert-property-input-string
 (defn convert-property-input-string
   [schema-type v-str]
   [schema-type v-str]
-  (if (and (not (string? v-str)) (not (object? v-str)))
-    v-str
-    (case schema-type
-      :number
-      (fail-parse-double v-str)
-
-      :page
-      (uuid v-str)
-
-      ;; these types don't need to be translated. :date expects uuid and other
-      ;; types usually expect text
-      (:url :date :any)
-      v-str
-
-      ;; :default
-      (if (util/uuid-string? v-str) (uuid v-str) v-str))))
+  (if (and (= :number schema-type) (string? v-str))
+    (fail-parse-double v-str)
+    v-str))
 
 
 (defn- update-datascript-schema
 (defn- update-datascript-schema
   [property {:keys [type cardinality values]}]
   [property {:keys [type cardinality values]}]

+ 0 - 1
src/test/frontend/handler/db_based/property_test.cljs

@@ -213,7 +213,6 @@
                 (db-property-handler/convert-property-input-string schema-type value)) y)
                 (db-property-handler/convert-property-input-string schema-type value)) y)
         [:number "1"] 1
         [:number "1"] 1
         [:number "1.2"] 1.2
         [:number "1.2"] 1.2
-        [:page (str test-uuid)] test-uuid
         [:url test-uuid] test-uuid
         [:url test-uuid] test-uuid
         [:date test-uuid] test-uuid
         [:date test-uuid] test-uuid
         [:any test-uuid] test-uuid
         [:any test-uuid] test-uuid