-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lowercase operators support in the where clause is updated (#3657)
* feat: lowercase operators suuport in the where clause is updated * feat: options is now updated * chore: log message is updated * chore: auto completed is updated * chore: tagRegex is updated * feat: update regex to math operators and text operators * chore: operator is updated * chore: options is updated --------- Co-authored-by: Yunus A M <[email protected]>
- Loading branch information
1 parent
587034f
commit 0e04b77
Showing
7 changed files
with
81 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 13 additions & 21 deletions
34
frontend/src/hooks/queryBuilder/useSetCurrentKeyAndOperator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
import { | ||
getRemovePrefixFromKey, | ||
getTagToken, | ||
} from 'container/QueryBuilder/filters/QueryBuilderSearch/utils'; | ||
import { useMemo } from 'react'; | ||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; | ||
import { getTagToken } from 'container/QueryBuilder/filters/QueryBuilderSearch/utils'; | ||
import { useMemo, useRef } from 'react'; | ||
|
||
type ICurrentKeyAndOperator = [string, string, string[]]; | ||
|
||
export const useSetCurrentKeyAndOperator = ( | ||
value: string, | ||
keys: BaseAutocompleteData[], | ||
): ICurrentKeyAndOperator => { | ||
const [key, operator, result] = useMemo(() => { | ||
let key = ''; | ||
let operator = ''; | ||
const keyRef = useRef<string>(''); | ||
const operatorRef = useRef<string>(''); | ||
|
||
const result = useMemo(() => { | ||
let result: string[] = []; | ||
const { tagKey, tagOperator, tagValue } = getTagToken(value); | ||
const isSuggestKey = keys?.some( | ||
(el) => el?.key === getRemovePrefixFromKey(tagKey), | ||
); | ||
if (isSuggestKey || keys.length === 0) { | ||
key = tagKey || ''; | ||
operator = tagOperator || ''; | ||
result = tagValue || []; | ||
} | ||
|
||
return [key, operator, result]; | ||
}, [value, keys]); | ||
keyRef.current = tagKey || ''; | ||
operatorRef.current = tagOperator || ''; | ||
result = tagValue || []; | ||
|
||
return result; | ||
}, [value]); | ||
|
||
return [key, operator, result]; | ||
return [keyRef.current, operatorRef.current, result]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters