Vanessa 2024-01-02 22:53:24 +08:00
parent 491fa58d99
commit d9bfc45592

View file

@ -427,7 +427,18 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
const nodeElement = hasClosestBlock(cellElements[0]);
if (!nodeElement) {
cellElements.forEach((item, index) => {
cellElements[index] = blockElement.querySelector(`.av__cell[data-id="${item.dataset.id}"]`) as HTMLElement;
const rowElement = hasClosestByClassName(item, "av__row");
if (rowElement) {
let cellIndex: number;
rowElement.querySelectorAll(".av__cell").forEach((cellElement: HTMLElement, ghostIndex) => {
if (cellElement.dataset.id === item.dataset.id) {
cellIndex = ghostIndex
}
});
if (typeof cellIndex === "number") {
cellElements[index] = blockElement.querySelectorAll(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell`)[cellIndex] as HTMLElement;
}
}
});
}
const colId = cellElements[0].dataset.colId;
@ -545,25 +556,9 @@ export const getSelectHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
}
});
let allUniqueOptions: IAVCellSelectValue[] = [];
data.rows.find(row => {
const rowElement = hasClosestByClassName(cellElements[0], "av__row");
if (rowElement && rowElement.dataset.id === row.id) {
row.cells.find(cell => {
if (cell.id === cellElements[0].dataset.id) {
if (cell.value && cell.value.mSelect) {
allUniqueOptions = cell.value.mSelect;
}
return true;
}
});
return true;
}
});
let selectedHTML = "";
allUniqueOptions.forEach((unique) => {
selectedHTML += `<div class="b3-chip b3-chip--middle" data-content="${escapeAttr(unique.content)}" style="background-color:var(--b3-font-background${unique.color});color:var(--b3-font-color${unique.color})">${unique.content}<svg class="b3-chip__close" data-type="removeCellOption"><use xlink:href="#iconCloseRound"></use></svg></div>`;
genCellValueByElement(colData.type, cellElements[0]).mSelect?.forEach((item) => {
selectedHTML += `<div class="b3-chip b3-chip--middle" data-content="${escapeAttr(item.content)}" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}<svg class="b3-chip__close" data-type="removeCellOption"><use xlink:href="#iconCloseRound"></use></svg></div>`;
});
return `<div class="b3-menu__items">