|
|
@@ -139,39 +139,44 @@
|
|
|
:value type})))]
|
|
|
[:div {:class (if in-block-container? "flex flex-1" "flex items-center col-span-2")}
|
|
|
(shui/select
|
|
|
- {:default-open (boolean default-open?)
|
|
|
- :disabled disabled?
|
|
|
- :on-value-change
|
|
|
- (fn [v]
|
|
|
- (let [type (keyword (string/lower-case v))
|
|
|
- update-schema-fn (apply comp
|
|
|
- #(assoc % :type type)
|
|
|
+ (cond->
|
|
|
+ {:default-open (boolean default-open?)
|
|
|
+ :disabled disabled?
|
|
|
+ :on-value-change
|
|
|
+ (fn [v]
|
|
|
+ (let [type (keyword (string/lower-case v))
|
|
|
+ update-schema-fn (apply comp
|
|
|
+ #(assoc % :type type)
|
|
|
;; always delete previous closed values as they
|
|
|
;; are not valid for the new type
|
|
|
- #(dissoc % :values)
|
|
|
- (keep
|
|
|
- (fn [attr]
|
|
|
- (when-not (db-property-type/property-type-allows-schema-attribute? type attr)
|
|
|
- #(dissoc % attr)))
|
|
|
- [:cardinality :classes :position]))]
|
|
|
- (when *property-schema
|
|
|
- (swap! *property-schema update-schema-fn))
|
|
|
- (let [schema (or (and *property-schema @*property-schema)
|
|
|
- (update-schema-fn property-schema))
|
|
|
- repo (state/get-current-repo)]
|
|
|
- (p/do!
|
|
|
- (when block
|
|
|
- (pv/exit-edit-property))
|
|
|
- (when *show-new-property-config?
|
|
|
- (reset! *show-new-property-config? false))
|
|
|
- (components-pu/update-property! property property-name schema)
|
|
|
- (when block
|
|
|
- (let [id (str "ls-property-" (:db/id block) "-" (:db/id property) "-editor")]
|
|
|
- (state/set-state! :editor/editing-property-value-id
|
|
|
- {id true}))
|
|
|
- (property-handler/set-block-property! repo (:block/uuid block)
|
|
|
- (:db/ident (db/entity [:block/original-name property-name]))
|
|
|
- (if (= type :default) "" :logseq.property/empty-placeholder)))))))}
|
|
|
+ #(dissoc % :values)
|
|
|
+ (keep
|
|
|
+ (fn [attr]
|
|
|
+ (when-not (db-property-type/property-type-allows-schema-attribute? type attr)
|
|
|
+ #(dissoc % attr)))
|
|
|
+ [:cardinality :classes :position]))]
|
|
|
+ (when *property-schema
|
|
|
+ (swap! *property-schema update-schema-fn))
|
|
|
+ (let [schema (or (and *property-schema @*property-schema)
|
|
|
+ (update-schema-fn property-schema))
|
|
|
+ repo (state/get-current-repo)]
|
|
|
+ (p/do!
|
|
|
+ (when block
|
|
|
+ (pv/exit-edit-property))
|
|
|
+ (when *show-new-property-config?
|
|
|
+ (reset! *show-new-property-config? false))
|
|
|
+ (components-pu/update-property! property property-name schema)
|
|
|
+ (when block
|
|
|
+ (let [id (str "ls-property-" (:db/id block) "-" (:db/id property) "-editor")]
|
|
|
+ (state/set-state! :editor/editing-property-value-id
|
|
|
+ {id true}))
|
|
|
+ (property-handler/set-block-property! repo (:block/uuid block)
|
|
|
+ (:db/ident (db/entity [:block/original-name property-name]))
|
|
|
+ (if (= type :default) "" :logseq.property/empty-placeholder)))))))}
|
|
|
+
|
|
|
+ ;; only set when in property configure modal
|
|
|
+ (and *property-name (:type property-schema))
|
|
|
+ (assoc :default-value (name (:type property-schema))))
|
|
|
(shui/select-trigger
|
|
|
{:class "!px-2 !py-0 !h-8"}
|
|
|
(shui/select-value
|