Просмотр исходного кода

Revert "Revert "enhance(ux): display tag property descriptions""

This reverts commit 555f5f7c6b070fb07afb2ed4e4a0fd785dc771f4.
Tienson Qin 1 год назад
Родитель
Сommit
0fb1b51059

+ 15 - 5
src/main/frontend/components/property.cljs

@@ -412,8 +412,7 @@
   [block k v {:keys [inline-text page-cp sortable-opts] :as opts}]
   (when (keyword? k)
     (when-let [property (db/sub-block (:db/id (db/entity k)))]
-      (let [class-properties? (= (:db/ident property) :logseq.property.class/properties)
-            type (get-in property [:block/schema :type] :default)
+      (let [type (get-in property [:block/schema :type] :default)
             closed-values? (seq (:property/closed-values property))
             block? (and v
                         (not closed-values?)
@@ -429,6 +428,8 @@
                                                                     :inline-text inline-text
                                                                     :page-cp page-cp))]
         [:div {:class (cond
+                        (and (= (:db/ident property) :logseq.property.class/properties) (seq v))
+                        "property-pair !flex flex-col"
                         (or date? checkbox?)
                         "property-pair items-center"
                         :else
@@ -437,18 +438,24 @@
            (dnd/sortable-item (assoc sortable-opts :class "property-key col-span-2") property-key-cp')
            [:div.property-key.col-span-2 property-key-cp'])
 
-         (when-not (:class-schema? opts)
+         (let [class-properties? (= (:db/ident property) :logseq.property.class/properties)
+               property-desc (when-not (= (:db/ident property) :logseq.property/description)
+                               (:logseq.property/description property))]
            [:div.property-value-container.col-span-3.flex.flex-row.gap-1.items-center
             (cond-> {}
               class-properties? (assoc :class (if (:logseq.property.class/properties block)
                                                 "ml-2 -mt-1"
                                                 "-ml-1")))
-            (when-not (or block? class-properties?)
+            (when-not (or block? class-properties? property-desc)
               [:div.opacity-30 {:style {:margin-left 5}}
                [:span.bullet-container.cursor [:span.bullet]]])
             [:div.flex.flex-1
              [:div.property-value.flex.flex-1
-              (pv/property-value block property v opts)]]])]))))
+              (cond-> {}
+                class-properties? (assoc :class :opacity-90))
+              (if (:class-schema? opts)
+                (pv/property-value property (db/entity :logseq.property/description) property-desc opts)
+                (pv/property-value block property v opts))]]])]))))
 
 (rum/defcs ordered-properties < rum/reactive
   {:init (fn [state]
@@ -512,6 +519,9 @@
         classes (concat (:block/tags block) (outliner-property/get-class-parents db (:block/tags block)))]
     (doseq [class classes]
       (db-async/<get-block repo (:db/id class) :children? false))
+    (when (ldb/class? block)
+      (doseq [property (:logseq.property.class/properties block)]
+        (db-async/<get-block repo (:db/id property) :children? false)))
     classes))
 
 (rum/defcs ^:large-vars/cleanup-todo properties-area < rum/reactive db-mixins/query

+ 15 - 6
src/main/frontend/components/property/value.cljs

@@ -32,8 +32,17 @@
             [frontend.components.title :as title]))
 
 (rum/defc property-empty-btn-value
-  [& {:as opts}]
-  (shui/button (merge {:class "empty-btn" :variant :text} opts) "Empty"))
+  [& {:keys [property] :as opts}]
+  (let [text (cond
+               (= (:db/ident property) :logseq.property/description)
+               "Add description"
+               :else
+               "Empty")]
+    (if (= text "Empty")
+      (shui/button (merge {:class "empty-btn" :variant :text} opts)
+                  text)
+      (shui/button (merge {:class "empty-btn !text-base" :variant :text} opts)
+                  text))))
 
 (rum/defc property-empty-text-value
   [& {:as opts}]
@@ -607,7 +616,7 @@
       [:div
        {:tabIndex 0
         :on-click (fn [] (<create-new-block! block property ""))}
-       (property-empty-btn-value)])))
+       (property-empty-btn-value {:property property})])))
 
 (rum/defcs property-block-value < rum/reactive db-mixins/query
                                   {:init (fn [state]
@@ -637,7 +646,7 @@
                 (:db/id v-block))
               :else
               invalid-warning)))
-        (property-empty-btn-value)))))
+        (property-empty-btn-value {:property property})))))
 
 (rum/defc closed-value-item < rum/reactive db-mixins/query
   [value {:keys [inline-text icon?]}]
@@ -680,7 +689,7 @@
     [:div.select-item.cursor-pointer
      (cond
        (= value :logseq.property/empty-placeholder)
-       (property-empty-btn-value)
+       (property-empty-btn-value {:property property})
 
        (or (ldb/page? value)
            (and (seq (:block/tags value))
@@ -776,7 +785,7 @@
                     (<create-new-block! block property "")))}
      (cond
        (and (= type :default) (nil? (:block/title value)))
-       [:div.jtrigger (property-empty-btn-value)]
+       [:div.jtrigger (property-empty-btn-value {:property property})]
 
        (= type :default)
        (property-block-value value block property page-cp)