An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Support database filter composition https://github.com/siyuan-note/siyuan/issues/10550
Daniela3f2060ce313
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scssindex 8425d4727e..176957cc21 100644--- a/app/src/assets/scss/business/_av.scss+++ b/app/src/assets/scss/business/_av.scss@@ -924,7 +924,7 @@.av__filter-group-item {padding-left: 8px;- &:hover .b3-menu__action {+ &:hover > .b3-menu__action {opacity: 1;}}@@ -936,7 +936,6 @@gap: 2px;min-height: 28px;padding-right: 4px;- align-self: center;}.av__filter-group-children {diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.tsindex e28b372158..7c3023dbc0 100644--- a/app/src/protyle/render/av/filter.ts+++ b/app/src/protyle/render/av/filter.ts@@ -10,18 +10,6 @@ import {fetchPost} from "../../../util/fetch";import {getFieldsByData} from "./view";import {Constants} from "../../../constants";-// 记录当前筛选面板中已折叠的分组路径。面板关闭时由 openMenuPanel 调用 resetFoldedFilterPaths 清空。-// 渲染时据此给容器加 fn__none、箭头设为 iconRight,使重渲染后折叠状态得以保持。-const foldedFilterPaths = new Set<string>();-export const resetFoldedFilterPaths = () => foldedFilterPaths.clear();-export const toggleFoldedFilterPath = (path: string) => {- if (foldedFilterPaths.has(path)) {- foldedFilterPaths.delete(path);- } else {- foldedFilterPaths.add(path);- }-};-export const getDefaultOperatorByType = (type: TAVCol) => {if (["select", "number", "date", "created", "updated"].includes(type)) {return "=";@@ -233,9 +221,6 @@ export const getFiltersHTML = (data: IAV) => {const childPath = path ? `${path},${index}` : `${index}`;childrenHTML += genNodeHTML(child, childPath, depth + 1, path, combination);});- if (0 === node.filters.length) {- childrenHTML = `<div class="b3-menu__item" data-path="${path}" data-empty-group="${path}"><span class="b3-menu__labels" style="padding-left: 8px;">${window.siyuan.languages.emptyFilterGroup}</span></div>`;- }if (isRoot) {return childrenHTML;diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex 3e18786adc..0041f1a38b 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -25,8 +25,7 @@ import {getFiltersHTML,hasFilterForColumn,removeFilterByPath,- removeFiltersByColumn,- resetFoldedFilterPaths+ removeFiltersByColumn} from "./filter";import {genCellValue, updateCellsValue} from "./cell";import {addSort, bindSortsEvent, getSortsHTML} from "./sort";@@ -124,7 +123,6 @@ export const openMenuPanel = (options: {} else if (options.type === "switcher") {html = getSwitcherHTML(data.views, data.viewID);} else if (options.type === "filters") {- resetFoldedFilterPaths();html = getFiltersHTML(data);} else if (options.type === "select") {html = getSelectHTML(fields, options.cellElements, true, options.blockElement);@@ -502,69 +500,6 @@ export const openMenuPanel = (options: {event.preventDefault();event.stopPropagation();break;- } else if (type === "addFilterGroup") {- const path = target.closest("[data-path]")?.getAttribute("data-path") || "";- // 记录目标分组在添加前的子节点数,用于事务后计算新分组的 path 并滚动定位- let targetFilters: IAVFilter[];- if ("" === path) {- targetFilters = getEditableFilters(data);- } else {- const node = getFilterByPath(getEditableFilters(data), path);- targetFilters = node && node.filters ? node.filters : getEditableFilters(data);- }- const newGroupIndex = targetFilters.length;- const oldFilters = JSON.parse(JSON.stringify(data.view.filters));- addFilterGroup(data, path);- transaction(options.protyle, [{- action: "setAttrViewFilters",- avID,- data: data.view.filters,- blockID- }], [{- action: "setAttrViewFilters",- avID,- data: oldFilters,- blockID- }]);- menuElement.innerHTML = getFiltersHTML(data);- setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);- // 滚动到新分组,引导用户继续往里添加条件- const newGroupPath = path ? `${path},${newGroupIndex}` : `${newGroupIndex}`;- const newGroupRow = menuElement.querySelector(`.av__filter-group-item[data-path="${newGroupPath}"]`) as HTMLElement;- newGroupRow?.scrollIntoView({behavior: "smooth", block: "nearest"});- event.preventDefault();- event.stopPropagation();- break;- } else if (type === "removeFilter") {- window.siyuan.menus.menu.remove();- const path = target.getAttribute("data-path") || target.closest("[data-path]")?.getAttribute("data-path") || "";- const node = getFilterByPath(getEditableFilters(data), path);- // 删除非空分组(含子条件)需二次确认,避免误删整组;单条件直接删- const doRemove = () => {- const oldFilters = JSON.parse(JSON.stringify(data.view.filters));- removeFilterByPath(getEditableFilters(data), path);- transaction(options.protyle, [{- action: "setAttrViewFilters",- avID,- data: data.view.filters,- blockID- }], [{- action: "setAttrViewFilters",- avID,- data: oldFilters,- blockID- }]);- menuElement.innerHTML = getFiltersHTML(data);- setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);- };- if (node && node.filters && node.filters.length > 0) {- confirmDialog(window.siyuan.languages.removeFilters, window.siyuan.languages.confirmDeleteFilterGroupTip, doRemove);- } else {- doRemove();- }- event.preventDefault();- event.stopPropagation();- break;} else if (type === "addFilterCondition") {const path = target.dataset.path || target.closest("[data-path]")?.getAttribute("data-path") || "";const depth = parseInt(target.dataset.depth || target.closest("[data-depth]")?.getAttribute("data-depth") || "0", 10);@@ -666,7 +601,7 @@ export const openMenuPanel = (options: {const isGroup = node && node.filters;const popup = document.createElement("div");popup.className = "b3-menu";- popup.style.cssText = `position:fixed;z-index:${++window.siyuan.zIndex};min-width:140px;top:${event.clientY + 100 < window.innerHeight ? event.clientY + 4 : event.clientY - 64}px;left:${Math.max(0, event.clientX - 120)}px;`;+ popup.style.cssText = `position:fixed;z-index:${++window.siyuan.zIndex};min-width:160px;top:${event.clientY + 100 < window.innerHeight ? event.clientY + 4 : event.clientY - 64}px;left:${Math.max(0, event.clientX - 120)}px;`;const items: {type: string; label: string; icon: string; cls?: string}[] = [{type: "duplicateFilter", label: window.siyuan.languages.duplicate, icon: "iconAdd"},];