Vanessa 2024-05-17 18:02:15 +08:00
parent 9f792df41e
commit 1c45347de5
2 changed files with 11 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import {genAVValueHTML} from "./blockAttr";
import {Constants} from "../../../constants";
import {hintRef} from "../../hint/extend";
import {pathPosix} from "../../../util/pathName";
import {mergeAddOption} from "./select";
const renderCellURL = (urlContent: string) => {
let host = urlContent;
@ -587,6 +588,11 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
(cellValue.type === "relation" && typeof cellValue.relation === "string")) {
return;
}
if (type === "select" || type === "mSelect") {
const operations = mergeAddOption(columns.find(e => e.id === colId), cellValue, avID);
doOperations.push(...operations.doOperations);
undoOperations.push(...operations.undoOperations);
}
if (objEquals(cellValue, oldValue)) {
return;
}

View file

@ -566,7 +566,7 @@ export const getSelectHTML = (data: IAVTable, cellElements: HTMLElement[], init
</div>`;
};
export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:string) => {
export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID: string) => {
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
cellValue.mSelect.forEach((item: IAVCellSelectValue) => {
@ -580,15 +580,17 @@ export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:
}
});
if (!needAdd) {
const newColor = ((column.options?.length || 0) % 13 + 1).toString()
column.options.push({
name: item.content,
color:(column.options?.length || 0) % 13 + 1
color: newColor
});
item.color = newColor;
doOperations.push({
action: "updateAttrViewColOptions",
id: column.id,
avID,
data: column.options
data: column.options
})
undoOperations.push({
action: "removeAttrViewColOption",