Browse Source

chore: remove :block/collapsed-properties

Tienson Qin 1 year ago
parent
commit
da4f9b5498

+ 0 - 1
deps/db/src/logseq/db.cljs

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

+ 0 - 1
deps/db/src/logseq/db/frontend/malli_schema.cljs

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

+ 0 - 2
deps/db/src/logseq/db/frontend/schema.cljs

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

+ 0 - 3
deps/outliner/src/logseq/outliner/op.cljs

@@ -205,9 +205,6 @@
          :create-property-text-block
          :create-property-text-block
          (apply outliner-property/create-property-text-block! conn args)
          (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
          :batch-set-property
          (apply outliner-property/batch-set-property! conn args)
          (apply outliner-property/batch-set-property! conn args)
 
 

+ 0 - 8
deps/outliner/src/logseq/outliner/property.cljs

@@ -334,14 +334,6 @@
                              [[:db/retract (:db/id block) property-id property-value]]
                              [[:db/retract (:db/id block) property-id property-value]]
                              {:outliner-op :save-block}))))))))
                              {: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
 (defn ^:api get-class-parents
   [tags]
   [tags]
   (let [tags' (filter (fn [tag] (contains? (:block/type tag) "class")) tags)
   (let [tags' (filter (fn [tag] (contains? (:block/type tag) "class")) tags)

+ 2 - 11
src/main/frontend/components/property.cljs

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

+ 0 - 7
src/main/frontend/handler/db_based/property.cljs

@@ -48,13 +48,6 @@
    {:outliner-op :create-property-text-block}
    {:outliner-op :create-property-text-block}
     (outliner-op/create-property-text-block! block-id property-id value opts)))
     (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!
 (defn batch-set-property!
   [block-id property-id value]
   [block-id property-id value]
   (ui-outliner-tx/transact!
   (ui-outliner-tx/transact!

+ 0 - 6
src/main/frontend/modules/outliner/op.cljs

@@ -77,12 +77,6 @@
   (op-transact!
   (op-transact!
    [:create-property-text-block [block-id property-id value opts]]))
    [: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!
 (defn batch-set-property!
   [block-ids property-id value]
   [block-ids property-id value]
   (op-transact!
   (op-transact!

+ 0 - 47
src/test/frontend/handler/db_based/property_test.cljs

@@ -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)