浏览代码

fix: update property filters to work with task status

fixes LOG-3088
Tienson Qin 1 年之前
父节点
当前提交
4ea0dd257d
共有 2 个文件被更改,包括 21 次插入18 次删除
  1. 18 14
      src/main/frontend/db/async.cljs
  2. 3 4
      src/main/frontend/db/query_dsl.cljs

+ 18 - 14
src/main/frontend/db/async.cljs

@@ -16,7 +16,8 @@
             [frontend.date :as date]
             [cljs-time.core :as t]
             [cljs-time.format :as tf]
-            [logseq.db :as ldb]))
+            [logseq.db :as ldb]
+            [frontend.handler.property.util :as pu]))
 
 (def <q db-async-util/<q)
 (def <pull db-async-util/<pull)
@@ -77,9 +78,10 @@
 
 (defn <get-db-based-property-values
   [graph property]
-  (let [property-name (if (keyword? property)
-                        (name property)
-                        (util/page-name-sanity-lc property))]
+  (let [property-name (-> (if (keyword? property) (name property) property)
+                          util/page-name-sanity-lc)
+        property (pu/get-property property-name)
+        closed-values? (seq (get-in property [:block/schema :values]))]
     (p/let [result (<q graph
                        '[:find ?prop-type ?v
                          :in $ ?prop-name
@@ -94,17 +96,19 @@
       (->> result
            (map (fn [[prop-type v]] [prop-type (if (coll? v) v [v])]))
            (mapcat (fn [[prop-type vals]]
-                     (let [result (case prop-type
-                                    :default
-                                    ;; Remove multi-block properties as there isn't a supported approach to query them yet
-                                    (map str (remove uuid? vals))
-                                    (:page :date)
-                                    (map #(:block/original-name (db-utils/entity graph [:block/uuid %]))
-                                         vals)
-                                    :number
+                     (let [result (if closed-values?
                                     vals
-                                    ;; Checkboxes returned as strings as builder doesn't display boolean values correctly
-                                    (map str vals))]
+                                    (case prop-type
+                                      :default
+                                      ;; Remove multi-block properties as there isn't a supported approach to query them yet
+                                      (map str (remove uuid? vals))
+                                      (:page :date)
+                                      (map #(:block/original-name (db-utils/entity graph [:block/uuid %]))
+                                           vals)
+                                      :number
+                                      vals
+                                      ;; Checkboxes returned as strings as builder doesn't display boolean values correctly
+                                      (map str vals)))]
                        (map (fn [value]
                               (if (uuid? value)
                                 (get-in (db-utils/entity graph [:block/uuid value]) [:block/schema :value])

+ 3 - 4
src/main/frontend/db/query_dsl.cljs

@@ -261,7 +261,7 @@
   [property-name]
   (let [repo (state/get-current-repo)]
     (if (config/db-based-graph? repo)
-      (str property-name)
+      (string/lower-case (str property-name))
       (keyword property-name))))
 
 (defn- build-property-two-arg
@@ -276,9 +276,8 @@
         values (get-in property [:block/schema :values])
         v' (if (seq values)             ; closed values
              (some #(when-let [closed-value (get-in (db-utils/entity [:block/uuid %]) [:block/schema :value])]
-                      (if (= v closed-value)
-                        %
-                        v))
+                      (when (= v closed-value)
+                        %))
                    values)
              v)]
     {:query (list 'property '?b (->keyword-property k) v')