Browse Source

fix: property query

Tienson Qin 11 months ago
parent
commit
d3fc6c9a77

+ 3 - 31
deps/db/src/logseq/db/frontend/rules.cljc

@@ -152,43 +152,15 @@
 (def ^:large-vars/data-var db-query-dsl-rules
   "Rules used by frontend.query.dsl for db graphs"
   (merge
-   (dissoc query-dsl-rules :namespace)
+   (dissoc query-dsl-rules :namespace
+           :page-property :has-page-property
+           :page-tags :all-page-tags)
    {:tags
     '[(tags ?b ?tags)
       [?b :block/tags ?t]
       [?t :block/name ?tag]
       [(missing? $ ?b :block/link)]
       [(contains? ?tags ?tag)]]
-    :page-tags
-    '[(page-tags ?p ?tags)
-      [?p :block/tags ?t]
-      [?t :block/name ?tag]
-      [(missing? $ ?p :block/link)]
-      [(contains? ?tags ?tag)]]
-
-    :has-page-property
-    '[(has-page-property ?p ?prop)
-      [?p :block/name]
-      [?p ?prop _]
-      [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]]
-
-    :page-property
-    '[(page-property ?p ?prop ?val)
-      [?p :block/name]
-      [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
-      [?p ?prop ?pv]
-      (or
-       ;; non-ref value
-       (and
-        [(missing? $ ?prop-e :db/valueType)]
-        [?p ?prop ?val])
-       ;; ref value
-       (and
-        [?prop-e :db/valueType :db.type/ref]
-        (or [?pv :block/title ?val]
-            [?pv :property.value/content ?val])))]
 
     :has-property
     '[(has-property ?b ?prop)

+ 7 - 3
src/main/frontend/components/query/builder.cljs

@@ -176,9 +176,13 @@
                       (cons "Select all" values'))]
     (select values''
             (fn [{:keys [original-value]}]
-              (let [x (if (= original-value "Select all")
-                        [(if (= @*find :page) :page-property :property) @*property]
-                        [(if (= @*find :page) :page-property :property) @*property original-value])]
+              (let [k (cond
+                        db-graph? :property
+                        (= @*find :page) :page-property
+                        :else :property)
+                    x (if (= original-value "Select all")
+                        [k @*property]
+                        [k @*property original-value])]
                 (reset! *property nil)
                 (append-tree! *tree opts loc x))))))