mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 17:28:50 +01:00
This commit is contained in:
parent
afd1ea9dc2
commit
5e189c300e
2 changed files with 20 additions and 6 deletions
|
|
@ -131,8 +131,8 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
|
|||
cellValue = {
|
||||
type: colType,
|
||||
number: {
|
||||
content: 0,
|
||||
isNotEmpty: true
|
||||
content: null,
|
||||
isNotEmpty: false
|
||||
}
|
||||
};
|
||||
} else if (["text", "block", "url", "phone", "email", "template"].includes(colType)) {
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ export const setFilter = async (options: {
|
|||
const menu = new Menu("set-filter-" + options.filter.column, () => {
|
||||
const oldFilters = JSON.parse(JSON.stringify(options.data.view.filters));
|
||||
const selectElement = window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement;
|
||||
if (!selectElement) {
|
||||
const operator = selectElement.value as TAVFilterOperator;
|
||||
if (!selectElement || !operator) {
|
||||
return;
|
||||
}
|
||||
const operator = selectElement.value as TAVFilterOperator;
|
||||
let hasMatch = false;
|
||||
let cellValue: IAVCellValue;
|
||||
if (textElements.length > 0) {
|
||||
|
|
@ -101,6 +101,10 @@ export const setFilter = async (options: {
|
|||
}
|
||||
});
|
||||
cellValue = genCellValue(filterType, mSelect);
|
||||
} else if (filterType === "checkbox") {
|
||||
cellValue = genCellValue(filterType, {
|
||||
checked: operator === "Is true"
|
||||
});
|
||||
} else {
|
||||
cellValue = genCellValue(filterType, undefined);
|
||||
}
|
||||
|
|
@ -112,6 +116,12 @@ export const setFilter = async (options: {
|
|||
let isSame = false;
|
||||
options.data.view.filters.find((filter, index) => {
|
||||
if (filter.column === options.filter.column) {
|
||||
if (filter.type && filter.type === "checkbox") {
|
||||
hasMatch = true;
|
||||
delete filter.type;
|
||||
options.data.view.filters[index] = newFilter;
|
||||
return true;
|
||||
}
|
||||
delete filter.type;
|
||||
if (objEquals(filter, newFilter)) {
|
||||
isSame = true;
|
||||
|
|
@ -187,8 +197,12 @@ export const setFilter = async (options: {
|
|||
}
|
||||
switch (filterType) {
|
||||
case "checkbox":
|
||||
selectHTML = `<option ${"Is true" === options.filter.operator ? "selected" : ""} value="Is true">${window.siyuan.languages.checked}</option>
|
||||
<option ${"Is false" === options.filter.operator ? "selected" : ""} value="Is false">${window.siyuan.languages.unchecked}</option>`;
|
||||
selectHTML = `<option ${("Is true" === options.filter.operator && !options.filter.type) ? "selected" : ""} value="Is true">${window.siyuan.languages.checked}</option>
|
||||
<option ${("Is false" === options.filter.operator && !options.filter.type) ? "selected" : ""} value="Is false">${window.siyuan.languages.unchecked}</option>`;
|
||||
if (options.filter.type) {
|
||||
// 初始化时有 type 字段
|
||||
selectHTML = `<option selected></option>${selectHTML}`;
|
||||
}
|
||||
break;
|
||||
case "block":
|
||||
case "text":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue