enhance(ux): polish dropdown property editor

pull/11483/head^2
charlie 2024-08-24 11:37:31 +08:00
parent b344e2c152
commit 9a1e6890d8
1 changed files with 7 additions and 5 deletions

View File

@ -289,7 +289,8 @@
property: block entity" property: block entity"
[_popup-id property opts] [_popup-id property opts]
(let [title (:block/title property) (let [title (:block/title property)
property-type (get-in property [:block/schema :type]) property-schema (:block/schema property)
property-type (get property-schema :type)
property-type-label' (some-> property-type (property-type-label)) property-type-label' (some-> property-type (property-type-label))
enable-closed-values? (contains? db-property-type/closed-value-property-types enable-closed-values? (contains? db-property-type/closed-value-property-types
(or property-type :default)) (or property-type :default))
@ -313,14 +314,15 @@
(dropdown-editor-menuitem {:icon :checks :title "Multiple values" (dropdown-editor-menuitem {:icon :checks :title "Multiple values"
:toggle-checked? many? :disabled? disabled? :toggle-checked? many? :disabled? disabled?
:on-toggle-checked-change #(db-property-handler/upsert-property! (:db/ident property) :on-toggle-checked-change #(db-property-handler/upsert-property! (:db/ident property)
(assoc (:block/schema property) :cardinality (if many? :one :many)) {})})) (assoc property-schema :cardinality (if many? :one :many)) {})}))
(shui/dropdown-menu-separator) (shui/dropdown-menu-separator)
(dropdown-editor-menuitem {:icon :float-left :title "UI position" :desc "beginning of the block" (dropdown-editor-menuitem {:icon :float-left :title "UI position" :desc "beginning of the block"
:item-props {:class "ui__position-trigger-item"} :item-props {:class "ui__position-trigger-item"}
:submenu-content (fn [ops] (ui-position-sub-pane property ops))}) :submenu-content (fn [ops] (ui-position-sub-pane property ops))})
(dropdown-editor-menuitem {:icon :eye-off :title "Hide by default" :toggle-checked? false (dropdown-editor-menuitem {:icon :eye-off :title "Hide by default" :toggle-checked? (boolean (:hide? property-schema))
:on-toggle-checked-change (fn [v] (shui/toast! (str title ": " v)))}) :on-toggle-checked-change #(db-property-handler/upsert-property! (:db/ident property)
(assoc property-schema :hide? %) {})})
(shui/dropdown-menu-separator) (shui/dropdown-menu-separator)
(dropdown-editor-menuitem (dropdown-editor-menuitem
@ -331,7 +333,7 @@
(route-handler/redirect-to-page! (:block/uuid property)))}}) (route-handler/redirect-to-page! (:block/uuid property)))}})
(dropdown-editor-menuitem (dropdown-editor-menuitem
{:id :remove-property :icon :square-x :title "Remove property" :desc "" :disabled? false {:id :remove-property :icon :square-x :title "Remove property" :desc "" :disabled? false
:item-props {:class "opacity-60 focus:opacity-100 focus:!text-red-rx-08" :item-props {:class "opacity-60 focus:opacity-100 focus:!text-red-rx-09"
:on-select (fn [^js e] :on-select (fn [^js e]
(util/stop e) (util/stop e)
(-> (shui/dialog-confirm! "remove?") (-> (shui/dialog-confirm! "remove?")