Skip to content

Commit

Permalink
render a shitty table
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjeff0 committed Aug 31, 2022
1 parent 77c1088 commit 0609d46
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
55 changes: 38 additions & 17 deletions src/cljs/athens/types/query/table.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Flex
VStack
HStack
Button, Table, Thead, Tbody, Th, Td, Tr, Tfoot, textDecoration, Link
Text]]
["@dnd-kit/core" :refer [closestCorners,
DragOverlay,]]
Expand Down Expand Up @@ -51,18 +52,33 @@


(defn render-entity
[uid children]
(let [entity (->> (reactive/get-reactive-block-document [:block/uid uid])
shared/block-to-flat-map)
page-title (common-db/get-page-title @db/dsdb uid)
task-title (get entity ":task/title")
status (get entity ":task/status")
priority (get entity ":task/priority")
assignee (get entity ":task/assignee")
_page (get entity ":task/page")
_due-date (get entity ":task/due-date")]
[:> Box
[:> Heading {:size "sm"} (or task-title page-title)]
[uid children columns]
(let [entity (->> (reactive/get-reactive-block-document [:block/uid uid])
shared/block-to-flat-map)
page-title (common-db/get-page-title @db/dsdb uid)
task-title (get entity ":task/title")
title (or page-title task-title)
status (get entity ":task/status")

priority (get entity ":task/priority")
assignee (get entity ":task/assignee")
_page (get entity ":task/page")
due-date (get entity ":task/due-date")

assignee-value (shared/parse-for-title assignee)
status-uid (shared/parse-for-uid status)
status-value (common-db/get-block-string @db/dsdb status-uid)
priority-uid (shared/parse-for-uid priority)
priority-value (common-db/get-block-string @db/dsdb priority-uid)
parent-uid (:block/uid (common-db/get-parent @db/dsdb [:block/uid uid]))]

[:> Box {:width "100%"}
[:> HStack {:justifyContent "space-between" :width "100%"}
[:> Heading {:size "sm"} title]
[:> Text {:size "md"} status-value]
[:> Text {:size "md"} priority-value]
[:> Text {:size "md"} assignee-value]
[:> Text {:size "md"} due-date]]
[:> Box
(for [[uid children] children]
^{:key uid}
Expand All @@ -71,9 +87,14 @@


(defn QueryTableV2
[{:keys [data] :as props}]
[:> Box
(for [[uid children] data]
^{:key uid}
[render-entity uid children])])
[{:keys [data columns] :as props}]
[:> VStack
[:> HStack {:justifyContent "space-between" :width "100%"}
(for [column columns]
^{:key column}
[:> Heading {:size "md"} column])]
[:<>
(for [[uid children] data]
^{:key uid}
[render-entity uid children columns])]])

3 changes: 2 additions & 1 deletion src/cljs/athens/types/query/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@
(sort-by sort-by-parents-count))
task-trees (tasks-to-trees tasks)]

[QueryTableV2 {:data task-trees}]))]))
[QueryTableV2 {:data task-trees
:columns ["Title" "Status" "Priority" "Assignee" "Due Date"]}]))]))



Expand Down

0 comments on commit 0609d46

Please sign in to comment.