Skip to content

Commit

Permalink
fix(query): cannot toggle updated-at and created-at
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Jan 5, 2024
1 parent 71ed902 commit 805b7c9
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/main/frontend/components/query_table.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,8 @@
query-properties (if page? (remove #{:block} query-properties) query-properties)
columns (if (seq query-properties)
query-properties
(get-keys result page?))
included-columns #{:created-at :updated-at}]
(distinct
(if (some included-columns columns)
(concat (remove included-columns columns)
(filter included-columns columns)
included-columns)
columns))))
(get-keys result page?))]
(distinct columns)))

(defn- build-column-value
"Builds a column's tuple value for a query table given a row, column and
Expand Down Expand Up @@ -156,12 +150,12 @@
(get-in row [:block/properties column])))]))

(defn build-column-text [row column]
(case column
(case column
:page (or (get-in row [:block/page :block/original-name])
(get-in row [:block/original-name])
(get-in row [:block/content]))
:block (or (get-in row [:block/original-name])
(get-in row [:block/content]))
:block (or (get-in row [:block/original-name])
(get-in row [:block/content]))
(or (get-in row [:block/properties column])
(get-in row [:block/properties-text-values column])
(get-in row [(keyword :block column)]))))
Expand All @@ -185,27 +179,27 @@
property-separated-by-commas? (partial text/separated-by-commas? (state/get-config))
table-version (get-shui-component-version :table config)
result-as-text (for [row sort-result]
(for [column columns]
(for [column columns]
(build-column-text row column)))
render-column-value (fn [row-format cell-format value]
(cond
(cond
;; elements should be rendered as they are provided
(= :element cell-format) value
;; collections are treated as a comma separated list of page-cps
(coll? value) (->> (map #(page-cp {} {:block/name %}) value)
(interpose [:span ", "]))
;; boolean values need to first be stringified
(boolean? value) (str value)
;; string values will attempt to be rendered as pages, falling back to
(boolean? value) (str value)
;; string values will attempt to be rendered as pages, falling back to
;; inline-text when no page entity is found
(string? value) (if-let [page (db/entity [:block/name (util/page-name-sanity-lc value)])]
(page-cp {} page)
(inline-text row-format value))
;; anything else should just be rendered as provided
:else value))]

(case table-version
2 (shui/table-v2 {:data (conj [[columns]] result-as-text)}
2 (shui/table-v2 {:data (conj [[columns]] result-as-text)}
(make-shui-context config inline))
1 [:div.overflow-x-auto {:on-mouse-down (fn [e] (.stopPropagation e))
:style {:width "100%"}
Expand Down

0 comments on commit 805b7c9

Please sign in to comment.