Revert change so that query functions can still work

Also add some docstring and slightly alter command name to reflect query
functions increased ability introduced with the related #9563
This commit is contained in:
Gabriel Horner
2023-06-19 16:28:24 -04:00
committed by Gabriel Horner
parent 8ab497cb8a
commit cb29fb6eae
3 changed files with 10 additions and 3 deletions

View File

@@ -278,7 +278,7 @@
[["Query" [[:editor/input "{{query }}" {:backward-pos 2}]
[:editor/exit]] query-doc]
["Zotero" (zotero-steps) "Import Zotero journal article"]
["Query table function" [[:editor/input "{{function }}" {:backward-pos 2}]] "Create a query table function"]
["Query function" [[:editor/input "{{function }}" {:backward-pos 2}]] "Create a query function"]
["Calculator" [[:editor/input "```calc\n\n```" {:type "block"
:backward-pos 4}]
[:codemirror/focus]] "Insert a calculator"]

View File

@@ -2733,8 +2733,13 @@
block (merge block (block/parse-title-and-body uuid format pre-block? content))
blocks-container-id (:blocks-container-id config)
config (update config :block merge block)
;; Each block might have multiple queries, but we store only the first query's result
config (assoc config :query-result (atom nil))
;; Each block might have multiple queries, but we store only the first query's result.
;; This :query-result atom is used by the query function feature to share results between
;; the parent's query block and the children blocks. This works because config is shared
;; between parent and children blocks
config (if (nil? (:query-result config))
(assoc config :query-result (atom nil))
config)
config (if ref? (block-handler/attach-order-list-state config block) config)
heading? (:heading properties)
*control-show? (get state ::control-show?)

View File

@@ -60,6 +60,8 @@
(not (and (string? query) (string/includes? query "(by-page false)")))))))
(defn get-query-result
"Fetches a query's result, transforms it as needed and saves the result into
an atom that is passed in as an argument"
[state config *query-error *query-triggered? current-block-uuid q options]
(let [query-atom (trigger-custom-query! state *query-error *query-triggered?)
query-result (and query-atom (rum/react query-atom))