|
|
@@ -1531,8 +1531,9 @@
|
|
|
(shui/table-footer (add-new-row (:view-entity option) table)))]]))))
|
|
|
|
|
|
(rum/defc list-view < rum/static
|
|
|
- [{:keys [config ref-matched-children-ids] :as option} view-entity {:keys [rows]} *scroller-ref]
|
|
|
- (let [lazy-item-render (fn [rows idx]
|
|
|
+ [{:keys [config ref-matched-children-ids view-feature-type] :as option} view-entity {:keys [rows]} *scroller-ref]
|
|
|
+ (let [references-view? (contains? #{:linked-references :unlinked-references} view-feature-type)
|
|
|
+ lazy-item-render (fn [rows idx]
|
|
|
(lazy-item rows idx (assoc option :list-view? true)
|
|
|
(fn [block]
|
|
|
(let [config' (cond->
|
|
|
@@ -1544,17 +1545,21 @@
|
|
|
(block-container config' block)))))
|
|
|
list-cp (fn [rows]
|
|
|
(when (seq rows)
|
|
|
- (ui/virtualized-list
|
|
|
- {:ref #(reset! *scroller-ref %)
|
|
|
- :class "content"
|
|
|
- :custom-scroll-parent (get-scroll-parent config)
|
|
|
- :increase-viewport-by {:top 64 :bottom 64}
|
|
|
- :compute-item-key (fn [idx]
|
|
|
- (let [block-id (util/nth-safe rows idx)]
|
|
|
- (str "list-row-" block-id)))
|
|
|
- :total-count (count rows)
|
|
|
- :skipAnimationFrameInResizeObserver true
|
|
|
- :item-content (fn [idx] (lazy-item-render rows idx))})))
|
|
|
+ (if references-view?
|
|
|
+ [:div.content
|
|
|
+ (for [[idx _row] (medley/indexed rows)]
|
|
|
+ (lazy-item-render rows idx))]
|
|
|
+ (ui/virtualized-list
|
|
|
+ {:ref #(reset! *scroller-ref %)
|
|
|
+ :class "content"
|
|
|
+ :custom-scroll-parent (get-scroll-parent config)
|
|
|
+ :increase-viewport-by {:top 64 :bottom 64}
|
|
|
+ :compute-item-key (fn [idx]
|
|
|
+ (let [block-id (util/nth-safe rows idx)]
|
|
|
+ (str "list-row-" block-id)))
|
|
|
+ :total-count (count rows)
|
|
|
+ :skipAnimationFrameInResizeObserver true
|
|
|
+ :item-content (fn [idx] (lazy-item-render rows idx))}))))
|
|
|
breadcrumb (state/get-component :block/breadcrumb)
|
|
|
all-numbers? (every? number? rows)]
|
|
|
(if all-numbers?
|
|
|
@@ -1943,61 +1948,62 @@
|
|
|
{:ref *view-ref}
|
|
|
(ui/foldable
|
|
|
(view-head view-parent view-entity table columns input sorting set-input! add-new-object! option)
|
|
|
- [:div.ls-view-body.flex.flex-col.gap-2.grid.mt-1
|
|
|
- (filters-row view-entity table option)
|
|
|
-
|
|
|
- (let [view-opts {:*scroller-ref *scroller-ref
|
|
|
- :display-type display-type
|
|
|
- :row-selection row-selection
|
|
|
- :add-new-object! add-new-object!}]
|
|
|
- (if (and group-by-property-ident (not (number? (first (:rows table)))))
|
|
|
- (when (seq (:rows table))
|
|
|
- [:div.flex.flex-col.border-t.pt-2.gap-2
|
|
|
- (map-indexed
|
|
|
- (fn [idx [value group]]
|
|
|
- (let [add-new-object! (when (fn? add-new-object!)
|
|
|
- (fn [_]
|
|
|
- (add-new-object! view-entity table
|
|
|
- {:properties {(:db/ident group-by-property) (or (and (map? value) (:db/id value)) value)}})))
|
|
|
- table' (shui/table-option (-> table-map
|
|
|
- (assoc-in [:data-fns :add-new-object!] add-new-object!)
|
|
|
- (assoc :data group ; data for this group
|
|
|
- )))
|
|
|
- readable-property-value #(cond (and (map? %) (or (:block/title %) (:logseq.property/value %)))
|
|
|
- (db-property/property-value-content %)
|
|
|
- (= (:db/ident %) :logseq.property/empty-placeholder)
|
|
|
- "Empty"
|
|
|
- :else
|
|
|
- (str %))
|
|
|
- group-by-page? (or (= :block/page group-by-property-ident)
|
|
|
- (and (not db-based?) (contains? #{:linked-references :unlinked-references} display-type)))]
|
|
|
- (rum/with-key
|
|
|
- (ui/foldable
|
|
|
- [:div
|
|
|
- {:class (when-not list-view? "my-4")}
|
|
|
- (cond
|
|
|
- group-by-page?
|
|
|
- (if value
|
|
|
- (let [c (state/get-component :block/page-cp)]
|
|
|
- (c {:disable-preview? true} value))
|
|
|
- [:div.text-muted-foreground.text-sm
|
|
|
- "Pages"])
|
|
|
-
|
|
|
- (some? value)
|
|
|
- (let [icon (pu/get-block-property-value value :logseq.property/icon)]
|
|
|
- [:div.flex.flex-row.gap-1.items-center
|
|
|
- (when icon (icon-component/icon icon {:color? true}))
|
|
|
- (readable-property-value value)])
|
|
|
- :else
|
|
|
- (str "No " (:block/title group-by-property)))]
|
|
|
- (let [render (view-cp view-entity (assoc table' :rows group) option view-opts)]
|
|
|
- (if list-view? [:div.-ml-2 render] render))
|
|
|
- {:title-trigger? false})
|
|
|
- (str (:db/id view-entity) "-group-idx-" idx))))
|
|
|
- (:rows table))])
|
|
|
- (view-cp view-entity table
|
|
|
- (assoc option :group-by-property-ident group-by-property-ident)
|
|
|
- view-opts)))]
|
|
|
+ (fn []
|
|
|
+ [:div.ls-view-body.flex.flex-col.gap-2.grid.mt-1
|
|
|
+ (filters-row view-entity table option)
|
|
|
+
|
|
|
+ (let [view-opts {:*scroller-ref *scroller-ref
|
|
|
+ :display-type display-type
|
|
|
+ :row-selection row-selection
|
|
|
+ :add-new-object! add-new-object!}]
|
|
|
+ (if (and group-by-property-ident (not (number? (first (:rows table)))))
|
|
|
+ (when (seq (:rows table))
|
|
|
+ [:div.flex.flex-col.border-t.pt-2.gap-2
|
|
|
+ (map-indexed
|
|
|
+ (fn [idx [value group]]
|
|
|
+ (let [add-new-object! (when (fn? add-new-object!)
|
|
|
+ (fn [_]
|
|
|
+ (add-new-object! view-entity table
|
|
|
+ {:properties {(:db/ident group-by-property) (or (and (map? value) (:db/id value)) value)}})))
|
|
|
+ table' (shui/table-option (-> table-map
|
|
|
+ (assoc-in [:data-fns :add-new-object!] add-new-object!)
|
|
|
+ (assoc :data group ; data for this group
|
|
|
+ )))
|
|
|
+ readable-property-value #(cond (and (map? %) (or (:block/title %) (:logseq.property/value %)))
|
|
|
+ (db-property/property-value-content %)
|
|
|
+ (= (:db/ident %) :logseq.property/empty-placeholder)
|
|
|
+ "Empty"
|
|
|
+ :else
|
|
|
+ (str %))
|
|
|
+ group-by-page? (or (= :block/page group-by-property-ident)
|
|
|
+ (and (not db-based?) (contains? #{:linked-references :unlinked-references} display-type)))]
|
|
|
+ (rum/with-key
|
|
|
+ (ui/foldable
|
|
|
+ [:div
|
|
|
+ {:class (when-not list-view? "my-4")}
|
|
|
+ (cond
|
|
|
+ group-by-page?
|
|
|
+ (if value
|
|
|
+ (let [c (state/get-component :block/page-cp)]
|
|
|
+ (c {:disable-preview? true} value))
|
|
|
+ [:div.text-muted-foreground.text-sm
|
|
|
+ "Pages"])
|
|
|
+
|
|
|
+ (some? value)
|
|
|
+ (let [icon (pu/get-block-property-value value :logseq.property/icon)]
|
|
|
+ [:div.flex.flex-row.gap-1.items-center
|
|
|
+ (when icon (icon-component/icon icon {:color? true}))
|
|
|
+ (readable-property-value value)])
|
|
|
+ :else
|
|
|
+ (str "No " (:block/title group-by-property)))]
|
|
|
+ (let [render (view-cp view-entity (assoc table' :rows group) option view-opts)]
|
|
|
+ (if list-view? [:div.-ml-2 render] render))
|
|
|
+ {:title-trigger? false})
|
|
|
+ (str (:db/id view-entity) "-group-idx-" idx))))
|
|
|
+ (:rows table))])
|
|
|
+ (view-cp view-entity table
|
|
|
+ (assoc option :group-by-property-ident group-by-property-ident)
|
|
|
+ view-opts)))])
|
|
|
(merge {:title-trigger? false} foldable-options))]))
|
|
|
|
|
|
(rum/defcs view-container
|