mirror of https://github.com/logseq/logseq
feat: show ancestor classes on class page's configure section
parent
e6b02acdfa
commit
fff41f3e46
|
@ -437,6 +437,7 @@
|
|||
(js/console.error "No selected option found to navigate to"))))})))
|
||||
|
||||
(rum/defcs configure < rum/reactive
|
||||
(rum/local false ::parent-changed?)
|
||||
[state page {:keys [journal? show-properties?] :as opts
|
||||
:or {show-properties? true}}]
|
||||
(let [page-id (:db/id page)
|
||||
|
@ -445,7 +446,8 @@
|
|||
properties-opts (merge {:selected? false
|
||||
:page-configure? true}
|
||||
opts)
|
||||
class? (= type "class")]
|
||||
class? (= type "class")
|
||||
parent-changed? (::parent-changed? state)]
|
||||
(when page
|
||||
[:div.property-configure.grid.gap-2
|
||||
(when (and (not journal?) (contains? #{"property" "class" nil} type))
|
||||
|
@ -486,7 +488,23 @@
|
|||
[{:db/id (:db/id page)
|
||||
:block/namespace [:block/uuid (uuid value)]}])
|
||||
(db/transact!
|
||||
[[:db.fn/retractAttribute (:db/id page) :block/namespace]]))))])])])
|
||||
[[:db.fn/retractAttribute (:db/id page) :block/namespace]]))
|
||||
(swap! parent-changed? not)))])])])
|
||||
(when (and class? (:block/namespace page))
|
||||
[:div.grid.grid-cols-4.gap-1.items-center.class-ancestors
|
||||
[:div.col-span-1 "Ancestor classes:"]
|
||||
[:div.col-span-3
|
||||
(let [ancestor-pages (loop [namespaces [page]]
|
||||
(if-let [parent (:block/namespace (last namespaces))]
|
||||
(recur (conj namespaces parent))
|
||||
namespaces))
|
||||
class-ancestors (map :block/original-name (reverse ancestor-pages))]
|
||||
(interpose [:span " < "]
|
||||
(map (fn [class-name]
|
||||
(if (= class-name (:block/original-name page))
|
||||
[:span class-name]
|
||||
[:a {:on-click #(route-handler/redirect-to-page! class-name)} class-name]))
|
||||
class-ancestors)))]])
|
||||
(when (and config/publishing? (= type "property"))
|
||||
(property/property-config (state/get-current-repo) page {}))
|
||||
(when (and (not show-properties?) (not config/publishing?))
|
||||
|
|
Loading…
Reference in New Issue