feat(grid): add LIKE, NOT LIKE, <, > context menu filters

Add four new filter options to the right-click context menu in table
data view: contains (LIKE), does not contain (NOT LIKE), less than (<),
and greater than (>). Includes en/zh-CN/es translations.
This commit is contained in:
t8y2
2026-05-11 12:39:31 +08:00
parent 1b0c17315b
commit 1934205c86
4 changed files with 35 additions and 2 deletions
+23 -2
View File
@@ -1139,7 +1139,17 @@ function applyContextSort(direction: "asc" | "desc" | null) {
emit("sort", column, columnIndex, direction, currentWhereInput());
}
function contextFilterCondition(mode: "equals" | "not-equals" | "is-null" | "is-not-null"): string | null {
type FilterMode =
| "equals"
| "not-equals"
| "is-null"
| "is-not-null"
| "like"
| "not-like"
| "less-than"
| "greater-than";
function contextFilterCondition(mode: FilterMode): string | null {
if (!contextColumn.value) return null;
const column = quoteIdent(contextColumn.value);
const value = contextCellValue.value;
@@ -1147,10 +1157,14 @@ function contextFilterCondition(mode: "equals" | "not-equals" | "is-null" | "is-
if (mode === "is-null") return `${column} IS NULL`;
if (mode === "is-not-null") return `${column} IS NOT NULL`;
if (value === null) return mode === "equals" ? `${column} IS NULL` : `${column} IS NOT NULL`;
if (mode === "like") return `${column} LIKE ${escapeVal(`%${value}%`)}`;
if (mode === "not-like") return `${column} NOT LIKE ${escapeVal(`%${value}%`)}`;
if (mode === "less-than") return `${column} < ${escapeVal(value)}`;
if (mode === "greater-than") return `${column} > ${escapeVal(value)}`;
return mode === "equals" ? `${column} = ${escapeVal(value)}` : `${column} <> ${escapeVal(value)}`;
}
async function applyContextFilter(mode: "equals" | "not-equals" | "is-null" | "is-not-null") {
async function applyContextFilter(mode: FilterMode) {
if (!canUseWhereSearch.value) return;
const condition = contextFilterCondition(mode);
if (!condition) return;
@@ -2366,6 +2380,13 @@ defineExpose({
<ContextMenuItem @click="applyContextFilter('not-equals')">
{{ t("grid.filterExcludeValue") }}
</ContextMenuItem>
<ContextMenuItem @click="applyContextFilter('like')">{{ t("grid.filterLike") }}</ContextMenuItem>
<ContextMenuItem @click="applyContextFilter('not-like')">{{ t("grid.filterNotLike") }}</ContextMenuItem>
<ContextMenuItem @click="applyContextFilter('less-than')">{{ t("grid.filterLessThan") }}</ContextMenuItem>
<ContextMenuItem @click="applyContextFilter('greater-than')">
{{ t("grid.filterGreaterThan") }}
</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem @click="applyContextFilter('is-null')">{{ t("grid.filterIsNull") }}</ContextMenuItem>
<ContextMenuItem @click="applyContextFilter('is-not-null')">
{{ t("grid.filterIsNotNull") }}
+4
View File
@@ -242,6 +242,10 @@ export default {
moreValues: "{count} more values, keep typing to narrow results",
filterByValue: "Filter by This Value",
filterExcludeValue: "Exclude This Value",
filterLike: "Contains Value",
filterNotLike: "Does Not Contain",
filterLessThan: "Less Than Value",
filterGreaterThan: "Greater Than Value",
filterIsNull: "Show NULL Values",
filterIsNotNull: "Show Non-NULL Values",
clearFilter: "Clear Filter",
+4
View File
@@ -243,6 +243,10 @@ export default {
moreValues: "{count} valores más, sigue escribiendo para acotar los resultados",
filterByValue: "Filtrar por este valor",
filterExcludeValue: "Excluir este valor",
filterLike: "Contiene este valor",
filterNotLike: "No contiene este valor",
filterLessThan: "Menor que este valor",
filterGreaterThan: "Mayor que este valor",
filterIsNull: "Mostrar valores NULL",
filterIsNotNull: "Mostrar valores no NULL",
clearFilter: "Limpiar filtro",
+4
View File
@@ -241,6 +241,10 @@ export default {
moreValues: "还有 {count} 个值,输入关键词继续缩小范围",
filterByValue: "筛选此值",
filterExcludeValue: "排除此值",
filterLike: "包含此值",
filterNotLike: "不包含此值",
filterLessThan: "小于此值",
filterGreaterThan: "大于此值",
filterIsNull: "仅显示 NULL",
filterIsNotNull: "仅显示非 NULL",
clearFilter: "清除筛选",