fix: :node property values should show unique names by tag

Fixes logseq/db-test#44 and also a part of LOG-3191
This commit is contained in:
Gabriel Horner
2024-08-30 12:36:49 -04:00
parent d9443a0fd0
commit 47970ee4c6
3 changed files with 16 additions and 9 deletions

View File

@@ -64,6 +64,7 @@
frontend.components.query.result query-result
frontend.components.class class-component
frontend.components.property property-component
frontend.components.title title
frontend.common.date common-date
frontend.common.file.core common-file
frontend.common.file.util wfu

View File

@@ -90,7 +90,8 @@
[electron.ipc :as ipc]
[frontend.db.async :as db-async]
[logseq.db.frontend.content :as db-content]
[logseq.db :as ldb]))
[logseq.db :as ldb]
[frontend.components.title :as title]))
;; local state
(defonce *dragging?
@@ -546,7 +547,7 @@
page-name-in-block is the overridable name of the page (legacy)
All page-names are sanitized except page-name-in-block"
[state {:keys [contents-page? whiteboard-page? html-export? meta-click?] :as config} page-entity children label]
[state {:keys [contents-page? whiteboard-page? html-export? meta-click? show-unique-title?] :as config} page-entity children label]
(let [*hover? (::hover? state)
*mouse-down? (::mouse-down? state)
tag? (:tag? config)
@@ -618,6 +619,9 @@
(coll? label)
(->elem :span (map-inline config label))
show-unique-title?
(title/block-unique-title page-entity)
:else
(let [title (:block/title page-entity)
s (cond untitled?

View File

@@ -27,7 +27,8 @@
[logseq.db.frontend.property.type :as db-property-type]
[dommy.core :as d]
[frontend.search :as search]
[goog.functions :refer [debounce]]))
[goog.functions :refer [debounce]]
[frontend.components.title :as title]))
(rum/defc property-empty-btn-value
[& {:as opts}]
@@ -388,7 +389,7 @@
options (map (fn [node]
(let [id (or (:value node) (:db/id node))
label (if (integer? id)
(let [title (subs (:block/title node) 0 256)
(let [title (subs (title/block-unique-title node) 0 256)
node (or (db/entity id) node)
icon (get-node-icon node)]
[:div.flex.flex-row.items-center.gap-1
@@ -659,22 +660,23 @@
(shui/button {:variant :ghost
:size :sm
:class "px-0 py-0 h-4"}
(ui/icon "edit" {:size 14})))])]
(ui/icon "edit" {:size 14})))])]
[:div.select-item.cursor-pointer
(cond
(= value :logseq.property/empty-placeholder)
(property-empty-btn-value)
(or (ldb/page? value)
(and (seq (:block/tags value))
;; FIXME: page-cp should be renamed to node-cp and
;; support this case and maybe other complex cases.
(not (string/includes? (:block/title value) "[["))))
(and (seq (:block/tags value))
;; FIXME: page-cp should be renamed to node-cp and
;; support this case and maybe other complex cases.
(not (string/includes? (:block/title value) "[["))))
(when value
(rum/with-key
(page-cp {:disable-preview? true
:tag? tag?
:hide-close-button? true
:show-unique-title? true
:meta-click? other-position?} value)
(:db/id value)))