浏览代码

fix: query table sorting for property columns

also fixes sorting indicator
Gabriel Horner 2 年之前
父节点
当前提交
1e4cc1b4f2
共有 1 个文件被更改,包括 6 次插入8 次删除
  1. 6 8
      src/main/frontend/components/query_table.cljs

+ 6 - 8
src/main/frontend/components/query_table.cljs

@@ -17,8 +17,7 @@
             [medley.core :as medley]
             [medley.core :as medley]
             [rum.core :as rum]
             [rum.core :as rum]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.text :as text]
-            [frontend.handler.property.util :as pu]
-            [frontend.handler.property :as property-handler]))
+            [frontend.handler.property.util :as pu]))
 
 
 ;; Util fns
 ;; Util fns
 ;; ========
 ;; ========
@@ -72,13 +71,12 @@
         desc? (if (some? p-desc?) p-desc? true)
         desc? (if (some? p-desc?) p-desc? true)
         properties (:block/properties current-block)
         properties (:block/properties current-block)
         query-sort-by (pu/lookup properties :query-sort-by)
         query-sort-by (pu/lookup properties :query-sort-by)
-        p-sort-by (keyword query-sort-by)
         ;; Starting with #6105, we started putting properties under namespaces.
         ;; Starting with #6105, we started putting properties under namespaces.
         nlp-date? (pu/lookup properties :logseq.query/nlp-date)
         nlp-date? (pu/lookup properties :logseq.query/nlp-date)
-        sort-by-column (or (some-> p-sort-by keyword)
-                         (if (query-dsl/query-contains-filter? (:block/content current-block) "sort-by")
-                           nil
-                           :updated-at))]
+        sort-by-column (or (if (uuid? query-sort-by) query-sort-by (keyword query-sort-by))
+                           (if (query-dsl/query-contains-filter? (:block/content current-block) "sort-by")
+                             nil
+                             :updated-at))]
     {:sort-desc? desc?
     {:sort-desc? desc?
      :sort-by-column sort-by-column
      :sort-by-column sort-by-column
      :sort-nlp-date? nlp-date?}))
      :sort-nlp-date? nlp-date?}))
@@ -90,7 +88,7 @@
   (let [repo (state/get-current-repo)]
   (let [repo (state/get-current-repo)]
     [:th.whitespace-nowrap
     [:th.whitespace-nowrap
      [:a {:on-click (fn []
      [:a {:on-click (fn []
-                      (property-handler/set-block-property! repo block-id :query-sort-by (if (uuid? column) uuid (name column)))
+                      (property-handler/set-block-property! repo block-id :query-sort-by (if (uuid? column) column (name column)))
                       (property-handler/set-block-property! repo block-id :query-sort-desc (not sort-desc?)))}
                       (property-handler/set-block-property! repo block-id :query-sort-desc (not sort-desc?)))}
       [:div.flex.items-center
       [:div.flex.items-center
        [:span.mr-1 title]
        [:span.mr-1 title]