Browse Source

fix: sorting for keyword columns

Gabriel Horner 2 years ago
parent
commit
775a38f91d

+ 3 - 2
deps/graph-parser/src/logseq/graph_parser/property.cljs

@@ -185,9 +185,10 @@
    :background-color {:schema {:type :default}}
    :heading {:schema {:type :any}}      ; number (1-6) or boolean for auto heading
    :query-table {:schema {:type :checkbox}}
-   ;; query-properties is a coll of property uuids and keywords where keywords are special frontend properties
+   ;; query-properties is a coll of property uuids and keywords where keywords are special frontend keywords
    :query-properties {:schema {:type :coll}}
-   :query-sort-by {:schema {:type :checkbox}}
+   ;; query-sort-by is either a property uuid or a keyword where keyword is a special frontend keyword
+   :query-sort-by {:schema {:type :any}}
    :query-sort-desc {:schema {:type :checkbox}}
    :logseq.query/nlp-date {:schema {:type :checkbox}}
    :ls-type {:schema {:type :keyword}}

+ 1 - 1
src/main/frontend/components/query_table.cljs

@@ -90,7 +90,7 @@
   (let [repo (state/get-current-repo)]
     [:th.whitespace-nowrap
      [:a {:on-click (fn []
-                      (property-handler/set-block-property! repo block-id :query-sort-by (name column))
+                      (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-desc (not sort-desc?)))}
       [:div.flex.items-center
        [:span.mr-1 title]

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

@@ -82,7 +82,7 @@
   (if (and (not (string? v-str)) (not (object? v-str)))
     v-str
     (case schema-type
-      :default
+      (:default :any :url)
       v-str
 
       :number
@@ -102,9 +102,7 @@
 
       :date
       v-str                  ; uuid
-
-      :url
-      v-str)))
+      )))
 
 (defn upsert-property!
   [repo k-name schema {:keys [property-uuid]}]