-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update hideFromReadData field to accept an array of strings and…
… implement condition comparison logic
- Loading branch information
1 parent
0479097
commit 35717ca
Showing
12 changed files
with
56 additions
and
46 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
frontend/webapp/utils/functions/resolvers/compare-condition/index.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const compareCondition = (renderCondition: string[], fields: { name: string; value: any }[]) => { | ||
if (!renderCondition || !renderCondition.length) return true; | ||
if (renderCondition.length === 1) return renderCondition[0] == 'true'; | ||
|
||
const [key, cond, val] = renderCondition; | ||
const field = fields.find((field) => field.name === key); | ||
|
||
if (!field) { | ||
console.warn(`Field with name ${key} not found, condition will be skipped`); | ||
return true; | ||
} | ||
|
||
switch (cond) { | ||
case '===': | ||
case '==': | ||
return field.value === val; | ||
case '!==': | ||
case '!=': | ||
return field.value !== val; | ||
case '>': | ||
return field.value > val; | ||
case '<': | ||
return field.value < val; | ||
case '>=': | ||
return field.value >= val; | ||
case '<=': | ||
return field.value <= val; | ||
default: | ||
console.warn(`Invalid condition ${cond}, condition will be skipped`); | ||
return true; | ||
} | ||
}; |
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 +1,2 @@ | ||
export * from './compare-condition'; | ||
export * from './get-value-for-range'; |