diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index c0c539875..b734f0b3a 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -149,6 +149,18 @@
width: 300px;
max-height: 70vh;
+ .b3-chip {
+ max-width: 220px;
+ margin: 1px 0;
+ padding: 6px 12px 6px 14px;
+ float: left;
+
+ svg {
+ width: 12px;
+ flex-shrink: 0;
+ }
+ }
+
.block__icon {
line-height: 20px;
padding: 0 4px;
@@ -161,12 +173,12 @@
overflow: hidden;
}
+ &__item:hover .b3-menu__action {
+ opacity: 1;
+ }
+
&__item:not([data-type="nobg"]):hover {
background-color: var(--b3-list-hover);
-
- .b3-menu__action {
- opacity: 1;
- }
}
}
}
diff --git a/app/src/assets/scss/component/_chip.scss b/app/src/assets/scss/component/_chip.scss
index e437349fe..573df4012 100644
--- a/app/src/assets/scss/component/_chip.scss
+++ b/app/src/assets/scss/component/_chip.scss
@@ -18,7 +18,7 @@
align-items: center;
box-sizing: border-box;
padding: 8px 12px;
- border-radius: var(--b3-border-radius-b);
+ border-radius: 20px;
transition: var(--b3-transition);
text-decoration: none;
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 2507b0d34..868e9adac 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -114,7 +114,6 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
break;
} else if (type === "goFilters") {
menuElement.innerHTML = getFiltersHTML(data);
- bindFiltersEvent(protyle, menuElement, data);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
event.stopPropagation();
break;
@@ -123,18 +122,17 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
action: "setAttrView",
id: avId,
data: {
- Filters: []
+ filters: []
}
}], [{
action: "setAttrView",
id: avId,
data: {
- Filters: data.filters
+ filters: data.filters
}
}]);
data.filters = [];
menuElement.innerHTML = getFiltersHTML(data);
- bindFiltersEvent(protyle, menuElement, data);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
event.stopPropagation();
break;
@@ -154,20 +152,23 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
action: "setAttrView",
id: avId,
data: {
- Filters: data.filters
+ filter: data.filters
}
}], [{
action: "setAttrView",
id: avId,
data: {
- Filters: oldFilters
+ filter: oldFilters
}
}]);
menuElement.innerHTML = getFiltersHTML(data);
- bindFiltersEvent(protyle, menuElement, data);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
event.stopPropagation();
break;
+ } else if (type === "setFilter") {
+ setFilter(protyle, data, target);
+ event.stopPropagation();
+ break;
} else if (type === "newCol") {
avPanelElement.remove();
const addMenu = addCol(protyle, blockElement);
@@ -405,6 +406,59 @@ ${html}
`;
};
+const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
+ 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 = {
+ 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;
+ return true;
+ }
+ });
+ transaction(protyle, [{
+ action: "setAttrView",
+ id: data.id,
+ data: {
+ filters: data.filters
+ }
+ }], [{
+ action: "setAttrView",
+ id: data.id,
+ data: {
+ filters: oldFilters
+ }
+ }]);
+ });
+ let selectHTML = "";
+ switch (target.getAttribute("data-coltype")) {
+ case "text":
+ selectHTML = `
+
+
+
+
+
+
+
+`;
+ break;
+ }
+ menu.addItem({
+ iconHTML: "",
+ label: ``
+ })
+ menu.addItem({
+ iconHTML: "",
+ label: ``
+ })
+ const rectTarget = target.getBoundingClientRect();
+ menu.open({x: rectTarget.left, y: rectTarget.bottom})
+}
+
const addFilter = (options: {
data: IAV,
rect: DOMRect,
@@ -450,7 +504,6 @@ const addFilter = (options: {
}
}]);
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);
}
});
@@ -463,25 +516,25 @@ const addFilter = (options: {
});
}
-const bindFiltersEvent = (protyle: IProtyle, menuElement: HTMLElement, data: IAV) => {
-
-}
-
const getFiltersHTML = (data: IAV) => {
let html = "";
- const genFilterItem = (id: string) => {
+ const genFilterItem = (filter: IAVFilter) => {
let filterHTML = "";
- data.columns.forEach((item) => {
- filterHTML += ``;
+ data.columns.find((item) => {
+ if (item.id === filter.column) {
+ filterHTML += `
+
+ ${item.name}${filter.value?.content ? ":" + filter.value?.content : ""}
+`;
+ return true
+ }
});
return filterHTML;
};
data.filters.forEach((item: IAVFilter) => {
- html += `