mirror of https://github.com/logseq/logseq
enhance: Improve ux of irreversible cardinality change
Users shouldn't be surprised by irreversible changes that can affect large parts of their data. Also fixed inconsistent language i.e. we use delete in dialogspull/11491/head^2
parent
3bc6a27173
commit
0510788aa1
|
@ -522,8 +522,16 @@
|
||||||
(dropdown-editor-menuitem {:icon :checks :title "Multiple values"
|
(dropdown-editor-menuitem {:icon :checks :title "Multiple values"
|
||||||
:toggle-checked? many?
|
:toggle-checked? many?
|
||||||
:disabled? (or disabled? (not (contains? db-property-type/cardinality-property-types property-type)))
|
:disabled? (or disabled? (not (contains? db-property-type/cardinality-property-types property-type)))
|
||||||
:on-toggle-checked-change #(db-property-handler/upsert-property! (:db/ident property)
|
:on-toggle-checked-change
|
||||||
(assoc property-schema :cardinality (if many? :one :many)) {})}))
|
(fn []
|
||||||
|
(let [update-cardinality-fn #(db-property-handler/upsert-property! (:db/ident property)
|
||||||
|
(assoc property-schema :cardinality (if many? :one :many)) {})]
|
||||||
|
;; Only show dialog for existing values as it can be reversed for unused properties
|
||||||
|
(if (seq values)
|
||||||
|
(-> (shui/dialog-confirm!
|
||||||
|
"This action cannot be undone. Do you want to change this property to have multiple values?")
|
||||||
|
(p/then update-cardinality-fn))
|
||||||
|
(update-cardinality-fn))))}))
|
||||||
|
|
||||||
(shui/dropdown-menu-separator)
|
(shui/dropdown-menu-separator)
|
||||||
(let [position (:position property-schema)]
|
(let [position (:position property-schema)]
|
||||||
|
@ -548,14 +556,14 @@
|
||||||
|
|
||||||
(when owner-block
|
(when owner-block
|
||||||
(dropdown-editor-menuitem
|
(dropdown-editor-menuitem
|
||||||
{:id :remove-property :icon :x :title "Remove property" :desc "" :disabled? false
|
{:id :delete-property :icon :x :title "Delete property" :desc "" :disabled? false
|
||||||
:item-props {:class "opacity-60 focus:!text-red-rx-09 focus:opacity-100"
|
:item-props {:class "opacity-60 focus:!text-red-rx-09 focus:opacity-100"
|
||||||
:on-select (fn [^js e]
|
:on-select (fn [^js e]
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(-> (p/do!
|
(-> (p/do!
|
||||||
(handle-delete-property! owner-block property {:class-schema? class-schema?})
|
(handle-delete-property! owner-block property {:class-schema? class-schema?})
|
||||||
(shui/popup-hide-all!))
|
(shui/popup-hide-all!))
|
||||||
(p/catch (fn [] (restore-root-highlight-item! :remove-property)))))}}))
|
(p/catch (fn [] (restore-root-highlight-item! :delete-property)))))}}))
|
||||||
(when debug?
|
(when debug?
|
||||||
[:<>
|
[:<>
|
||||||
(shui/dropdown-menu-separator)
|
(shui/dropdown-menu-separator)
|
||||||
|
|
Loading…
Reference in New Issue