|
|
@@ -28,21 +28,35 @@
|
|
|
:file/path (:v e)
|
|
|
:file/content (:file/content (d/entity db (:e e)))}))))
|
|
|
|
|
|
+(defn- get-block-with-refs
|
|
|
+ [db block]
|
|
|
+ (update block :block/refs (fn [refs]
|
|
|
+ (map (fn [ref]
|
|
|
+ (let [e (d/entity db (:db/id ref))]
|
|
|
+ (if (and e (:block/name e))
|
|
|
+ (assoc ref
|
|
|
+ :block/uuid (:block/uuid e)
|
|
|
+ :block/original-name (:block/name e)
|
|
|
+ :block/name (:block/name e))
|
|
|
+ ref))) refs))))
|
|
|
+
|
|
|
(defn get-block-and-children
|
|
|
[db name children?]
|
|
|
(let [get-children (fn [col]
|
|
|
(map (fn [e]
|
|
|
- (select-keys e [:db/id :block/uuid :block/page :block/left :block/parent]))
|
|
|
+ (select-keys e [:db/id :block/uuid :block/page :block/left :block/parent :block/collapsed?]))
|
|
|
col))
|
|
|
uuid? (common-util/uuid-string? name)
|
|
|
block (when uuid?
|
|
|
(let [id (uuid name)]
|
|
|
(d/entity db [:block/uuid id])))]
|
|
|
(if (and block (not (:block/name block))) ; not a page
|
|
|
- (cond->
|
|
|
- {:block (d/pull db '[*] (:db/id block))}
|
|
|
- children?
|
|
|
- (assoc :children (get-children (:block/_parent block))))
|
|
|
+ (let [block' (d/pull db '[*] (:db/id block))
|
|
|
+ block-with-refs (get-block-with-refs db block')]
|
|
|
+ (cond->
|
|
|
+ {:block block-with-refs}
|
|
|
+ children?
|
|
|
+ (assoc :children (get-children (:block/_parent block)))))
|
|
|
(when-let [block (or block (d/entity db [:block/name name]))]
|
|
|
(cond->
|
|
|
{:block (d/pull db '[*] (:db/id block))}
|