Explorar o código

:art: https://github.com/siyuan-note/siyuan/issues/10519

Vanessa hai 1 ano
pai
achega
1e02294797

+ 11 - 1
app/src/protyle/render/av/cell.ts

@@ -193,6 +193,11 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
                 type: colType,
                 relation: {blockIDs: [], contents: []}
             };
+        } else if (colType === "rollup") {
+            cellValue = {
+                type: colType,
+                rollup: {contents: []}
+            };
         }
     }
     if (colType === "block") {
@@ -431,7 +436,8 @@ const updateCellValueByInput = (protyle: IProtyle, type: TAVCol, blockElement: H
             checked: cellElements[0].querySelector("use").getAttribute("xlink:href") === "#iconUncheck"
         } : (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value, cellElements);
     }
-    if (!hasClosestByClassName(cellElements[0], "custom-attr")) {
+    if (cellElements[0] // 兼容新增行后台隐藏
+        && !hasClosestByClassName(cellElements[0], "custom-attr")) {
         cellElements[0].classList.add("av__cell--select");
     }
     //  单元格编辑中 ctrl+p 光标定位
@@ -473,6 +479,10 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
         if (!nodeElement.contains(item)) {
             item = cellElements[elementIndex] = nodeElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${item.dataset.colId}"]`) as HTMLElement;
         }
+        if (!item) {
+            // 兼容新增行后台隐藏
+            return;
+        }
         const type = getTypeByCellElement(item) || item.dataset.type as TAVCol;
         if (["created", "updated", "template", "rollup"].includes(type)) {
             return;

+ 1 - 1
app/src/protyle/render/av/filter.ts

@@ -216,7 +216,7 @@ export const setFilter = async (options: {
         });
         options.data.view.filters.find(item => {
             if (item.column === colData.id && item.value.type === "rollup") {
-                if (!item.value.rollup) {
+                if (!item.value.rollup || !item.value.rollup.contents || item.value.rollup.contents.length === 0) {
                     filterValue = {
                         [filterValue.type]: genCellValue(filterValue.type, filterValue.type === "checkbox" ? {checked: undefined} : ""),
                         type: filterValue.type

+ 1 - 1
app/src/protyle/render/av/row.ts

@@ -93,7 +93,7 @@ const setPage = (blockElement: Element) => {
 export const insertAttrViewBlockAnimation = (protyle: IProtyle, blockElement: Element, srcIDs: string[], previousId: string, avId?: string,) => {
     let previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header");
     // 有排序需要加入最后一行
-    if(blockElement.querySelector('.av__views [data-type="av-sort"]').classList.contains("block__icon--active")) {
+    if (blockElement.querySelector('.av__views [data-type="av-sort"]').classList.contains("block__icon--active")) {
         previousElement = blockElement.querySelector(".av__row--util").previousElementSibling;
         showMessage(window.siyuan.languages.insertRowTip2);
     }