Vanessa 2023-07-13 23:16:07 +08:00
parent 7822e66ce4
commit 2ee0155ee0
5 changed files with 29 additions and 7 deletions

View file

@ -114,6 +114,10 @@
&__celltext {
flex: 1;
overflow: hidden;
.b3-chip {
margin: 2px;
}
}
&__firstcol {

View file

@ -12,7 +12,7 @@ export const popTextCell = (protyle: IProtyle, cellElement: HTMLElement) => {
html = `<textarea ${style} class="b3-text-field">${cellElement.textContent}</textarea>`;
} else if (type === "number") {
html = `<input type="number" value="${cellElement.textContent}" ${style} class="b3-text-field">`;
} else if (type === "select" && blockElement) {
} else if (["select", "mSelect"].includes(type) && blockElement) {
openMenuPanel(protyle, blockElement, "select", {cellElement});
return;
}

View file

@ -187,7 +187,7 @@ export const setFilter = (options: {
label: `<select style="margin: 4px 0" class="b3-select fn__size200">${selectHTML}</select>`
});
if (options.filter.value.type === "select" || options.filter.value.type === "mSelect") {
colData.options.forEach((option) => {
colData.options?.forEach((option) => {
let icon = "iconUncheck"
options.filter.value.mSelect.find((optionItem) => {
if (optionItem.content === option.name) {

View file

@ -63,10 +63,12 @@ ${column.wrap ? "" : "white-space: nowrap;"}">
text = `<span class="av__celltext">${cell.value?.number.content || ""}</span>`;
} else if (cell.valueType === "mSelect" || cell.valueType === "select") {
cell.value?.mSelect?.forEach((item: { content: string, color: string }) => {
text += `<span class="av__celltext"><span class="b3-chip b3-chip--middle" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}</span></span>`;
text += `<span class="b3-chip b3-chip--middle" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}</span>`;
});
if (!text) {
text = '<span class="av__celltext"></span>';
} else {
text = `<span class="av__celltext">${text}</span>`;
}
} else if (cell.valueType === "date") {
text = `<span class="av__celltext">${cell.value?.date.content || ""}</span>`;

View file

@ -118,7 +118,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAV, options: {
transaction(protyle, [{
action: "updateAttrViewColOption",
id: colId,
parentID: data.id,
avID: data.id,
data: {
newColor: color,
oldName: name,
@ -127,7 +127,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAV, options: {
}], [{
action: "updateAttrViewColOption",
id: colId,
parentID: data.id,
avID: data.id,
data: {
newColor: color,
oldName: inputElement.value,
@ -238,7 +238,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAV, options: {
transaction(protyle, [{
action: "updateAttrViewColOption",
id: colId,
parentID: data.id,
avID: data.id,
data: {
oldName: name,
newName: inputElement.value,
@ -248,7 +248,7 @@ export const setSelectCol = (protyle: IProtyle, data: IAV, options: {
}], [{
action: "updateAttrViewColOption",
id: colId,
parentID: data.id,
avID: data.id,
data: {
oldName: inputElement.value,
newName: name,
@ -389,6 +389,18 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
value: genCellValue(colData.type, ""),
valueType: colData.type
}
} else {
let hasSelected = false
cellData.value.mSelect.find((item) => {
if (item.content === currentElement.dataset.name) {
hasSelected = true
return true;
}
})
if (hasSelected) {
menuElement.querySelector("input").focus();
return;
}
}
const oldValue = Object.assign([], cellData.value.mSelect);
@ -448,6 +460,10 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
}
if (colData.type === "select") {
menuElement.parentElement.remove();
} else {
menuElement.innerHTML = getSelectHTML(data.view, options);
bindSelectEvent(protyle, data, menuElement, options);
menuElement.querySelector("input").focus();
}
};