From cfe8d809b82983ecfce27e0048a6d3b3472d54ca Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Thu, 30 Nov 2023 16:47:02 -0500 Subject: [PATCH] fix: changing property shouldn't lead to invalid closed values To reproduce, create a :default property with two closed values. Change to url type, the previous closed values would stay on and would be invalid when selected. Also added a tippy so users are aware that changing types can alter their existing config --- src/main/frontend/components/property.cljs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 4b6b3b2984..3aab28a29e 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -185,19 +185,27 @@ :interactive true :disabled false} (svg/help-circle))] - [:div.col-span-2 + [:div.flex.items-center.col-span-2 (ui/select schema-types (fn [_e 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))) - [:values :position :cardinality :classes]))] + #(dissoc % attr))) + [:cardinality :classes :position]))] (swap! *property-schema update-schema-fn) - (components-pu/update-property! property @*property-name @*property-schema))))]))] + (components-pu/update-property! property @*property-name @*property-schema)))) + (ui/tippy {:html "Changing the property type clears some property configurations." + :class "tippy-hover ml-2" + :interactive true + :disabled false} + (svg/info))]))] (when (db-property-type/property-type-allows-schema-attribute? (:type @*property-schema) :cardinality) [:div.grid.grid-cols-4.gap-1.items-center.leading-8