mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-11 11:18:50 +01:00
🚨
This commit is contained in:
parent
e6a8abf004
commit
6f0c68f506
11 changed files with 29 additions and 31 deletions
|
|
@ -33,7 +33,7 @@ const calcItem = (options: {
|
|||
}
|
||||
}]);
|
||||
} else {
|
||||
options.target.querySelector(".b3-menu__accelerator").textContent = getNameByOperator(options.operator, true)
|
||||
options.target.querySelector(".b3-menu__accelerator").textContent = getNameByOperator(options.operator, true);
|
||||
const colData = options.data.view.columns.find((item) => {
|
||||
if (item.id === options.colId) {
|
||||
if (!item.rollup) {
|
||||
|
|
@ -440,6 +440,6 @@ export const getNameByOperator = (operator: string, isRollup: boolean) => {
|
|||
case "Latest":
|
||||
return window.siyuan.languages.calcOperatorLatest;
|
||||
default:
|
||||
return ""
|
||||
return "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -667,7 +667,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
|
|||
};
|
||||
|
||||
const renderRollup = (cellValue: IAVCellValue) => {
|
||||
let text = ""
|
||||
let text = "";
|
||||
if (["text"].includes(cellValue.type)) {
|
||||
text = cellValue ? (cellValue[cellValue.type as "text"].content || "") : "";
|
||||
} else if (["url", "email", "phone"].includes(cellValue.type)) {
|
||||
|
|
@ -700,7 +700,7 @@ const renderRollup = (cellValue: IAVCellValue) => {
|
|||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
||||
icon?: string,
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||
icon: "iconEdit",
|
||||
label: window.siyuan.languages.edit,
|
||||
click() {
|
||||
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value
|
||||
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
|
||||
openMenuPanel({
|
||||
protyle,
|
||||
blockElement,
|
||||
|
|
@ -538,7 +538,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||
colId,
|
||||
cb(avElement) {
|
||||
// 修改名字后点击编辑,需要更新名字
|
||||
const editNameElement = avElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
|
||||
const editNameElement = avElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement;
|
||||
editNameElement.value = colName;
|
||||
editNameElement.select();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export const setFilter = async (options: {
|
|||
}
|
||||
const menu = new Menu("set-filter-" + options.filter.column, () => {
|
||||
const oldFilters = JSON.parse(JSON.stringify(options.data.view.filters));
|
||||
const selectElement = window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement
|
||||
const selectElement = window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement;
|
||||
if (!selectElement) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -162,10 +162,10 @@ export const setFilter = async (options: {
|
|||
});
|
||||
return;
|
||||
}
|
||||
let targetAVId = ""
|
||||
let targetAVId = "";
|
||||
options.data.view.columns.find((column) => {
|
||||
if (column.id === colData.rollup.relationKeyID) {
|
||||
targetAVId = column.relation.avID
|
||||
targetAVId = column.relation.avID;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
@ -180,10 +180,10 @@ export const setFilter = async (options: {
|
|||
if (item.column === colData.id && item.type) {
|
||||
item.operator = getDefaultOperatorByType(filterType);
|
||||
item.value = genCellValue(filterType, "");
|
||||
delete item.type
|
||||
delete item.type;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
switch (filterType) {
|
||||
case "checkbox":
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ const updateCol = (options: {
|
|||
isRelation: boolean,
|
||||
}, itemElement: HTMLElement) => {
|
||||
if (itemElement.classList.contains("b3-list--empty")) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
options.target.querySelector(".b3-menu__accelerator").textContent = itemElement.querySelector(".b3-list-item__text").textContent
|
||||
options.target.querySelector(".b3-menu__accelerator").textContent = itemElement.querySelector(".b3-list-item__text").textContent;
|
||||
|
||||
const colData = options.data.view.columns.find((item) => {
|
||||
if (item.id === options.colId) {
|
||||
|
|
@ -62,7 +62,7 @@ const updateCol = (options: {
|
|||
const genSearchList = (element: Element, keyword: string, avId: string, isRelation: boolean, cb?: () => void) => {
|
||||
if (!isRelation && !avId) {
|
||||
showMessage(window.siyuan.languages.selectRelation);
|
||||
return
|
||||
return;
|
||||
}
|
||||
fetchPost(isRelation ? "/api/av/searchAttributeViewRelationKey" : "/api/av/searchAttributeViewNonRelationKey", {
|
||||
avID: avId,
|
||||
|
|
@ -172,8 +172,8 @@ export const getRollupHTML = (options: { data?: IAV, cellElements?: HTMLElement[
|
|||
<span class="b3-menu__label">${window.siyuan.languages.calc}</span>
|
||||
<span class="b3-menu__accelerator">${getNameByOperator(colData.rollup?.calc?.operator, true)}</span>
|
||||
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
|
||||
</button>`
|
||||
}
|
||||
</button>`;
|
||||
};
|
||||
|
||||
export const bindRollupEvent = (options: {
|
||||
protyle: IProtyle,
|
||||
|
|
@ -184,7 +184,7 @@ export const bindRollupEvent = (options: {
|
|||
if (goSearchRollupColElement) {
|
||||
const oldValue = JSON.parse(goSearchRollupColElement.dataset.oldValue) as IAVCellRollupValue;
|
||||
const goSearchRollupTargetElement = options.menuElement.querySelector('[data-type="goSearchRollupTarget"]') as HTMLElement;
|
||||
let targetKeyAVId = ""
|
||||
let targetKeyAVId = "";
|
||||
if (oldValue.relationKeyID) {
|
||||
options.data.view.columns.find((item) => {
|
||||
if (item.id === oldValue.relationKeyID) {
|
||||
|
|
@ -193,13 +193,13 @@ export const bindRollupEvent = (options: {
|
|||
goSearchRollupTargetElement.dataset.avId = targetKeyAVId;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
if (oldValue.keyID && targetKeyAVId) {
|
||||
fetchPost("/api/av/getAttributeView", {id: targetKeyAVId}, (response) => {
|
||||
response.data.av.keyValues.find((item: { key: { id: string, name: string, type: TAVCol } }) => {
|
||||
if (item.key.id === oldValue.keyID) {
|
||||
goSearchRollupTargetElement.querySelector('.b3-menu__accelerator').textContent = item.key.name;
|
||||
goSearchRollupTargetElement.querySelector(".b3-menu__accelerator").textContent = item.key.name;
|
||||
const goSearchRollupCalcElement = options.menuElement.querySelector('[data-type="goSearchRollupCalc"]') as HTMLElement;
|
||||
goSearchRollupCalcElement.dataset.colType = item.key.type;
|
||||
goSearchRollupCalcElement.dataset.calc = oldValue.calc.operator;
|
||||
|
|
@ -209,4 +209,4 @@ export const bindRollupEvent = (options: {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue