From a779a14c7300a5954462fee03a793f75e7f0a998 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 1 Jan 2024 17:44:30 +0800 Subject: [PATCH] :art: rollup render --- app/src/protyle/render/av/cell.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 1a7e619ac..1e2f05170 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -647,7 +647,12 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => { text += ``; } else if (cellValue.type === "rollup") { cellValue?.rollup?.contents?.forEach((item, index) => { - text += renderRollup(item, wrap) + (index === cellValue.rollup.contents.length - 1 ? "" : " ,"); + const rollupText = renderRollup(item, wrap); + if (!rollupText && text) { + text = text.substring(0, text.length - 2); + } else { + text += rollupText + ((index === cellValue.rollup.contents.length - 1 || !rollupText) ? "" : ", "); + } }); } else if (cellValue.type === "relation") { cellValue?.relation?.contents?.forEach((item, index) => { @@ -675,26 +680,27 @@ const renderRollup = (cellValue: IAVCellValue, wrap: boolean) => { text = `${urlContent}`; } else if (cellValue.type === "block") { if (cellValue?.isDetached) { - text = `${cellValue.block.content || ""}`; + text = `${cellValue.block?.content || ""}`; } else { - text = `${cellValue.block.content || ""}`; + text = `${cellValue.block?.content || ""}`; } } else if (cellValue.type === "number") { - text = `${cellValue?.number.formattedContent || cellValue?.number.content || ""}`; + text = cellValue?.number.formattedContent || cellValue?.number.content.toString() || ""; } else if (cellValue.type === "mSelect" || cellValue.type === "select") { cellValue?.mSelect?.forEach((item) => { text += `${item.content}`; }); } else if (cellValue.type === "date") { const dataValue = cellValue ? cellValue.date : null; - text = ``; if (dataValue && dataValue.isNotEmpty) { text += dayjs(dataValue.content).format(dataValue.isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm"); } if (dataValue && dataValue.hasEndDate && dataValue.isNotEmpty && dataValue.isNotEmpty2) { text += `${dayjs(dataValue.content2).format(dataValue.isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm")}`; } - text += ""; + if (text) { + text = `${text}`; + } } else if (["created", "updated"].includes(cellValue.type)) { const dataValue = cellValue ? cellValue[cellValue.type as "date"] : null; text = ``;