From 1e022947971f7cda83def24ad6127e5ca122d5e3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 7 Mar 2024 09:15:15 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/10519 --- app/src/protyle/render/av/cell.ts | 12 +++++++++++- app/src/protyle/render/av/filter.ts | 2 +- app/src/protyle/render/av/row.ts | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 868e1af4c..ec531ffe9 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/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; diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts index aa7a4440f..2c75ac88f 100644 --- a/app/src/protyle/render/av/filter.ts +++ b/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 diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts index 30ccac842..9bf841150 100644 --- a/app/src/protyle/render/av/row.ts +++ b/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); }