Skip to content

Commit 3d96bf9

Browse files
committed
fix(property): show route-root hidden toggle and gate date edit icon
1 parent 6e88d53 commit 3d96bf9

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

src/main/frontend/components/property.cljs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@
510510
(db/sub-block (:db/id linked-block))
511511
(db/sub-block (:db/id block))))
512512

513+
(defn- show-property-panel-edit-button?
514+
[property opts]
515+
(and (contains? #{:date :datetime} (:logseq.property/type property))
516+
(= :block-below (:property-position opts))))
517+
513518
(defn- empty-panel-property-value?
514519
[value]
515520
(or (nil? value)
@@ -556,7 +561,7 @@
556561
(if (:class-schema? opts)
557562
(pv/property-value property (db/entity :logseq.property/description) opts)
558563
(pv/property-value block' property (assoc opts :suppress-inline-edit-icon? true)))]
559-
(when (contains? #{:date :datetime} type)
564+
(when (show-property-panel-edit-button? property opts)
560565
[:button.property-panel-edit-btn.select-none
561566
{:type "button"
562567
:on-click (fn [e]
@@ -948,10 +953,12 @@
948953
hidden-properties (-> (concat block-hidden-properties
949954
(filter property-hide-f class-property-pairs))
950955
(remove-built-in-or-other-position-properties true))
951-
root-block? (or (= (str (:block/uuid block))
952-
(state/get-current-page))
953-
(and (= (str (:block/uuid block)) (:id opts))
954-
(not (entity-util/page? block))))]
956+
current-route-page? (= (str (:block/uuid block)) (state/get-current-page))
957+
root-block? (and (= (str (:block/uuid block)) (:id opts))
958+
(not (entity-util/page? block)))
959+
show-hidden-properties-toggle-button? (and (seq hidden-properties)
960+
(or current-route-page?
961+
root-block?))]
955962
[:<>
956963
(load-bidirectional-properties block root-block? #(reset! *bidirectional-properties %))
957964
(let [has-bidirectional-properties? (seq bidirectional-properties)]
@@ -1007,8 +1014,12 @@
10071014
nil)
10081015

10091016
(when-not class?
1010-
(hidden-properties-cp block hidden-properties
1011-
(assoc opts :show-hidden-properties? show-hidden-properties?)))
1017+
[:<>
1018+
(when show-hidden-properties-toggle-button?
1019+
[:div.mb-1
1020+
(hidden-properties-toggle-button block {})])
1021+
(hidden-properties-cp block hidden-properties
1022+
(assoc opts :show-hidden-properties? show-hidden-properties?))])
10121023

10131024
(when (and show-properties-panel? (not replace-renderer))
10141025
[:div.properties-panel.gap-8

src/test/frontend/components/property/property_test.cljs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@
4141
(is (true? (property-component/hidden-properties-visible? block-uuid)))
4242
(property-component/toggle-hidden-properties-visibility! block-uuid)
4343
(is (false? (property-component/hidden-properties-visible? block-uuid)))))
44+
45+
(deftest show-property-panel-edit-button-test
46+
(is (false? (#'property-component/show-property-panel-edit-button?
47+
{:logseq.property/type :date}
48+
{}))
49+
"Date edit button should be hidden outside bottom properties")
50+
(is (false? (#'property-component/show-property-panel-edit-button?
51+
{:logseq.property/type :datetime}
52+
{}))
53+
"Datetime edit button should be hidden outside bottom properties")
54+
(is (true? (#'property-component/show-property-panel-edit-button?
55+
{:logseq.property/type :datetime}
56+
{:property-position :block-below}))
57+
"Datetime edit button should be shown for bottom properties"))

0 commit comments

Comments
 (0)