mirror of https://github.com/logseq/logseq
fix: tests
parent
89efb99b71
commit
b0c03b0003
|
@ -22,9 +22,11 @@
|
|||
(let [id (:db/id m)
|
||||
children (-> (block-children id (inc level))
|
||||
(ldb/sort-by-order))]
|
||||
(assoc m
|
||||
:block/level level
|
||||
:block/children children)))
|
||||
(->
|
||||
(assoc m
|
||||
:block/level level
|
||||
:block/children children)
|
||||
(dissoc :block/parent :block/tx-id))))
|
||||
(sort-fn parent)))]
|
||||
(block-children root-id 1)))
|
||||
|
||||
|
|
|
@ -108,17 +108,17 @@
|
|||
(db-utils/pull id-or-uuid)
|
||||
(and id-or-uuid (db-model/query-block-by-uuid (sdk-utils/uuid-or-throw-error id-or-uuid))))]
|
||||
(when (or (true? (some-> opts (.-includePage)))
|
||||
(not (contains? block :block/name)))
|
||||
(not (contains? block :block/name)))
|
||||
(when-let [uuid (:block/uuid block)]
|
||||
(let [{:keys [includeChildren]} (bean/->clj opts)
|
||||
repo (state/get-current-repo)
|
||||
block (if includeChildren
|
||||
;; nested children results
|
||||
(first (outliner-tree/blocks->vec-tree
|
||||
(db-model/get-block-and-children repo uuid) uuid))
|
||||
(let [blocks (db-model/get-block-and-children repo uuid)]
|
||||
(first (outliner-tree/blocks->vec-tree blocks uuid)))
|
||||
;; attached shallow children
|
||||
(assoc block :block/children
|
||||
(map #(list :uuid (:block/uuid %))
|
||||
(db/get-block-immediate-children repo uuid))))
|
||||
(map #(list :uuid (:block/uuid %))
|
||||
(db/get-block-immediate-children repo uuid))))
|
||||
block (into-properties repo block)]
|
||||
(bean/->js (sdk-utils/normalize-keyword-for-json block)))))))
|
||||
|
|
|
@ -6,27 +6,32 @@
|
|||
[goog.object :as gobj]
|
||||
[cljs-bean.core :as bean]))
|
||||
|
||||
(defn- entity? [e]
|
||||
(when e (instance? de/Entity e)))
|
||||
(defn- entity->map
|
||||
"Convert a db Entity to a map"
|
||||
[e]
|
||||
(assert (de/entity? e))
|
||||
(assoc (into {} e) :db/id (:db/id e)))
|
||||
|
||||
(defn normalize-keyword-for-json
|
||||
([input] (normalize-keyword-for-json input true))
|
||||
([input camel-case?]
|
||||
(when input
|
||||
(let [input (cond
|
||||
(entity? input) (into {} input)
|
||||
(sequential? input) (map #(if (entity? %) (into {} %) %) input)
|
||||
(de/entity? input) (entity->map input)
|
||||
(sequential? input) (map #(if (de/entity? %)
|
||||
(entity->map %)
|
||||
%) input)
|
||||
:else input)]
|
||||
(walk/postwalk
|
||||
(fn [a]
|
||||
(cond
|
||||
(keyword? a)
|
||||
(cond-> (name a)
|
||||
camel-case?
|
||||
(csk/->camelCase))
|
||||
(fn [a]
|
||||
(cond
|
||||
(keyword? a)
|
||||
(cond-> (name a)
|
||||
camel-case?
|
||||
(csk/->camelCase))
|
||||
|
||||
(uuid? a) (str a)
|
||||
:else a)) input)))))
|
||||
(uuid? a) (str a)
|
||||
:else a)) input)))))
|
||||
|
||||
(defn uuid-or-throw-error
|
||||
[s]
|
||||
|
@ -56,4 +61,4 @@
|
|||
(def ^:export jsx-to-clj jsx->clj)
|
||||
(def ^:export to-js bean/->js)
|
||||
(def ^:export to-keyword keyword)
|
||||
(def ^:export to-symbol symbol)
|
||||
(def ^:export to-symbol symbol)
|
||||
|
|
Loading…
Reference in New Issue