Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
6a40be9f
Commit
6a40be9f
authored
Jan 12, 2022
by
email
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: tag query filter
parent
308adef9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
11 deletions
+51
-11
MemoList.tsx
web/src/components/MemoList.tsx
+20
-7
TagList.tsx
web/src/components/TagList.tsx
+1
-1
filter.ts
web/src/helpers/filter.ts
+15
-1
MemoTrash.tsx
web/src/pages/MemoTrash.tsx
+15
-2
No files found.
web/src/components/MemoList.tsx
View file @
6a40be9f
...
@@ -19,23 +19,36 @@ const MemoList: React.FC<Props> = () => {
...
@@ -19,23 +19,36 @@ const MemoList: React.FC<Props> = () => {
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
filter
:
queryId
}
=
query
;
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
filter
:
queryId
}
=
query
;
const
showMemoFilter
=
Boolean
(
tagQuery
||
(
duration
&&
duration
.
from
<
duration
.
to
)
||
memoType
||
textQuery
);
const
queryFilter
=
queryService
.
getQueryById
(
queryId
);
const
showMemoFilter
=
Boolean
(
tagQuery
||
(
duration
&&
duration
.
from
<
duration
.
to
)
||
memoType
||
textQuery
||
queryFilter
);
const
shownMemos
=
const
shownMemos
=
showMemoFilter
||
query
Id
showMemoFilter
||
query
Filter
?
memos
.
filter
((
memo
)
=
>
{
?
memos
.
filter
((
memo
)
=
>
{
let
shouldShow
=
true
;
let
shouldShow
=
true
;
const
query
=
queryService
.
getQueryById
(
queryId
);
if
(
queryFilter
)
{
if
(
query
)
{
const
filters
=
JSON
.
parse
(
queryFilter
.
querystring
)
as
Filter
[];
const
filters
=
JSON
.
parse
(
query
.
querystring
)
as
Filter
[];
if
(
Array
.
isArray
(
filters
))
{
if
(
Array
.
isArray
(
filters
))
{
shouldShow
=
checkShouldShowMemoWithFilters
(
memo
,
filters
);
shouldShow
=
checkShouldShowMemoWithFilters
(
memo
,
filters
);
}
}
}
}
if
(
tagQuery
&&
!
memo
.
content
.
includes
(
`#${tagQuery} `
)
&&
!
memo
.
content
.
includes
(
`# ${tagQuery} `
))
{
if
(
tagQuery
)
{
shouldShow
=
false
;
const
tagsSet
=
new
Set
<
string
>
();
for
(
const
t
of
Array
.
from
(
memo
.
content
.
match
(
TAG_REG
)
??
[]))
{
const
tag
=
t
.
replace
(
TAG_REG
,
"$1"
).
trim
();
const
items
=
tag
.
split
(
"/"
);
let
temp
=
""
;
for
(
const
i
of
items
)
{
temp
+=
i
;
tagsSet
.
add
(
temp
);
temp
+=
"/"
;
}
}
if
(
!
tagsSet
.
has
(
tagQuery
))
{
shouldShow
=
false
;
}
}
}
if
(
if
(
duration
&&
duration
&&
...
...
web/src/components/TagList.tsx
View file @
6a40be9f
...
@@ -100,7 +100,7 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
...
@@ -100,7 +100,7 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
if
(
isActive
)
{
if
(
isActive
)
{
locationService
.
setTagQuery
(
""
);
locationService
.
setTagQuery
(
""
);
}
else
{
}
else
{
utils
.
copyTextToClipboard
(
`#
${
tag
.
text
}
`
);
utils
.
copyTextToClipboard
(
`#
${
tag
.
text
}
`
);
if
(
!
[
"/"
,
"/recycle"
].
includes
(
locationService
.
getState
().
pathname
))
{
if
(
!
[
"/"
,
"/recycle"
].
includes
(
locationService
.
getState
().
pathname
))
{
locationService
.
setPathname
(
"/"
);
locationService
.
setPathname
(
"/"
);
}
}
...
...
web/src/helpers/filter.ts
View file @
6a40be9f
...
@@ -119,7 +119,21 @@ export const checkShouldShowMemo = (memo: Model.Memo, filter: Filter) => {
...
@@ -119,7 +119,21 @@ export const checkShouldShowMemo = (memo: Model.Memo, filter: Filter) => {
let
shouldShow
=
true
;
let
shouldShow
=
true
;
if
(
type
===
"TAG"
)
{
if
(
type
===
"TAG"
)
{
let
contained
=
memo
.
content
.
includes
(
`#
${
value
}
`
)
||
memo
.
content
.
includes
(
`#
${
value
}
`
);
let
contained
=
true
;
const
tagsSet
=
new
Set
<
string
>
();
for
(
const
t
of
Array
.
from
(
memo
.
content
.
match
(
TAG_REG
)
??
[]))
{
const
tag
=
t
.
replace
(
TAG_REG
,
"$1"
).
trim
();
const
items
=
tag
.
split
(
"/"
);
let
temp
=
""
;
for
(
const
i
of
items
)
{
temp
+=
i
;
tagsSet
.
add
(
temp
);
temp
+=
"/"
;
}
}
if
(
!
tagsSet
.
has
(
value
))
{
contained
=
false
;
}
if
(
operator
===
"NOT_CONTAIN"
)
{
if
(
operator
===
"NOT_CONTAIN"
)
{
contained
=
!
contained
;
contained
=
!
contained
;
}
}
...
...
web/src/pages/MemoTrash.tsx
View file @
6a40be9f
...
@@ -37,8 +37,21 @@ const MemoTrash: React.FC<Props> = () => {
...
@@ -37,8 +37,21 @@ const MemoTrash: React.FC<Props> = () => {
}
}
}
}
if
(
tagQuery
&&
!
memo
.
content
.
includes
(
`# ${tagQuery}`
))
{
if
(
tagQuery
)
{
shouldShow
=
false
;
const
tagsSet
=
new
Set
<
string
>
();
for
(
const
t
of
Array
.
from
(
memo
.
content
.
match
(
TAG_REG
)
??
[]))
{
const
tag
=
t
.
replace
(
TAG_REG
,
"$1"
).
trim
();
const
items
=
tag
.
split
(
"/"
);
let
temp
=
""
;
for
(
const
i
of
items
)
{
temp
+=
i
;
tagsSet
.
add
(
temp
);
temp
+=
"/"
;
}
}
if
(
!
tagsSet
.
has
(
tagQuery
))
{
shouldShow
=
false
;
}
}
}
if
(
if
(
duration
&&
duration
&&
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment