fix(ui): missing tr/thead/tbody in query-table

pull/3536/head
Andelf 2021-12-21 11:58:36 +08:00 committed by Tienson Qin
parent 7c1076673b
commit 0319e3f4d6
1 changed files with 59 additions and 56 deletions

View File

@ -50,7 +50,7 @@
result (map (fn [b] result (map (fn [b]
(let [b (block/parse-title-and-body b)] (let [b (block/parse-title-and-body b)]
(assoc-in b ks (or (clock/clock-summary (:block/body b) false) 0)))) (assoc-in b ks (or (clock/clock-summary (:block/body b) false) 0))))
result)] result)]
(if (every? #(zero? (get-in % ks)) result) (if (every? #(zero? (get-in % ks)) result)
(map #(medley/dissoc-in % ks) result) (map #(medley/dissoc-in % ks) result)
result))) result)))
@ -109,62 +109,65 @@
[:div.overflow-x-auto {:on-mouse-down (fn [e] (.stopPropagation e)) [:div.overflow-x-auto {:on-mouse-down (fn [e] (.stopPropagation e))
:style {:width "100%"}} :style {:width "100%"}}
[:table.table-auto [:table.table-auto
(for [key keys] [:thead
(let [key-name (if (and (= key :clock-time) (integer? clock-time-total)) [:tr.cursor
(util/format "clock-time(total: %s)" (clock/minutes->days:hours:minutes (for [key keys]
clock-time-total)) (let [key-name (if (and (= key :clock-time) (integer? clock-time-total))
(name key))] (util/format "clock-time(total: %s)" (clock/minutes->days:hours:minutes
(sortable-title key-name key *sort-by-item *desc? (:block/uuid current-block)))) clock-time-total))
(for [item result] (name key))]
(let [format (:block/format item) (sortable-title key-name key *sort-by-item *desc? (:block/uuid current-block))))]]
edit-input-id (str "edit-block-" (:id config) "-" (:block/uuid item)) [:tbody
heading-level (:block/heading-level item)] (for [item result]
[:tr.cursor (let [format (:block/format item)
(for [key keys] edit-input-id (str "edit-block-" (:id config) "-" (:block/uuid item))
(let [value (case key heading-level (:block/heading-level item)]
:page [:tr.cursor
[:string (or (:block/original-name item) (for [key keys]
(:block/name item))] (let [value (case key
:page
[:string (or (:block/original-name item)
(:block/name item))]
:block ; block title :block ; block title
(let [content (:block/content item) (let [content (:block/content item)
{:block/keys [title]} (block/parse-title-and-body {:block/keys [title]} (block/parse-title-and-body
(:block/uuid item) (:block/uuid item)
(:block/format item) (:block/format item)
(:block/pre-block? item) (:block/pre-block? item)
content)] content)]
(if (seq title) (if (seq title)
[:element (->elem :div (map-inline config title))] [:element (->elem :div (map-inline config title))]
[:string content])) [:string content]))
:created-at :created-at
[:string (when-let [created-at (:block/created-at item)] [:string (when-let [created-at (:block/created-at item)]
(date/int->local-time-2 created-at))] (date/int->local-time-2 created-at))]
:updated-at :updated-at
[:string (when-let [updated-at (:block/updated-at item)] [:string (when-let [updated-at (:block/updated-at item)]
(date/int->local-time-2 updated-at))] (date/int->local-time-2 updated-at))]
[:string (get-in item [:block/properties key])])] [:string (get-in item [:block/properties key])])]
[:td.whitespace-nowrap {:on-mouse-down (fn [] (reset! select? false)) [:td.whitespace-nowrap {:on-mouse-down (fn [] (reset! select? false))
:on-mouse-move (fn [] (reset! select? true)) :on-mouse-move (fn [] (reset! select? true))
:on-mouse-up (fn [] :on-mouse-up (fn []
(when-not @select? (when-not @select?
(state/sidebar-add-block! (state/sidebar-add-block!
(state/get-current-repo) (state/get-current-repo)
(:db/id item) (:db/id item)
:block-ref :block-ref
{:block item})))} {:block item})))}
(when value (when value
(if (= :element (first value)) (if (= :element (first value))
(second value) (second value)
(let [value (second value)] (let [value (second value)]
(if (coll? value) (if (coll? value)
(let [vals (for [item value] (let [vals (for [item value]
(page-cp {} {:block/name item}))] (page-cp {} {:block/name item}))]
(interpose [:span ", "] vals)) (interpose [:span ", "] vals))
(if (not (string? value)) (if (not (string? value))
value value
(if-let [page (db/entity [:block/name (string/lower-case value)])] (if-let [page (db/entity [:block/name (string/lower-case value)])]
(page-cp {} page) (page-cp {} page)
(inline-text format value)))))))]))]))]]))) (inline-text format value)))))))]))]))]]])))