🎨 rollup attr

This commit is contained in:
Vanessa 2024-01-01 22:33:27 +08:00
parent 9952f76783
commit 31c2b02bb3
2 changed files with 44 additions and 3 deletions

View file

@ -4,6 +4,42 @@ import {escapeAttr} from "../../../util/escape";
import * as dayjs from "dayjs";
import {popTextCell} from "./cell";
const genAVRollupHTML = (value: IAVCellValue) => {
let html = "";
switch (value.type) {
case "block":
html = value.block.content;
break;
case "text":
html = value.text.content;
break;
case "number":
html = value.number.formattedContent || value.number.content.toString();
break;
case "date":
if (value[value.type] && value[value.type].isNotEmpty) {
html = dayjs(value[value.type].content).format(value[value.type].isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
}
if (value[value.type] && value[value.type].hasEndDate && value[value.type].isNotEmpty && value[value.type].isNotEmpty2) {
html += `<svg class="av__cellicon"><use xlink:href="#iconForward"></use></svg>${dayjs(value[value.type].content2).format(value[value.type].isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm")}`;
}
if (html) {
html = `<span class="av__celltext">${html}</span>`;
}
break;
case "url":
html = value.url.content ? `<a class="fn__a" href="${value.url.content}" target="_blank">${value.url.content}</a>` : "";
break;
case "phone":
html = value.phone.content ? `<a class="fn__a" href="tel:${value.phone.content}" target="_blank">${value.phone.content}</a>` : "";
break;
case "email":
html = value.email.content ? `<a class="fn__a" href="mailto:${value.email.content}" target="_blank">${value.email.content}</a>` : "";
break;
}
return html;
};
export const genAVValueHTML = (value: IAVCellValue) => {
let html = "";
switch (value.type) {
@ -74,8 +110,13 @@ export const genAVValueHTML = (value: IAVCellValue) => {
});
break;
case "rollup":
value.rollup?.contents.forEach((item) => {
html += `<span class="av__celltext--url" style="margin-right: 8px">${item}</span>`;
value?.rollup?.contents?.forEach((item, index) => {
const rollupText = ["select", "mSelect", "mAsset", "checkbox", "relation"].includes(item.type) ? genAVValueHTML(item) : genAVRollupHTML(item);
if (!rollupText && html) {
html = html.substring(0, html.length - 2);
} else {
html += rollupText + ((index === value.rollup.contents.length - 1 || !rollupText) ? "" : ",&nbsp;");
}
});
break;
}

View file

@ -175,7 +175,7 @@ export const getRollupHTML = (options: { data?: IAV, cellElements?: HTMLElement[
</button>`
}
export const bindRollupEvent = (options: {
export const bindRollupEvent = (options: {
protyle: IProtyle,
data: IAV,
menuElement: HTMLElement