Browse Source

enhance(ux): display the page properties on the right sidebar as default

charlie 1 year ago
parent
commit
cf3102b934

+ 4 - 1
src/main/frontend/components/block.cljs

@@ -3286,6 +3286,7 @@
         editing? (or (state/sub-editing? [container-id (:block/uuid block)])
                      (state/sub-editing? [:unknown-container (:block/uuid block)]))
         table? (:table? config*)
+        sidebar? (:sidebar? config*)
         property? (:property? config*)
         custom-query? (boolean (:custom-query? config*))
         ref-or-custom-query? (or ref? custom-query?)
@@ -3454,7 +3455,9 @@
      (when-not (:table? config)
        (query-property-cp block config collapsed?))
 
-     (when (and db-based? (not collapsed?) (not (or table? property?)))
+     (when (and db-based?
+             (or sidebar? (not collapsed?))
+             (not (or table? property?)))
        [:div (when-not (:page-title? config) {:style {:padding-left 45}})
         (db-properties-cp config block {:in-block-container? true})])
 

+ 5 - 3
src/main/frontend/components/objects.cljs

@@ -197,14 +197,16 @@
                                                        (set-data! (get-class-objects class))
                                                        (when-let [f (get-in table [:data-fns :set-row-selection!])]
                                                          (f {})))))})]
-        {:disable-on-pointer-down? true})])))
+        {:disable-on-pointer-down? true
+         :default-collapsed? (:sidebar? config)})])))
 
 (rum/defcs class-objects < rum/reactive db-mixins/query mixins/container-id
-  [state class current-page?]
+  [state class {:keys [current-page? sidebar?]}]
   (when class
     (let [class (db/sub-block (:db/id class))
           config {:container-id (:container-id state)
-                  :current-page? current-page?}
+                  :current-page? current-page?
+                  :sidebar? sidebar?}
           properties (outliner-property/get-class-properties class)
           repo (state/get-current-repo)
           objects (->> (db-model/sub-class-objects repo (:db/id class))

+ 3 - 2
src/main/frontend/components/page.cljs

@@ -485,6 +485,7 @@
        {:page-title? true
         :page-title-actions-cp (when (and with-actions? (not= (:db/id (state/get-edit-block)) (:db/id page))) db-page-title-actions)
         :hide-title? sidebar?
+        :sidebar? sidebar?
         :hide-children? true
         :container-id container-id
         :from-journals? (contains? #{:home :all-journals} (get-in (state/get-route-match) [:data :name]))}
@@ -610,7 +611,7 @@
                    :on-mouse-leave (fn [e]
                                      (page-mouse-leave e *control-show?))}
                   (page-blocks-collapse-control title *control-show? *all-collapsed?)])
-               (when (and (not whiteboard?) (not sidebar?) (ldb/page? page))
+               (when (and (not whiteboard?) (ldb/page? page))
                  (if db-based?
                    (db-page-title page whiteboard-page? sidebar? (:container-id state))
                    (page-title-cp page {:journal? journal?
@@ -622,7 +623,7 @@
               (db-page/configure-property page))
 
             (when (and db-based? class-page?)
-              (objects/class-objects page (:current-page? option)))
+              (objects/class-objects page {:current-page? option :sidebar? sidebar?}))
 
             (when (and db-based? (ldb/property? page))
               (objects/property-related-objects page (:current-page? option)))