Vanessa 2024-03-25 11:15:00 +08:00
parent a3e3a0aeed
commit 1d176d5a09
7 changed files with 45 additions and 33 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,11 @@
import {isMobile} from "../util/functions"; import {isMobile} from "../util/functions";
import {Dialog} from "./index"; 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({ const dialog = new Dialog({
title, title,
content: `<div class="b3-dialog__content"> content: `<div class="b3-dialog__content">

View file

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