feat: query tables support both sort and custom properties

This commit is contained in:
Tienson Qin
2021-07-19 14:39:16 +08:00
parent 5dcb128c7e
commit fa17476d13
7 changed files with 181 additions and 97 deletions

View File

@@ -923,6 +923,22 @@
(let [key (keyword key)]
(block-property-aux! block-id key value)))
(defn set-block-query-properties!
[block-id all-properties key add?]
(when-let [block (db/entity [:block/uuid block-id])]
(let [query-properties (-> (get-in block [:block/properties :query-properties] "")
(common-handler/safe-read-string "Failed to parse query properties"))
query-properties (if (seq query-properties)
query-properties
all-properties)
query-properties (if add?
(distinct (conj query-properties key))
(remove #{key} query-properties))
query-properties (vec query-properties)]
(if (seq query-properties)
(set-block-property! block-id :query-properties (str query-properties))
(remove-block-property! block-id :query-properties)))))
(defn set-block-timestamp!
[block-id key value]
(let [key (string/lower-case key)