diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 868e9adac..bae0b05f7 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -407,12 +407,13 @@ ${html} }; const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => { + const colType = target.getAttribute("data-coltype") as TAVCol; const menu = new Menu(undefined, () => { const colId = target.parentElement.parentElement.getAttribute("data-id"); const oldFilters = JSON.parse(JSON.stringify(data.filters)); data.filters.find((filter) => { if (filter.column === colId) { - filter.value = { + filter.value[colType] = { content: (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value }; filter.operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator; @@ -434,7 +435,7 @@ const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => { }]); }); let selectHTML = ""; - switch (target.getAttribute("data-coltype")) { + switch (colType) { case "text": selectHTML = ` @@ -482,13 +483,15 @@ const addFilter = (options: { 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, + value: { + [column.type]: { + content: "" + } + }, }); transaction(options.protyle, [{ action: "setAttrView", @@ -522,9 +525,10 @@ const getFiltersHTML = (data: IAV) => { let filterHTML = ""; data.columns.find((item) => { if (item.id === filter.column) { - filterHTML += ` + const filterValue = (filter.value && filter.value[item.type] && filter.value[item.type].content) ? ":" + filter.value[item.type].content : ""; + filterHTML += ` - ${item.name}${filter.value?.content ? ":" + filter.value?.content : ""} + ${item.name}${filterValue} `; return true } diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 44d36eac9..287879484 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -882,8 +882,11 @@ interface IAVCell { valueType: TAVCol, } -interface IAVCellValue { - content: string, - content2?: string, - color?: string, +type IAVCellValue = { + [key in TAVCol]?: { + content: string + content2?: string + color?: string + id?: string + } }