mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
851ce86084
commit
26788e6985
2 changed files with 19 additions and 12 deletions
|
|
@ -407,12 +407,13 @@ ${html}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
|
const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
|
||||||
|
const colType = target.getAttribute("data-coltype") as TAVCol;
|
||||||
const menu = new Menu(undefined, () => {
|
const menu = new Menu(undefined, () => {
|
||||||
const colId = target.parentElement.parentElement.getAttribute("data-id");
|
const colId = target.parentElement.parentElement.getAttribute("data-id");
|
||||||
const oldFilters = JSON.parse(JSON.stringify(data.filters));
|
const oldFilters = JSON.parse(JSON.stringify(data.filters));
|
||||||
data.filters.find((filter) => {
|
data.filters.find((filter) => {
|
||||||
if (filter.column === colId) {
|
if (filter.column === colId) {
|
||||||
filter.value = {
|
filter.value[colType] = {
|
||||||
content: (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).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;
|
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 = "";
|
let selectHTML = "";
|
||||||
switch (target.getAttribute("data-coltype")) {
|
switch (colType) {
|
||||||
case "text":
|
case "text":
|
||||||
selectHTML = `<option value="=">=</option>
|
selectHTML = `<option value="=">=</option>
|
||||||
<option value="!=">!=</option>
|
<option value="!=">!=</option>
|
||||||
|
|
@ -482,13 +483,15 @@ const addFilter = (options: {
|
||||||
icon: getColIconByType(column.type),
|
icon: getColIconByType(column.type),
|
||||||
click: () => {
|
click: () => {
|
||||||
const oldFilters = Object.assign([], options.data.filters);
|
const oldFilters = Object.assign([], options.data.filters);
|
||||||
const value: IAVCellValue = {
|
|
||||||
content: ""
|
|
||||||
}
|
|
||||||
options.data.filters.push({
|
options.data.filters.push({
|
||||||
column: column.id,
|
column: column.id,
|
||||||
operator: "Contains",
|
operator: "Contains",
|
||||||
value,
|
value: {
|
||||||
|
[column.type]: {
|
||||||
|
content: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "setAttrView",
|
action: "setAttrView",
|
||||||
|
|
@ -522,9 +525,10 @@ const getFiltersHTML = (data: IAV) => {
|
||||||
let filterHTML = "";
|
let filterHTML = "";
|
||||||
data.columns.find((item) => {
|
data.columns.find((item) => {
|
||||||
if (item.id === filter.column) {
|
if (item.id === filter.column) {
|
||||||
filterHTML += `<span data-type="setFilter" data-coltype="${item.type}" class="b3-chip${filter.value?.content ? " b3-chip--primary" : ""}">
|
const filterValue = (filter.value && filter.value[item.type] && filter.value[item.type].content) ? ":" + filter.value[item.type].content : "";
|
||||||
|
filterHTML += `<span data-type="setFilter" data-coltype="${item.type}" class="b3-chip${filterValue ? " b3-chip--primary" : ""}">
|
||||||
<svg><use xlink:href="#${getColIconByType(item.type)}"></use></svg>
|
<svg><use xlink:href="#${getColIconByType(item.type)}"></use></svg>
|
||||||
<span class="fn__ellipsis">${item.name}${filter.value?.content ? ":" + filter.value?.content : ""}</span>
|
<span class="fn__ellipsis">${item.name}${filterValue}</span>
|
||||||
</span>`;
|
</span>`;
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
app/src/types/index.d.ts
vendored
11
app/src/types/index.d.ts
vendored
|
|
@ -882,8 +882,11 @@ interface IAVCell {
|
||||||
valueType: TAVCol,
|
valueType: TAVCol,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IAVCellValue {
|
type IAVCellValue = {
|
||||||
content: string,
|
[key in TAVCol]?: {
|
||||||
content2?: string,
|
content: string
|
||||||
color?: string,
|
content2?: string
|
||||||
|
color?: string
|
||||||
|
id?: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue