diff --git a/deps/db/src/logseq/db/frontend/property/type.cljs b/deps/db/src/logseq/db/frontend/property/type.cljs index 3d0ba7880..a01282dd0 100644 --- a/deps/db/src/logseq/db/frontend/property/type.cljs +++ b/deps/db/src/logseq/db/frontend/property/type.cljs @@ -94,11 +94,12 @@ ;; FIXME: UI concerns shouldn't be in this layer (number? (some-> (:block/content entity) parse-double)))))) -(defn- property-value-block? - [db s] - (when-let [ent (d/entity db s)] - (and (:block/content ent) - (:logseq.property/created-from-property ent)))) +(defn- text-entity? + [db s {:keys [new-closed-value?]}] + (if new-closed-value? + (string? s) + (when-let [ent (d/entity db s)] + (string? (:block/content ent))))) (defn- page? [db val] @@ -116,7 +117,7 @@ "Map of types to malli validation schemas that validate a property value for that type" {:default [:fn {:error/message "should be a text block"} - property-value-block?] + text-entity?] :string [:fn {:error/message "should be a string"} string-entity?] diff --git a/deps/outliner/src/logseq/outliner/property.cljs b/deps/outliner/src/logseq/outliner/property.cljs index cd738a59a..7679246da 100644 --- a/deps/outliner/src/logseq/outliner/property.cljs +++ b/deps/outliner/src/logseq/outliner/property.cljs @@ -443,15 +443,6 @@ property-type (get property-schema :type :default)] (when (contains? db-property-type/closed-value-property-types property-type) (let [value (if (string? value) (string/trim value) value) - closed-values (:property/closed-values property) - default-closed-values? (and (= :default property-type) (seq closed-values)) - value (if (and default-closed-values? (string? value) (not (string/blank? value))) - (let [result (create-property-text-block! conn nil - (:db/id property) - value - {})] - (:db/id (d/entity @conn [:block/uuid (:block-id result)]))) - value) resolved-value (try (convert-property-input-string (:type property-schema) value) (catch :default e @@ -466,15 +457,16 @@ (some (fn [b] (and (= (str resolved-value) (str (or (db-property/property-value-when-closed b) (:block/uuid b)))) - (not= id (:block/uuid b)))) closed-values) + (not= id (:block/uuid b)))) + (:property/closed-values property)) (do ;; (notification/show! "Choice already exists" :warning) - :value-exists) + (doto :value-exists prn)) validate-message (do ;; (notification/show! validate-message :warning) - :value-invalid) + (doto :value-invalid prn)) (nil? resolved-value) nil @@ -505,8 +497,7 @@ [new-block (outliner-core/block-with-updated-at {:db/id (:db/id property)})]))] - {:block-id block-id - :tx-data tx-data})))))) + (d/transact! conn tx-data {:outliner-op :save-block}))))))) (defn add-existing-values-to-closed-values! "Adds existing values as closed values and returns their new block uuids" diff --git a/src/main/frontend/components/property/closed_value.cljs b/src/main/frontend/components/property/closed_value.cljs index 552ac7508..c36a76ff7 100644 --- a/src/main/frontend/components/property/closed_value.cljs +++ b/src/main/frontend/components/property/closed_value.cljs @@ -30,11 +30,9 @@ (defn-