feat: class children area

pull/11055/head
Tienson Qin 2024-02-28 02:47:23 +08:00 committed by Gabriel Horner
parent ab8f5a77d2
commit 76ebf19364
4 changed files with 33 additions and 3 deletions

View File

@ -41,6 +41,7 @@
;; TODO: remove this in later releases
:block/heading-level
:block/file
:class/parent
{:block/page [:db/id :block/name :block/original-name :block/journal-day]}
{:block/_parent ...}])

View File

@ -775,8 +775,8 @@
(rum/defc page-reference < rum/reactive
"Component for page reference"
[html-export? s {:keys [nested-link? id] :as config} label]
(let [show-brackets? (state/show-brackets?)
[html-export? s {:keys [nested-link? show-brackets? id] :as config} label]
(let [show-brackets? (if (some? show-brackets?) show-brackets? (state/show-brackets?))
block-uuid (:block/uuid config)
contents-page? (= "contents" (string/lower-case (str id)))]
(if (string/ends-with? s ".excalidraw")

View File

@ -6,7 +6,8 @@
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[rum.core :as rum]))
[rum.core :as rum]
[frontend.components.block :as block]))
(rum/defc class-select
[page class on-select]
@ -100,3 +101,27 @@
[:span class-name]
[:a {:on-click #(route-handler/redirect-to-page! class-name)} class-name]))
class-ancestors))]])))])))
(defn class-children-aux
[class]
(let [children (:class/_parent class)]
(when (seq children)
[:ul
(for [child children]
(let [title [:li.ml-2 (block/page-reference false (:block/original-name child) {:show-brackets? false} nil)]]
(if (seq (:class/_parent child))
(ui/foldable
title
(class-children-aux child)
{:default-collapsed? false})
title)))])))
(rum/defc class-children
[class]
(when (seq (:class/_parent class))
[:div.mt-4
(ui/foldable
[:h2.font-medium "Child classes"]
[:div.mt-2.ml-1 (class-children-aux class)]
{:default-collapsed? false
:title-trigger? true})]))

View File

@ -11,6 +11,7 @@
[frontend.components.scheduled-deadlines :as scheduled]
[frontend.components.icon :as icon-component]
[frontend.components.db-based.page :as db-page]
[frontend.components.class :as class-component]
[frontend.handler.property.util :as pu]
[frontend.handler.db-based.property :as db-property-handler]
[frontend.handler.db-based.property.util :as db-pu]
@ -555,6 +556,9 @@
(reference/references route-page-name)
(str route-page-name "-refs"))]))
(when (contains? (:block/type page) "class")
(class-component/class-children page))
(when-not block-or-whiteboard?
(when (not journal?)
(hierarchy/structures route-page-name)))