diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index d82e214d8..2507b0d34 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -413,7 +413,54 @@ const addFilter = (options: { avId: string, protyle: IProtyle }) => { - + const menu = new Menu("av-add-filter"); + options.data.columns.forEach((column) => { + let hasFilter = false; + options.data.filters.find((filter) => { + if (filter.column === column.id) { + hasFilter = true; + return true; + } + }); + if (!hasFilter) { + menu.addItem({ + label: column.name, + icon: getColIconByType(column.type), + click: () => { + const oldFilters = Object.assign([], options.data.filters); + const value: IAVCellValue = { + content: "" + } + options.data.filters.push({ + column: column.id, + operator: "Contains", + value, + }); + transaction(options.protyle, [{ + action: "setAttrView", + id: options.avId, + data: { + filters: options.data.filters + } + }], [{ + action: "setAttrView", + id: options.avId, + data: { + filters: oldFilters + } + }]); + options.menuElement.innerHTML = getFiltersHTML(options.data); + bindFiltersEvent(options.protyle, options.menuElement, options.data); + setPosition(options.menuElement, options.tabRect.right - options.menuElement.clientWidth, options.tabRect.bottom, options.tabRect.height); + } + }); + } + }); + menu.open({ + x: options.rect.left, + y: options.rect.bottom, + h: options.rect.height, + }); } const bindFiltersEvent = (protyle: IProtyle, menuElement: HTMLElement, data: IAV) => { @@ -432,14 +479,9 @@ const getFiltersHTML = (data: IAV) => { data.filters.forEach((item: IAVFilter) => { html += ``; }); @@ -533,7 +575,7 @@ const getConfigHTML = (data: IAV) => { ${data.columns.filter((item: IAVColumn) => !item.hidden).length}/${data.columns.length} -