mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 14:39:48 +00:00
fix: remove existing properties when auto-complete property key
This commit is contained in:
@@ -101,8 +101,12 @@
|
||||
shortcut/disable-all-shortcuts
|
||||
[state entity *property-key *property-value]
|
||||
(let [*search? (::search? state)
|
||||
entity-properties (->> (keys (:block/properties entity))
|
||||
(map #(:block/original-name (db/entity [:block/uuid %])))
|
||||
(set))
|
||||
result (when-not (string/blank? @*property-key)
|
||||
(search/property-search @*property-key))]
|
||||
(->> (search/property-search @*property-key)
|
||||
(remove entity-properties)))]
|
||||
[:div
|
||||
[:div.ls-property-add.grid.grid-cols-4.gap-1.flex.flex-row.items-center
|
||||
[:input#add-property.form-input.simple-input.block.col-span-1.focus:outline-none
|
||||
@@ -117,15 +121,17 @@
|
||||
"Escape"
|
||||
(exit-edit-property *property-key *property-value)
|
||||
|
||||
"Enter"
|
||||
(list "Tab" "Enter")
|
||||
(do
|
||||
(util/stop e)
|
||||
(reset! *search? false)
|
||||
(.focus (js/document.getElementById "add-property-value")))
|
||||
|
||||
nil))}]
|
||||
|
||||
[:input#add-property-value.block-properties
|
||||
{:on-change #(reset! *property-value (util/evalue %))
|
||||
[:input#add-property-value.form-input.simple-input.block.col-span-1.focus:outline-none
|
||||
{:placeholder "Value"
|
||||
:on-change #(reset! *property-value (util/evalue %))
|
||||
:on-key-down (fn [e]
|
||||
(case (util/ekey e)
|
||||
"Enter"
|
||||
|
||||
@@ -1171,7 +1171,7 @@ independent of format as format specific heading characters are stripped"
|
||||
distinct
|
||||
(map (fn [k]
|
||||
(if (uuid? k)
|
||||
(keyword (:block/name (d/entity db [:block/uuid k])))
|
||||
(:block/original-name (d/entity db [:block/uuid k]))
|
||||
k)))
|
||||
sort)))
|
||||
|
||||
|
||||
@@ -163,10 +163,12 @@
|
||||
;; cardinality changed from :one to :many
|
||||
(fix-cardinality-many-values! property-uuid))
|
||||
(let [tx-data (cond-> {:block/uuid property-uuid}
|
||||
property-name (assoc :block/name property-name)
|
||||
property-schema (assoc :block/schema property-schema)
|
||||
true outliner-core/block-with-updated-at)]
|
||||
(db/transact! repo [tx-data]))))
|
||||
property-name (merge
|
||||
{:block/original-name property-name
|
||||
:block/name (gp-util/page-name-sanity-lc property-name)})
|
||||
property-schema (assoc :block/schema property-schema)
|
||||
true outliner-core/block-with-updated-at)]
|
||||
(db/transact! repo [tx-data]))))
|
||||
|
||||
(defn delete-property-value!
|
||||
"Delete value if a property has multiple values"
|
||||
|
||||
Reference in New Issue
Block a user