|
|
@@ -3350,17 +3350,19 @@
|
|
|
(mldoc/block-with-title? first-elem-type))
|
|
|
true)))
|
|
|
|
|
|
-(defn- valid-custom-query-block?
|
|
|
- "Whether block has a valid custom query."
|
|
|
+(defn- db-collapsable?
|
|
|
[block]
|
|
|
- (let [entity (db/entity (:db/id block))
|
|
|
- content (:block/title entity)]
|
|
|
- (when content
|
|
|
- (when (and (string/includes? content "#+BEGIN_QUERY")
|
|
|
- (string/includes? content "#+END_QUERY"))
|
|
|
- (let [ast (mldoc/->edn (string/trim content) (or (:block/format entity) :markdown))
|
|
|
- q (mldoc/extract-first-query-from-ast ast)]
|
|
|
- (some? (:query (common-util/safe-read-map-string q))))))))
|
|
|
+ (let [property-keys (->> (keys (:block/properties block))
|
|
|
+ (remove db-property/db-attribute-properties)
|
|
|
+ (remove #(outliner-property/property-with-other-position? (db/entity %))))]
|
|
|
+ (or (and (seq property-keys)
|
|
|
+ (not (db-pu/all-hidden-properties? property-keys)))
|
|
|
+ (and (seq (:block/tags block))
|
|
|
+ (some (fn [t]
|
|
|
+ (let [properties (map :db/ident (:logseq.property.class/properties t))]
|
|
|
+ (prn :tags (:block/title t) properties)
|
|
|
+ (and (seq properties)
|
|
|
+ (not (db-pu/all-hidden-properties? properties))))) (:block/tags block))))))
|
|
|
|
|
|
(defn collapsable?
|
|
|
([block-id]
|
|
|
@@ -3371,23 +3373,12 @@
|
|
|
(when block-id
|
|
|
(let [repo (state/get-current-repo)]
|
|
|
(if-let [block (db/entity [:block/uuid block-id])]
|
|
|
- (let [db-based? (config/db-based-graph? repo)
|
|
|
- tags (:block/tags (db/entity (:db/id block)))
|
|
|
- property-keys (->> (keys (:block/properties block))
|
|
|
- (remove db-property/db-attribute-properties)
|
|
|
- (remove #(outliner-property/property-with-other-position? (db/entity %))))]
|
|
|
+ (let [db-based? (config/db-based-graph? repo)]
|
|
|
(or (if ignore-children? false (db-model/has-children? block-id))
|
|
|
- (and (not db-based?) (file-editor-handler/valid-dsl-query-block? block))
|
|
|
- (valid-custom-query-block? block)
|
|
|
- (and db-based? (ldb/class-instance? (db/entity :logseq.class/Query) block))
|
|
|
- (and db-based?
|
|
|
- (seq property-keys)
|
|
|
- (not (db-pu/all-hidden-properties? property-keys)))
|
|
|
- (and db-based? (seq tags)
|
|
|
- (some (fn [t]
|
|
|
- (let [properties (map :db/ident (:logseq.property.class/properties (:block/schema t)))]
|
|
|
- (and (seq properties)
|
|
|
- (not (db-pu/all-hidden-properties? properties))))) tags))
|
|
|
+ (and db-based? (db-collapsable? block))
|
|
|
+ (and (not db-based?)
|
|
|
+ (or (file-editor-handler/valid-dsl-query-block? block)
|
|
|
+ (file-editor-handler/valid-custom-query-block? block)))
|
|
|
(and
|
|
|
(:outliner/block-title-collapse-enabled? (state/get-config))
|
|
|
(block-with-title? (:block/format block)
|