mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 04:34:14 +00:00
fix: disable grouped by page when result-transform exists
Adds `:group-by-page?` option to enable grouping even if `result-transform` exists.
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
(ui/icon "refresh" {:style {:font-size 20}})]))
|
||||
|
||||
(defn- get-query-result
|
||||
[state config *query-error *query-triggered? current-block-uuid q not-grouped-by-page? ]
|
||||
[state config *query-error *query-triggered? current-block-uuid q group-by-page?]
|
||||
(or (when-let [*result (:query-result config)] @*result)
|
||||
(let [query-atom (trigger-custom-query! state *query-error *query-triggered?)
|
||||
query-result (and query-atom (rum/react query-atom))
|
||||
@@ -89,7 +89,7 @@
|
||||
remove-blocks (if current-block-uuid [current-block-uuid] nil)
|
||||
transformed-query-result (when query-result
|
||||
(db/custom-query-result-transform query-result remove-blocks q))
|
||||
result (if (and (:block/uuid (first transformed-query-result)) (not not-grouped-by-page?))
|
||||
result (if (and group-by-page? (:block/uuid (first transformed-query-result)))
|
||||
(let [result (db-utils/group-by-page transformed-query-result)]
|
||||
(if (map? result)
|
||||
(dissoc result nil)
|
||||
@@ -106,14 +106,13 @@
|
||||
dsl-query?
|
||||
page-list?
|
||||
view-f
|
||||
result]}]
|
||||
result
|
||||
group-by-page?]}]
|
||||
(let [{:keys [->hiccup ->elem inline-text page-cp map-inline]} config
|
||||
*query-error query-error-atom
|
||||
not-grouped-by-page? (or table?
|
||||
(and (string? query) (string/includes? query "(by-page false)")))
|
||||
only-blocks? (:block/uuid (first result))
|
||||
blocks-grouped-by-page? (and (seq result)
|
||||
(not not-grouped-by-page?)
|
||||
blocks-grouped-by-page? (and group-by-page?
|
||||
(seq result)
|
||||
(coll? (first result))
|
||||
(:block/name (ffirst result))
|
||||
(:block/uuid (first (second (first result))))
|
||||
@@ -203,7 +202,8 @@
|
||||
state)}
|
||||
(rum/local nil ::query-result)
|
||||
{:init (fn [state] (assoc state :query-error (atom nil)))}
|
||||
[state config {:keys [title builder query view collapsed? table-view?] :as q} *query-triggered?]
|
||||
[state config {:keys [title builder query view collapsed? table-view?
|
||||
result-transform group-by-page?] :as q} *query-triggered?]
|
||||
(let [*query-error (:query-error state)
|
||||
built-in? (built-in-custom-query? title)
|
||||
dsl-query? (:dsl-query? config)
|
||||
@@ -227,10 +227,12 @@
|
||||
full-text-search? (and dsl-query?
|
||||
(util/electron?)
|
||||
(symbol? (gp-util/safe-read-string query)))
|
||||
not-grouped-by-page? (or table?
|
||||
(and (string? query) (string/includes? query "(by-page false)")))
|
||||
group-by-page? (or group-by-page?
|
||||
(and (not table?)
|
||||
(not result-transform)
|
||||
(not (and (string? query) (string/includes? query "(by-page false)")))))
|
||||
result (when (or built-in-collapsed? (not collapsed?'))
|
||||
(get-query-result state config *query-error *query-triggered? current-block-uuid q not-grouped-by-page?))
|
||||
(get-query-result state config *query-error *query-triggered? current-block-uuid q group-by-page?))
|
||||
query-time (:query-time (meta result))
|
||||
page-list? (and (seq result)
|
||||
(some? (:block/name (first result))))
|
||||
@@ -240,7 +242,8 @@
|
||||
:table? table?
|
||||
:view-f view-f
|
||||
:page-list? page-list?
|
||||
:result result}]
|
||||
:result result
|
||||
:group-by-page? group-by-page?}]
|
||||
(if (:custom-query? config)
|
||||
[:code (if dsl-query?
|
||||
(util/format "{{query %s}}" query)
|
||||
|
||||
Reference in New Issue
Block a user