Browse Source

:art: 数据库列修改名字后点击编辑,需要更新名字

Vanessa 1 năm trước cách đây
mục cha
commit
23fd11ae12
2 tập tin đã thay đổi với 18 bổ sung3 xóa
  1. 14 2
      app/src/protyle/render/av/col.ts
  2. 4 1
      app/src/protyle/render/av/rollup.ts

+ 14 - 2
app/src/protyle/render/av/col.ts

@@ -472,7 +472,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
     const avID = blockElement.getAttribute("data-av-id");
     const oldValue = cellElement.querySelector(".av__celltext").textContent.trim();
     const menu = new Menu("av-header-cell", () => {
-        const newValue = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
+        const newValue = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
         if (newValue === oldValue) {
             return;
         }
@@ -542,7 +542,19 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
             icon: "iconEdit",
             label: window.siyuan.languages.edit,
             click() {
-                openMenuPanel({protyle, blockElement, type: "edit", colId});
+                const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value
+                openMenuPanel({
+                    protyle,
+                    blockElement,
+                    type: "edit",
+                    colId,
+                    cb(avElement) {
+                        // 修改名字后点击编辑,需要更新名字
+                        const editNameElement = avElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
+                        editNameElement.value = colName;
+                        editNameElement.select();
+                    }
+                });
             }
         });
     }

+ 4 - 1
app/src/protyle/render/av/rollup.ts

@@ -9,6 +9,9 @@ import {unicode2Emoji} from "../../../emoji";
 import {getColIconByType} from "./col";
 
 const updateCol = (protyle: IProtyle, data: IAV, colId: string, itemElement: HTMLElement) => {
+    if (itemElement.classList.contains("b3-list--empty")) {
+        return
+    }
     const colData = data.view.columns.find((item) => {
         if (item.id === colId) {
             return true;
@@ -44,7 +47,7 @@ const genSearchList = (element: Element, keyword: string, avId: string, cb?: ()
         <span class="b3-list-item__text">${escapeHtml(item.name || window.siyuan.languages.title)}</span>
 </div>`;
         });
-        element.innerHTML = html;
+        element.innerHTML = html || `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`;
         if (cb) {
             cb();
         }