Vanessa 2024-04-07 18:49:56 +08:00
parent a02c0a8a3a
commit 88accc65ad
2 changed files with 91 additions and 57 deletions

View file

@ -115,7 +115,7 @@ export const openMenuPanel = (options: {
avPanelElement = document.querySelector(".av__panel");
let closeCB: () => void;
const menuElement = avPanelElement.lastElementChild as HTMLElement;
const tabRect = options.blockElement.querySelector(`.av__views, .av__row[data-col-id="${options.colId}"] > .block__logo`)?.getBoundingClientRect();
let tabRect = options.blockElement.querySelector(`.av__views, .av__row[data-col-id="${options.colId}"] > .block__logo`)?.getBoundingClientRect();
if (["select", "date", "asset", "relation", "rollup"].includes(options.type)) {
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
if (options.type === "select") {
@ -484,6 +484,8 @@ export const openMenuPanel = (options: {
event.stopPropagation();
break;
} else if (type === "go-properties") {
// 复制列后点击返回到属性面板,宽度不一致,需重新计算
tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
menuElement.innerHTML = getPropertiesHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
event.preventDefault();
@ -981,19 +983,13 @@ export const openMenuPanel = (options: {
event.stopPropagation();
break;
} else if (type === "duplicateCol") {
const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
const colData = data.view.columns.find((item: IAVColumn) => item.id === colId);
duplicateCol({
blockElement: options.blockElement,
protyle: options.protyle,
type: colData.type,
avID,
colId,
icon: colData.icon,
newValue: colData.name,
colId: menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"),
data,
viewID: data.viewID,
});
avPanelElement.remove();
event.preventDefault();
event.stopPropagation();
break;
@ -1004,6 +1000,7 @@ export const openMenuPanel = (options: {
const colData = data.view.columns.find((item: IAVColumn, index) => {
if (item.id === colId) {
previousID = data.view.columns[index - 1]?.id;
data.view.columns.splice(index, 1);
return true;
}
});
@ -1030,7 +1027,14 @@ export const openMenuPanel = (options: {
}]);
removeAttrViewColAnimation(options.blockElement, colId);
options.blockElement.setAttribute("updated", newUpdated);
avPanelElement.remove();
if (isCustomAttr) {
avPanelElement.remove();
} else {
tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
menuElement.innerHTML = getPropertiesHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
}
});
event.preventDefault();
event.stopPropagation();
@ -1187,7 +1191,7 @@ export const openMenuPanel = (options: {
});
};
const getPropertiesHTML = (data: IAVTable) => {
export const getPropertiesHTML = (data: IAVTable) => {
let showHTML = "";
let hideHTML = "";
data.columns.forEach((item: IAVColumn) => {