浏览代码

fix: regression on deleting property from class

Gabriel Horner 1 年之前
父节点
当前提交
dd224b32c5
共有 2 个文件被更改,包括 18 次插入16 次删除
  1. 3 2
      src/main/frontend/components/property.cljs
  2. 15 14
      src/main/frontend/components/property/config.cljs

+ 3 - 2
src/main/frontend/components/property.cljs

@@ -305,7 +305,7 @@
 
 (rum/defcs property-key-cp <
   (rum/local false ::hover?)
-  [state block property {:keys [other-position?]}]
+  [state block property {:keys [other-position? class-schema?]}]
   (let [*hover? (::hover? state)
         icon (:logseq.property/icon property)]
     [:div.flex.flex-row.items-center.gap-1
@@ -352,7 +352,8 @@
                          :on-click (fn [^js/MouseEvent e]
                                      (shui/popup-show! (.-target e)
                                                        (fn []
-                                                         (property-config/dropdown-editor property block {:debug? (.-altKey e)}))
+                                                         (property-config/dropdown-editor property block {:debug? (.-altKey e)
+                                                                                                          :class-schema? class-schema?}))
                                                        {:content-props
                                                         {:class "ls-property-dropdown-editor as-root"}
                                                         :align "start"

+ 15 - 14
src/main/frontend/components/property/config.cljs

@@ -354,14 +354,19 @@
                      (property-handler/remove-block-property! repo (:block/uuid block) (:db/ident property))))]
     (if (and class? class-schema?)
       (-> (shui/dialog-confirm!
-            ;; Only ask for confirmation on class schema properties
-            [:p (str "Are you sure you want to delete this property?")])
-        (p/then remove!))
-      (remove!))))
+           [:p (str "Are you sure you want to delete this property?")]
+           {:id :delete-property-from-class
+            :data-reminder :ok})
+          (p/then remove!))
+      (-> (shui/dialog-confirm!
+           "Are you sure you want to delete the property from this node?"
+           {:id :delete-property-from-node
+            :data-reminder :ok})
+          (p/then remove!)))))
 
 (rum/defc dropdown-editor-impl
   "property: block entity"
-  [property owner-block opts]
+  [property owner-block {:keys [class-schema? debug?]}]
   (let [title (:block/title property)
         property-schema (:block/schema property)
         property-type (get property-schema :type)
@@ -413,19 +418,15 @@
 
      (when owner-block
        (dropdown-editor-menuitem
-        {:id :remove-property :icon :square-x :title "Remove property" :desc "" :disabled? false
+        {:id :remove-property :icon :square-x :title "Delete property" :desc "" :disabled? false
          :item-props {:class "opacity-60 focus:opacity-100 focus:!text-red-rx-09"
                       :on-select (fn [^js e]
                                    (util/stop e)
-                                   (-> (shui/dialog-confirm!
-                                        "Are you sure you want to delete property from this node?"
-                                        {:id :delete-property-from-node
-                                         :data-reminder :ok})
-                                       (p/then (fn []
-                                                 (handle-delete-property! owner-block property {:class-schema? false})
-                                                 (shui/popup-hide-all!)))
+                                   (-> (p/do!
+                                        (handle-delete-property! owner-block property {:class-schema? class-schema?})
+                                        (shui/popup-hide-all!))
                                        (p/catch (fn [] (restore-root-highlight-item! :remove-property)))))}}))
-     (when (:debug? opts)
+     (when debug?
        [:<>
         (shui/dropdown-menu-separator)
         (dropdown-editor-menuitem