|
@@ -332,8 +332,10 @@
|
|
|
[block property {:keys [multiple-choices? dropdown?] :as opts}]
|
|
[block property {:keys [multiple-choices? dropdown?] :as opts}]
|
|
|
(let [schema (:block/schema property)
|
|
(let [schema (:block/schema property)
|
|
|
type (:type schema)
|
|
type (:type schema)
|
|
|
- items (if (= :enum type)
|
|
|
|
|
- (map (fn [v] {:value v}) (:enum-values schema))
|
|
|
|
|
|
|
+ enum? (= :enum type)
|
|
|
|
|
+ items (if enum?
|
|
|
|
|
+ (map (fn [[id {:keys [name]}]] {:label name
|
|
|
|
|
+ :value id}) (get-in schema [:enum-config :values]))
|
|
|
(->> (model/get-block-property-values (:block/uuid property))
|
|
(->> (model/get-block-property-values (:block/uuid property))
|
|
|
(mapcat (fn [[_id value]]
|
|
(mapcat (fn [[_id value]]
|
|
|
(if (coll? value)
|
|
(if (coll? value)
|
|
@@ -372,6 +374,8 @@
|
|
|
(exit-edit-property)
|
|
(exit-edit-property)
|
|
|
(when-let [f (:on-chosen opts)] (f)))
|
|
(when-let [f (:on-chosen opts)] (f)))
|
|
|
nil))})}
|
|
nil))})}
|
|
|
|
|
+ enum?
|
|
|
|
|
+ (assoc :extract-fn :label)
|
|
|
multiple-choices?
|
|
multiple-choices?
|
|
|
(assoc :on-apply on-chosen)
|
|
(assoc :on-apply on-chosen)
|
|
|
(not multiple-choices?)
|
|
(not multiple-choices?)
|
|
@@ -399,7 +403,7 @@
|
|
|
(properties-cp config entity (:editor-id config) (merge opts {:in-block-container? true}))])))
|
|
(properties-cp config entity (:editor-id config) (merge opts {:in-block-container? true}))])))
|
|
|
|
|
|
|
|
(rum/defc select-item
|
|
(rum/defc select-item
|
|
|
- [type value {:keys [page-cp inline-text]}]
|
|
|
|
|
|
|
+ [property type value {:keys [page-cp inline-text]}]
|
|
|
(case type
|
|
(case type
|
|
|
(:page :date)
|
|
(:page :date)
|
|
|
(when-let [page (db/entity [:block/uuid value])]
|
|
(when-let [page (db/entity [:block/uuid value])]
|
|
@@ -409,6 +413,9 @@
|
|
|
:number
|
|
:number
|
|
|
[:span.number (str value)]
|
|
[:span.number (str value)]
|
|
|
|
|
|
|
|
|
|
+ :enum
|
|
|
|
|
+ (get-in (:block/schema property) [:enum-config :values value :name])
|
|
|
|
|
+
|
|
|
(inline-text {} :markdown (str value))))
|
|
(inline-text {} :markdown (str value))))
|
|
|
|
|
|
|
|
(rum/defc single-value-select
|
|
(rum/defc single-value-select
|
|
@@ -465,7 +472,7 @@
|
|
|
(if (and select-type? (not= type :date))
|
|
(if (and select-type? (not= type :date))
|
|
|
(single-value-select block property value
|
|
(single-value-select block property value
|
|
|
(fn []
|
|
(fn []
|
|
|
- (select-item type value opts))
|
|
|
|
|
|
|
+ (select-item property type value opts))
|
|
|
select-opts
|
|
select-opts
|
|
|
opts)
|
|
opts)
|
|
|
(case type
|
|
(case type
|
|
@@ -541,7 +548,7 @@
|
|
|
(if (seq items)
|
|
(if (seq items)
|
|
|
(concat
|
|
(concat
|
|
|
(for [item items]
|
|
(for [item items]
|
|
|
- (select-item type item opts))
|
|
|
|
|
|
|
+ (select-item property type item opts))
|
|
|
(when date?
|
|
(when date?
|
|
|
[(date-picker block property nil {:toggle-fn toggle-fn})]))
|
|
[(date-picker block property nil {:toggle-fn toggle-fn})]))
|
|
|
(when-not editing? [:div.opacity-50.pointer.text-sm "Empty"])))
|
|
(when-not editing? [:div.opacity-50.pointer.text-sm "Empty"])))
|