Skip to content

Commit

Permalink
code>new: implement NOT keyword in the filter
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnfan committed May 19, 2023
1 parent 28c0c5d commit b45eddc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ tagmark-ui has implemented the invocation of filters through pure frontend Javas
## TODO

- [x] fix overlay doc `<a>` style
- [ ] implement NOT keyword in the filter
- [x] implement NOT keyword in the filter
1 change: 1 addition & 0 deletions doc/filter.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following keywords (operators) are defined in Advanced Filter:

- `AND`: Must be uppercase, indicating "and" operation, similar to the `&&` logical operator in Javascript.
- `OR`: Must be uppercase, indicating "or" operation, similar to the `||` logical operator in Javascript.
- `NOT`: Must be uppercase, indicating "not" operation, similar to the `!` logical operator in Javascript.
- `(` and `)`: Used to combine multiple expressions and control their priority, what is consistent with most programming languages.

**No quotation marks (`"` or `'`) are required in the string entered in Advanced Filter.**
Expand Down
1 change: 1 addition & 0 deletions doc/filter.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

- `AND`:大文字でなければならず、「そして」操作を示し、Javascriptの`&&`論理演算子に似ています。
- `OR`:大文字でなければならず、「または」操作を示し、Javascriptの`||`論理演算子に似ています。
- `NOT`:大文字でなければならず、「非」操作を示し、Javascriptの`!`論理演算子に似ています。
- `(` および `)`:複数の式を結合し、その優先順位を制御するために使用されます。ほとんどのプログラミング言語と一致します。

**アドバンストフィルターで入力する文字列に引用符(`"`または`'`)は必要ありません。**
Expand Down
1 change: 1 addition & 0 deletions doc/filter.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Advanced Filter 中定义了如下的关键字(运算符):

- `AND`: 必须大写,表示 "与" 运算,它类似于Javascript 中的 `&&` 逻辑运算符。
- `OR`: 必须大写,表示 "或" 运算,它类似于Javascript 中的 `||` 逻辑运算符。
- `NOT`: 必须大写,表示 "非" 运算,它类似于Javascript 中的 `!` 逻辑运算符。
- `(``)`: 用来组合多个表达式,并控制它们的优先级。它的用法与大多数编程语言中的用法一致。

**Advanced Filter 中输入的字符串不需要使用 `"` 或者 `'` 括起来。**
Expand Down
5 changes: 4 additions & 1 deletion js/tagmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ function customHeaderFilter(headerValue, rowValue, rowData, filterParams) {
if (!cellValue) return false;

// case insensitive and trim
let headerValueParts = headerValue.trim().split(/\b(OR|AND)\b/);
let headerValueParts = headerValue.trim().split(/\b(OR|AND|NOT)\b/);
let checkHeaderValueParts = Array();
headerValueParts.forEach((headerValuePart) => {
headerValuePart = headerValuePart.trim();
if (headerValuePart === "AND") {
checkHeaderValueParts.push("&&");
} else if (headerValuePart === "OR") {
checkHeaderValueParts.push("||");
} else if (headerValuePart === "NOT") {
checkHeaderValueParts.push("!");
} else {
let keyword = extractKeyword(headerValuePart);
if (!keyword.trim()) return;
if (Array.isArray(cellValue)) {
if (cellValue.length === 0) return false;
checkHeaderValueParts.push(
Expand Down

0 comments on commit b45eddc

Please sign in to comment.