chore: remove :block/collapsed-properties

experiment/tanstack-table
Tienson Qin 2024-06-25 10:57:44 +08:00
parent 3c838bc243
commit da4f9b5498
9 changed files with 2 additions and 86 deletions

View File

@ -20,7 +20,6 @@
:block/parent
:block/order
:block/collapsed?
:block/collapsed-properties
:block/format
:block/refs
:block/_refs

View File

@ -208,7 +208,6 @@
[:block/properties {:optional true} block-properties]
[:block/refs {:optional true} [:set :int]]
[:block/tags {:optional true} [:set :int]]
[:block/collapsed-properties {:optional true} [:set :int]]
[:block/tx-id {:optional true} :int]])
(def page-attrs

View File

@ -23,8 +23,6 @@
:db/index true}
:block/order {:db/index true}
:block/collapsed? {}
:block/collapsed-properties {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; :markdown, :org
:block/format {}

View File

@ -205,9 +205,6 @@
:create-property-text-block
(apply outliner-property/create-property-text-block! conn args)
:collapse-expand-block-property
(apply outliner-property/collapse-expand-block-property! conn args)
:batch-set-property
(apply outliner-property/batch-set-property! conn args)

View File

@ -334,14 +334,6 @@
[[:db/retract (:db/id block) property-id property-value]]
{:outliner-op :save-block}))))))))
(defn collapse-expand-block-property!
"Notice this works only if the value itself if a block (property type should be :default)"
[conn block-id property-id collapse?]
(let [f (if collapse? :db/add :db/retract)]
(ldb/transact! conn
[[f block-id :block/collapsed-properties property-id]]
{:outliner-op :save-block})))
(defn ^:api get-class-parents
[tags]
(let [tags' (filter (fn [tag] (contains? (:block/type tag) "class")) tags)

View File

@ -581,12 +581,6 @@
(ui/icon "plus" {:size 15})
[:div.ml-1.text-sm "Add property"]]]]))
(defn- property-collapsed?
[block property]
(boolean?
(some (fn [p] (= (:db/id property) (:db/id p)))
(:block/collapsed-properties block))))
(rum/defcs property-key <
(rum/local false ::hover?)
[state block property {:keys [class-schema? page-cp inline-text other-position?]}]
@ -699,7 +693,6 @@
(map? (first v))
(:block/page (first v))))
(contains? #{:default} type))
collapsed? (when block? (property-collapsed? block property))
date? (= type :date)
checkbox? (= type :checkbox)]
[:div {:class (cond
@ -710,7 +703,6 @@
[:div.property-key.col-span-2
(property-key block property (assoc (select-keys opts [:class-schema?])
:block? block?
:collapsed? collapsed?
:inline-text inline-text
:page-cp page-cp))]
[:div.property-value-container.col-span-3.flex.flex-row.gap-1.items-center
@ -720,9 +712,8 @@
(if (and (:class-schema? opts) (:page-configure? opts))
[:div.property-description.text-sm.opacity-70
(inline-text {} :markdown (get-in property [:block/schema :description]))]
(when-not collapsed?
[:div.property-value.flex.flex-1
(pv/property-value block property v opts)]))]]]))))
[:div.property-value.flex.flex-1
(pv/property-value block property v opts)])]]]))))
(rum/defcs ordered-properties < rum/reactive
{:init (fn [state]

View File

@ -48,13 +48,6 @@
{:outliner-op :create-property-text-block}
(outliner-op/create-property-text-block! block-id property-id value opts)))
(comment
(defn collapse-expand-block-property!
[block-id property-id collapse?]
(ui-outliner-tx/transact!
{:outliner-op :collapse-expand-block-property}
(outliner-op/collapse-expand-block-property! block-id property-id collapse?))))
(defn batch-set-property!
[block-id property-id value]
(ui-outliner-tx/transact!

View File

@ -77,12 +77,6 @@
(op-transact!
[:create-property-text-block [block-id property-id value opts]]))
(comment
(defn collapse-expand-block-property!
[block-id property-id collapse?]
(op-transact!
[:collapse-expand-block-property [block-id property-id collapse?]])))
(defn batch-set-property!
[block-ids property-id value]
(op-transact!

View File

@ -1,47 +0,0 @@
(ns frontend.handler.db-based.property-test
(:require [logseq.outliner.property :as outliner-property]
[frontend.db :as db]
[clojure.test :refer [deftest is testing use-fixtures]]
[frontend.test.helper :as test-helper]
[datascript.core :as d]))
(def init-data (test-helper/initial-test-page-and-blocks))
(defn start-and-destroy-db
[f]
(test-helper/db-based-start-and-destroy-db
f
{:init-data (fn [conn] (d/transact! conn init-data))}))
;; init page id
;; (def pid (:block/uuid (first init-data)))
;; first block id
(def fbid (:block/uuid (second init-data)))
(use-fixtures :each start-and-destroy-db)
;; collapse-expand-property!
(deftest collapse-expand-property-test
(testing "Collapse and expand property"
(let [conn (db/get-db false)
fb (db/entity [:block/uuid fbid])
k :user.property/property-1]
;; add property
(outliner-property/upsert-property! conn k {:type :default} {})
(let [property (db/entity k)]
(outliner-property/create-property-text-block! conn
(:db/id fb)
(:db/id property)
"Block content"
{})
;; collapse property-1
(outliner-property/collapse-expand-block-property! conn (:db/id fb) (:db/id property) true)
(is (=
[(:db/id property)]
(map :db/id (:block/collapsed-properties (db/entity [:block/uuid fbid])))))
;; expand property-1
(outliner-property/collapse-expand-block-property! conn (:db/id fb) (:db/id property) false)
(is (nil? (:block/collapsed-properties (db/entity [:block/uuid fbid]))))))))
#_(cljs.test/run-tests)