diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index fb1b71e22..e6e4f0054 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -276,6 +276,8 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
updateCellValueByInput(protyle, type, cellElements);
} else if (type === "relation") {
openMenuPanel({protyle, blockElement, type: "relation", cellElements});
+ } else if (type === "rollup") {
+ openMenuPanel({protyle, blockElement, type: "rollup", cellElements, colId: cellElements[0].dataset.colId});
}
if (!hasClosestByClassName(cellElements[0], "custom-attr")) {
cellElements[0].classList.add("av__cell--select");
@@ -644,8 +646,8 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
} else if (cellValue.type === "checkbox") {
text += ``;
} else if (cellValue.type === "rollup") {
- cellValue?.rollup?.contents?.forEach((item) => {
- text += renderCell(item, wrap);
+ cellValue?.rollup?.contents?.forEach((item, index) => {
+ text += renderRollup(item, wrap) + (index === cellValue.rollup.contents.length - 1 ? "" : " ,");
});
} else if (cellValue.type === "relation") {
cellValue?.relation?.contents?.forEach((item, index) => {
@@ -659,6 +661,71 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
return text;
};
+const renderRollup = (cellValue: IAVCellValue, wrap: boolean) => {
+ let text = ""
+ if (["text", "template"].includes(cellValue.type)) {
+ text = `${cellValue ? (cellValue[cellValue.type as "text"].content || "") : ""}`;
+ } else if (["url", "email", "phone"].includes(cellValue.type)) {
+ const urlContent = cellValue ? cellValue[cellValue.type as "url"].content : "";
+ // https://github.com/siyuan-note/siyuan/issues/9291
+ let urlAttr = "";
+ if (cellValue.type === "url") {
+ urlAttr = ` data-href="${urlContent}"`;
+ }
+ text = `${urlContent}`;
+ } else if (cellValue.type === "block") {
+ if (cellValue?.isDetached) {
+ text = `${cellValue.block.content || ""}
+${window.siyuan.languages.more}`;
+ } else {
+ text = `${cellValue.block.content || ""}
+${window.siyuan.languages.update}`;
+ }
+ } else if (cellValue.type === "number") {
+ text = `${cellValue?.number.formattedContent || cellValue?.number.content || ""}`;
+ } 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 += "";
+ } else if (["created", "updated"].includes(cellValue.type)) {
+ const dataValue = cellValue ? cellValue[cellValue.type as "date"] : null;
+ text = ``;
+ if (dataValue && dataValue.isNotEmpty) {
+ text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm");
+ }
+ text += "";
+ } else if (cellValue.type === "mAsset") {
+ cellValue?.mAsset?.forEach((item) => {
+ if (item.type === "image") {
+ text += ``;
+ } else {
+ text += `${item.name}`;
+ }
+ });
+ } else if (cellValue.type === "checkbox") {
+ text += ``;
+ } else if (cellValue.type === "rollup") {
+ cellValue?.rollup?.contents?.forEach((item) => {
+ text += renderCell(item, wrap) + '';
+ });
+ } else if (cellValue.type === "relation") {
+ cellValue?.relation?.contents?.forEach((item, index) => {
+ text += `${item}`;
+ });
+ }
+ return text;
+}
+
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
icon?: string,
name?: string,
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 028324cf8..85abf8104 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -9,7 +9,7 @@ import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action"
import {openEmojiPanel, unicode2Emoji} from "../../../emoji";
import {focusBlock} from "../../util/selection";
import {toggleUpdateRelationBtn} from "./relation";
-import {getNameByOperator} from "./calc";
+import {bindRollupEvent, getRollupHTML} from "./rollup";
export const duplicateCol = (options: {
protyle: IProtyle,
@@ -160,21 +160,7 @@ export const getEditHTML = (options: {
`;
} else if (colData.type === "rollup") {
- html += `
-
-`;
+ html += getRollupHTML({colData});
}
return `