瀏覽代碼

:art: fix https://github.com/siyuan-note/siyuan/issues/10729

Vanessa 1 年之前
父節點
當前提交
1d176d5a09

+ 1 - 0
app/appearance/langs/en_US.json

@@ -1,4 +1,5 @@
 {
+  "removeCol": "Are you sure you want to delete the ${x} column in the database?",
   "video": "Video",
   "audio": "Audio",
   "updateAll": "Update all",

+ 1 - 0
app/appearance/langs/es_ES.json

@@ -1,4 +1,5 @@
 {
+  "removeCol": "¿Está seguro de que desea eliminar la columna ${x} en la base de datos?",
   "vídeo": "Vídeo",
   "audio": "Audio",
   "updateAll": "Actualizar todo",

+ 1 - 0
app/appearance/langs/fr_FR.json

@@ -1,4 +1,5 @@
 {
+  "removeCol": "Êtes-vous sûr de vouloir supprimer la colonne ${x} de la base de données ?",
   "video": "Vidéo",
   "audio": "Audio",
   "updateAll": "Tout mettre à jour",

+ 1 - 0
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,5 @@
 {
+  "removeCol": "確定刪除資料庫中的 ${x} 欄位?",
   "video": "影片",
   "audio": "音訊",
   "updateAll": "全部更新",

+ 1 - 0
app/appearance/langs/zh_CN.json

@@ -1,4 +1,5 @@
 {
+  "removeCol": "确定删除数据库中的 ${x} 列?",
   "video": "视频",
   "audio": "音频",
   "updateAll": "全部更新",

+ 5 - 1
app/src/dialog/confirmDialog.ts

@@ -1,7 +1,11 @@
 import {isMobile} from "../util/functions";
 import {Dialog} from "./index";
 
-export const confirmDialog = (title: string, text: string, confirm?: (dialog:Dialog) => void, cancel?: (dialog:Dialog) => void) => {
+export const confirmDialog = (title: string, text: string, confirm?: (dialog?: Dialog) => void, cancel?: (dialog: Dialog) => void) => {
+    if (!text && !title) {
+        confirm();
+        return;
+    }
     const dialog = new Dialog({
         title,
         content: `<div class="b3-dialog__content">

+ 35 - 32
app/src/protyle/render/av/openMenuPanel.ts

@@ -31,6 +31,7 @@ import {bindRollupData, getRollupHTML, goSearchRollupCol} from "./rollup";
 import {updateCellsValue} from "./cell";
 import {openCalcMenu} from "./calc";
 import * as dayjs from "dayjs";
+import {confirmDialog} from "../../../dialog/confirmDialog";
 
 export const openMenuPanel = (options: {
     protyle: IProtyle,
@@ -1025,38 +1026,40 @@ export const openMenuPanel = (options: {
                     event.stopPropagation();
                     break;
                 } else if (type === "removeCol") {
-                    const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
-                    let previousID: string;
-                    const colData = data.view.columns.find((item: IAVColumn, index) => {
-                        if (item.id === colId) {
-                            previousID = data.view.columns[index - 1]?.id;
-                            return true;
-                        }
-                    });
-                    const newUpdated = dayjs().format("YYYYMMDDHHmmss");
-                    transaction(options.protyle, [{
-                        action: "removeAttrViewCol",
-                        id: colId,
-                        avID,
-                    }, {
-                        action: "doUpdateUpdated",
-                        id: blockID,
-                        data: newUpdated,
-                    }], [{
-                        action: "addAttrViewCol",
-                        name: colData.name,
-                        avID,
-                        type: colData.type,
-                        id: colId,
-                        previousID
-                    }, {
-                        action: "doUpdateUpdated",
-                        id: blockID,
-                        data: options.blockElement.getAttribute("updated")
-                    }]);
-                    removeAttrViewColAnimation(options.blockElement, colId);
-                    options.blockElement.setAttribute("updated", newUpdated);
-                    avPanelElement.remove();
+                    confirmDialog(isCustomAttr ? window.siyuan.languages.deleteOpConfirm : "", isCustomAttr ? window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value) : "", () => {
+                        const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
+                        let previousID: string;
+                        const colData = data.view.columns.find((item: IAVColumn, index) => {
+                            if (item.id === colId) {
+                                previousID = data.view.columns[index - 1]?.id;
+                                return true;
+                            }
+                        });
+                        const newUpdated = dayjs().format("YYYYMMDDHHmmss");
+                        transaction(options.protyle, [{
+                            action: "removeAttrViewCol",
+                            id: colId,
+                            avID,
+                        }, {
+                            action: "doUpdateUpdated",
+                            id: blockID,
+                            data: newUpdated,
+                        }], [{
+                            action: "addAttrViewCol",
+                            name: colData.name,
+                            avID,
+                            type: colData.type,
+                            id: colId,
+                            previousID
+                        }, {
+                            action: "doUpdateUpdated",
+                            id: blockID,
+                            data: options.blockElement.getAttribute("updated")
+                        }]);
+                        removeAttrViewColAnimation(options.blockElement, colId);
+                        options.blockElement.setAttribute("updated", newUpdated);
+                        avPanelElement.remove();
+                    })
                     event.preventDefault();
                     event.stopPropagation();
                     break;