mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: dnd-kit sortable items require ids
This commit is contained in:
@@ -35,9 +35,14 @@
|
||||
children]))
|
||||
|
||||
(rum/defc items
|
||||
[col {:keys [on-drag-end parent-node vertical? sort-by-inner-element?]
|
||||
:or {vertical? true}}]
|
||||
(let [ids (mapv :id col)
|
||||
[col* {:keys [on-drag-end parent-node vertical? sort-by-inner-element?]
|
||||
:or {vertical? true}}]
|
||||
(assert (every? :id col*))
|
||||
(when (some #(nil? (:id %)) col*)
|
||||
(js/console.error "dnd-kit items without id")
|
||||
(prn :col col*))
|
||||
(let [col (filter :id col*)
|
||||
ids (mapv :id col)
|
||||
items' (bean/->js ids)
|
||||
id->item (zipmap ids col)
|
||||
[items-state set-items] (rum/use-state items')
|
||||
|
||||
@@ -1911,7 +1911,8 @@
|
||||
{pinned true unpinned false} (group-by (fn [item]
|
||||
(contains? pinned-properties (:id item)))
|
||||
(remove (fn [column]
|
||||
(false? (get visible-columns (:id column))))
|
||||
(or (false? (get visible-columns (:id column)))
|
||||
(nil? (:name column))))
|
||||
columns))
|
||||
group-by-property (or (:logseq.property.view/group-by-property view-entity)
|
||||
(db/entity group-by-property-ident))
|
||||
|
||||
@@ -7,22 +7,37 @@
|
||||
|
||||
(defn- fix-invalid-blocks!
|
||||
[conn errors]
|
||||
(let [tx-data (keep
|
||||
(let [tx-data (mapcat
|
||||
(fn [{:keys [entity dispatch-key]}]
|
||||
(let [entity (d/entity @conn (:db/id entity))]
|
||||
(cond
|
||||
(and (= dispatch-key :block) (nil? (:block/title entity)))
|
||||
[[:db/retractEntity (:db/id entity)]]
|
||||
|
||||
(and (= dispatch-key :block) (nil? (:block/page entity)))
|
||||
(let [latest-journal-id (:db/id (first (ldb/get-latest-journals @conn)))
|
||||
page-id (:db/id (:block/page (:block/parent entity)))]
|
||||
(cond
|
||||
page-id
|
||||
[[:db/add (:db/id entity) :block/page page-id]]
|
||||
latest-journal-id
|
||||
[[:db/add (:db/id entity) :block/page latest-journal-id]
|
||||
[:db/add (:db/id entity) :block/parent latest-journal-id]]
|
||||
:else
|
||||
(js/console.error (str "Don't know where to put the block " (:db/id entity)))))
|
||||
|
||||
(:block.temp/fully-loaded? entity)
|
||||
[:db/retract (:db/id entity) :block.temp/fully-loaded?]
|
||||
[[:db/retract (:db/id entity) :block.temp/fully-loaded?]]
|
||||
(and (:block/page entity) (not (:block/parent entity)))
|
||||
[:db/add (:db/id entity) :block/parent (:db/id (:block/page entity))]
|
||||
[[:db/add (:db/id entity) :block/parent (:db/id (:block/page entity))]]
|
||||
(and (not (:block/page entity)) (not (:block/parent entity)) (not (:block/name entity)))
|
||||
[:db/retractEntity (:db/id entity)]
|
||||
[[:db/retractEntity (:db/id entity)]]
|
||||
(and (= dispatch-key :property-value-block) (:block/title entity))
|
||||
[:db/retract (:db/id entity) :block/title]
|
||||
[[:db/retract (:db/id entity) :block/title]]
|
||||
(and (ldb/class? entity) (not (:logseq.property.class/extends entity)))
|
||||
[:db/add (:db/id entity) :logseq.property.class/extends :logseq.class/Root]
|
||||
[[:db/add (:db/id entity) :logseq.property.class/extends :logseq.class/Root]]
|
||||
(and (or (ldb/class? entity) (ldb/property? entity)) (ldb/internal-page? entity))
|
||||
[:db/retract (:db/id entity) :block/tags :logseq.class/Page]
|
||||
[[:db/retract (:db/id entity) :block/tags :logseq.class/Page]]
|
||||
:else
|
||||
nil)))
|
||||
errors)]
|
||||
|
||||
Reference in New Issue
Block a user