fix: select

This commit is contained in:
Tienson Qin
2023-07-14 12:53:19 +08:00
parent dacda99a04
commit c2d8f650af
2 changed files with 14 additions and 12 deletions

View File

@@ -214,7 +214,10 @@
[block property]
(let [repo (state/get-current-repo)
items (->> (model/get-block-property-values (:block/uuid property))
(map (fn [[_id value]] {:value value}))
(mapcat (fn [[_id value]]
(if (coll? value)
(map (fn [v] {:value v}) value)
[{:value value}])))
(distinct))
add-property-f #(add-property! block (:block/original-name property) % true)]
(select/select {:items items
@@ -257,7 +260,7 @@
(add-property!)))}))
;; :others
(if editing?
[:div.flex.flex-1 {:class "property-value-content"}
[:div.flex.flex-1
(case type
(list :number :url)
(select block property)

View File

@@ -1230,16 +1230,15 @@ independent of format as format specific heading characters are stripped"
(defn get-block-property-values
"Get blocks which have this property."
[property-uuid]
(->>
(d/q
'[:find ?b ?v
:in $ ?property-uuid
:where
[?b :block/properties ?p]
[(get ?p ?property-uuid) ?v]
[(some? ?v)]]
(conn/get-db)
property-uuid)))
(d/q
'[:find ?b ?v
:in $ ?property-uuid
:where
[?b :block/properties ?p]
[(get ?p ?property-uuid) ?v]
[(some? ?v)]]
(conn/get-db)
property-uuid))
(defn get-template-by-name
[name]