Browse Source

fix: adding existing values to page and date properties

multiple bugs:
- detected existing closed values incorrectly
- didn't display closed values
- didn't add existing values correctly
Gabriel Horner 1 year ago
parent
commit
aa58ff3a4a
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/main/frontend/components/property/closed_value.cljs

+ 6 - 3
src/main/frontend/components/property/closed_value.cljs

@@ -17,7 +17,8 @@
             [frontend.db.async :as db-async]
             [frontend.state :as state]
             [promesa.core :as p]
-            [logseq.db.frontend.property :as db-property]))
+            [logseq.db.frontend.property :as db-property]
+            [logseq.db.frontend.property.type :as db-property-type]))
 
 (defn- <upsert-closed-value!
   "Create new closed value and returns its block UUID."
@@ -183,7 +184,7 @@
    [:ol
     (for [value values]
       [:li (if (uuid? value)
-             (let [result (db/entity value)]
+             (let [result (db/entity [:block/uuid value])]
                (:block/original-name result))
              (str value))])]
    (ui/button
@@ -224,7 +225,9 @@
              (shui/popup-show! (.-target e)
                                (fn [{:keys [id]}]
                                  (let [opts {:toggle-fn (fn [] (shui/popup-hide! id))}
-                                       values' (->> (map second values)
+                                       values' (->> (if (contains? db-property-type/ref-property-types (get-in property [:block/schema :type]))
+                                                      (map #(:block/uuid (db/entity (second %))) values)
+                                                      (map second values))
                                                     (remove string/blank?)
                                                     (remove (set (get-in property [:block/schema :values])))
                                                     distinct)]