Browse Source

enhance(ux): add hidden properties area in sidebar and main page

Tienson Qin 4 months ago
parent
commit
aba80a4564

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

@@ -3762,7 +3762,7 @@
                                          :hide-block-refs-count? hide-block-refs-count?
                                          :*show-query? *show-query?}))])]
 
-         (when (and db-based? (not collapsed?) (not (or table? property? (:page-title? config))))
+         (when (and db-based? (not collapsed?) (not (or table? property?)))
            (block-positioned-properties config block :block-below))]])
 
      (when (and db-based?

+ 4 - 0
src/main/frontend/components/block.css

@@ -1074,6 +1074,10 @@ html.is-mac {
   height: 24px;
 }
 
+.ls-page-title .positioned-properties.block-below {
+  margin-left: 7px;
+}
+
 .ls-page-title .ls-properties-area .positioned-properties.block-left svg,
 .ls-page-title .ls-properties-area .positioned-properties.block-right svg {
   width: initial;

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

@@ -456,7 +456,8 @@
 
      [:div.w-full.relative
       (component-block/block-container
-       {:page-title? true
+       {:id (str (:block/uuid page))
+        :page-title? true
         :page-title-actions-cp (when (and with-actions?
                                           (not (util/mobile?))
                                           (not= (:db/id (state/get-edit-block)) (:db/id page)))
@@ -602,8 +603,10 @@
   [state {:keys [repo page preview? sidebar? tag-dialog? linked-refs? unlinked-refs? config] :as option}]
   (let [current-repo (state/sub :git/current-repo)
         *objects-ready? (::objects-ready? state)
-        config (assoc config :*objects-ready? *objects-ready?)
         page (or page (some-> (:db/id option) db/entity))
+        config (assoc config
+                      :*objects-ready? *objects-ready?
+                      :id (str (:block/uuid page)))
         repo (or repo current-repo)
         block? (some? (:block/page page))
         class-page? (ldb/class? page)

+ 41 - 23
src/main/frontend/components/property.cljs

@@ -556,6 +556,16 @@
                                    (:block/order (db/entity k)))) properties)]
       (ordered-properties block properties' opts))))
 
+(rum/defc hidden-properties-cp
+  [block hidden-properties {:keys [root-block? sidebar-properties?] :as opts}]
+  (when (and (seq hidden-properties) (or root-block? sidebar-properties?))
+    [:details.my-1
+     [:summary.text-sm.opacity-50.hover:opacity-90.cursor-pointer
+      {:style {:margin-left 11}}
+      [:span.ml-1 "Hidden properties"]]
+     [:div.mt-1
+      (properties-section block hidden-properties opts)]]))
+
 (rum/defcs ^:large-vars/cleanup-todo properties-area < rum/reactive db-mixins/query
   {:init (fn [state]
            (let [target-block (first (:rum/args state))
@@ -574,7 +584,7 @@
                                                      (and (set? ids) (contains? ids (:block/uuid block))))))
         properties (:block/properties block)
         remove-built-in-or-other-position-properties
-        (fn [properties]
+        (fn [properties show-in-hidden-properties?]
           (remove (fn [property]
                     (let [id (if (vector? property) (first property) property)]
                       (or
@@ -585,10 +595,10 @@
                           (and (not (ldb/public-built-in-property? ent))
                                (ldb/built-in? ent))
                           ;; other position
-                          (when-not (or show-properties?
-                                        (and (:sidebar? opts) (= (:id opts) (str (:block/uuid block))))
-                                        (and page-title? (not journal-page?))
-                                        show-empty-and-hidden-properties?)
+                          (when-not (or
+                                     (and page-title? (not journal-page?))
+                                     show-empty-and-hidden-properties?
+                                     show-in-hidden-properties?)
                             (outliner-property/property-with-other-position? ent))
 
                           (and (:gallery-view? opts)
@@ -598,7 +608,6 @@
         classes-properties-set (set (map :db/ident classes-properties))
         block-own-properties (->> properties
                                   (remove (fn [[id _]] (classes-properties-set id))))
-        root-block? (= (:id opts) (str (:block/uuid block)))
         state-hide-empty-properties? (:ui/hide-empty-properties? (state/get-config))
         ;; This section produces own-properties and full-hidden-properties
         hide-with-property-id (fn [property-id]
@@ -609,17 +618,11 @@
                                      false
                                      state-hide-empty-properties?
                                      (nil? (get block property-id))
+                                     (and (:logseq.property/hide-empty-value property)
+                                          (nil? (get properties property-id)))
+                                     true
                                      :else
-                                     ;; sidebar or tag dialog properties ignore these checks
-                                     (when-not (or show-properties? page-title?)
-                                       (cond
-                                         root-block?
-                                         false
-                                         (and (:logseq.property/hide-empty-value property)
-                                              (nil? (get properties property-id)))
-                                         true
-                                         :else
-                                         (boolean (:logseq.property/hide? property))))))))
+                                     (boolean (:logseq.property/hide? property))))))
         property-hide-f (cond
                           config/publishing?
                           ;; Publishing is read only so hide all blank properties as they
@@ -635,7 +638,7 @@
                               (nil? property-value)))
                           :else
                           (comp hide-with-property-id first))
-        {_block-hidden-properties true
+        {block-hidden-properties true
          block-own-properties' false} (group-by property-hide-f block-own-properties)
         class-properties (loop [classes all-classes
                                 properties (set (map first block-own-properties'))
@@ -643,19 +646,28 @@
                            (if-let [class (first classes)]
                              (let [cur-properties (->> (db-property/get-class-ordered-properties class)
                                                        (map :db/ident)
-                                                       (remove properties)
-                                                       (remove hide-with-property-id))]
+                                                       (remove properties))]
                                (recur (rest classes)
                                       (set/union properties (set cur-properties))
                                       (if (seq cur-properties)
                                         (into result cur-properties)
                                         result)))
                              result))
-        full-properties (->> (concat block-own-properties'
-                                     (map (fn [p] [p (get block p)]) class-properties))
-                             remove-built-in-or-other-position-properties)]
+        full-properties (-> (concat block-own-properties'
+                                    (remove property-hide-f (map (fn [p] [p (get block p)]) class-properties)))
+                            (remove-built-in-or-other-position-properties false))
+        hidden-properties (-> (concat block-hidden-properties
+                                      (filter property-hide-f (map (fn [p] [p (get block p)]) class-properties)))
+                              (remove-built-in-or-other-position-properties true))
+        root-block? (or (= (str (:block/uuid block))
+                           (state/get-current-page))
+                        (and (= (str (:block/uuid block)) (:id opts))
+                             (not (entity-util/page? block))))]
     (cond
-      (empty? full-properties)
+      (and (empty? full-properties) (seq hidden-properties) (not root-block?) (not sidebar-properties?))
+      nil
+
+      (and (empty? full-properties) (empty? hidden-properties))
       (when show-properties?
         (rum/with-key (new-property block opts) (str id "-add-property")))
 
@@ -673,6 +685,10 @@
          [:<>
           (properties-section block properties' opts)
 
+          (when-not class?
+            (hidden-properties-cp block hidden-properties
+                                  (assoc opts :root-block? root-block?)))
+
           (when (and page? (not class?))
             (rum/with-key (new-property block opts) (str id "-add-property")))
 
@@ -689,4 +705,6 @@
                  "Tag properties are inherited by all nodes using the tag. For example, each #Task node inherits 'Status' and 'Priority'."]]
                [:div.ml-4
                 (properties-section block properties opts')
+                (hidden-properties-cp block hidden-properties
+                                      (assoc opts :root-block? root-block?))
                 (rum/with-key (new-property block opts') (str id "-class-add-property"))]]))]]))))

+ 1 - 1
src/main/frontend/components/property/value.cljs

@@ -55,7 +55,7 @@
                :else
                "Empty")]
     (if (= text "Empty")
-      (shui/button (merge {:class "empty-btn" :variant :text} opts)
+      (shui/button (merge {:class "empty-btn !text-base" :variant :text} opts)
                    text)
       (shui/button (merge {:class "empty-btn !text-base" :variant :text} opts)
                    text))))

+ 3 - 3
src/main/frontend/modules/shortcut/config.cljs

@@ -397,7 +397,7 @@
                                              :fn      (fn []
                                                         (state/pub-event! [:editor/new-property {:property-key "Icon"}]))}
 
-   :editor/toggle-display-all-properties    {:binding "p a"
+   :editor/toggle-display-hidden-properties {:binding "p a"
                                              :db-graph? true
                                              :fn      ui-handler/toggle-show-empty-hidden-properties!}
 
@@ -875,7 +875,7 @@
           :editor/add-property-status
           :editor/add-property-priority
           :editor/add-property-icon
-          :editor/toggle-display-all-properties
+          :editor/toggle-display-hidden-properties
           :ui/toggle-wide-mode
           :ui/select-theme-color
           :ui/goto-plugins
@@ -1011,7 +1011,7 @@
      :editor/add-property-status
      :editor/add-property-priority
      :editor/add-property-icon
-     :editor/toggle-display-all-properties]
+     :editor/toggle-display-hidden-properties]
 
     :shortcut.category/toggle
     [:ui/toggle-help

+ 7 - 0
src/main/frontend/worker/db_worker.cljs

@@ -762,6 +762,13 @@
   [repo]
   (js/Promise. (embedding/task--update-index-info! repo)))
 
+(def-thread-api :thread-api/check-worker-status
+  [repo]
+  (when repo
+    (let [conn (worker-state/get-datascript-conn repo)]
+      (when @conn
+        {:available? (some? (d/entity @conn :logseq.class/Tag))}))))
+
 (comment
   (def-thread-api :general/dangerousRemoveAllDbs
     []

+ 12 - 9
src/main/mobile/init.cljs

@@ -12,7 +12,8 @@
             [frontend.util :as util]
             [logseq.shui.dialog.core :as shui-dialog]
             [mobile.components.ui :as cc-ui]
-            [mobile.state :as mobile-state]))
+            [mobile.state :as mobile-state]
+            [promesa.core :as p]))
 
 (def *init-url (atom nil))
 ;; FIXME: `appUrlOpen` are fired twice when receiving a same intent.
@@ -77,14 +78,16 @@
       (if (not is-active?)
         (editor-handler/save-current-block!)
         ;; check whether db-worker is available
-        (when-let [client-id @state/*db-worker-client-id]
-          (when @state/*db-worker
-            (js/navigator.locks.request client-id #js {:mode "exclusive"
-                                                       :ifAvailable true}
-                                        (fn [lock]
-                                          (when lock
-                                            ;; lock acquired, meaning the worker has terminated
-                                            (js/window.location.reload))))))))))
+        (when @state/*db-worker-client-id
+          (->
+           (p/timeout
+            (p/let [{:keys [available?]} (state/<invoke-db-worker :thread-api/check-worker-status)]
+              (when-not available?
+                (js/window.location.reload)))
+            100)
+           (p/catch (fn [error]
+                      (js/console.error error)
+                      (js/window.location.reload)))))))))
 
 (defn- general-init
   "Initialize event listeners used by both iOS and Android"

+ 2 - 2
src/resources/dicts/de.edn

@@ -696,7 +696,7 @@
  :command.editor/set-tags "Tags für ausgewählte Blöcke setzen"
  :command.editor/strike-through          "Durchgestrichen"
  :command.editor/toggle-block-children "Ein-/Ausklappen umschalten"
- :command.editor/toggle-display-all-properties "Alle Properties anzeigen/verstecken"
+ :command.editor/toggle-display-hidden-properties "Alle Properties anzeigen/verstecken"
  :command.editor/toggle-number-list      "Nummeriert/Unnummeriert umschalten"
  :command.editor/toggle-open-blocks      "Öffnen von Blöcken umschalten (alle Blöcke ein- oder ausklappen)"
  :command.editor/undo                    "Rückgängig"
@@ -796,5 +796,5 @@
  :shortcut.category/navigating           "Navigation"
  :shortcut.category/others               "Sonstiges"
  :shortcut.category/toggle               "Umschalten"
- 
+
  :views.table/live-query-title (fn [total] (str "Echtzeit-Query (" total ")"))}

+ 1 - 1
src/resources/dicts/en.edn

@@ -775,7 +775,7 @@
   :editor/copy-page-url "Copy page url"
   :ui/toggle-wide-mode "Toggle wide mode"
   :ui/highlight-recent-blocks "Toggle highlight recent blocks"
-  :editor/toggle-display-all-properties "Toggle display all properties"
+  :editor/toggle-display-hidden-properties "Toggle display hidden properties"
   :ui/select-theme-color "Select available theme colors"
   :ui/goto-plugins "Go to plugins dashboard"
   :ui/install-plugins-from-file "Install plugins from plugins.edn"