-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
杨国璇
authored and
杨国璇
committed
Aug 16, 2024
1 parent
0142fe4
commit 7a47c64
Showing
46 changed files
with
899 additions
and
74 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
54 changes: 54 additions & 0 deletions
54
frontend/src/metadata/metadata-view/_basic/utils/filter/filter-column/multiple-select.js
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,54 @@ | ||
import { FILTER_PREDICATE_TYPE } from '../../../constants/filter/filter-predicate'; | ||
|
||
/** | ||
* Filter multiple-select | ||
* @param {array} optionIds e.g. [ option.id, ... ] | ||
* @param {string} filter_predicate | ||
* @param {array} filter_term option ids | ||
* @returns bool | ||
*/ | ||
const multipleSelectFilter = (optionIds, { filter_predicate, filter_term }) => { | ||
switch (filter_predicate) { | ||
case FILTER_PREDICATE_TYPE.HAS_ANY_OF: { | ||
return ( | ||
filter_term.length === 0 | ||
|| (Array.isArray(optionIds) && optionIds.some((optionId) => filter_term.includes(optionId))) | ||
); | ||
} | ||
case FILTER_PREDICATE_TYPE.HAS_ALL_OF: { | ||
return ( | ||
filter_term.length === 0 | ||
|| (Array.isArray(optionIds) && filter_term.every((optionId) => optionIds.includes(optionId))) | ||
); | ||
} | ||
case FILTER_PREDICATE_TYPE.HAS_NONE_OF: { | ||
if (filter_term.length === 0 || !Array.isArray(optionIds) || optionIds.length === 0) { | ||
return true; | ||
} | ||
return filter_term.every((optionId) => optionIds.indexOf(optionId) < 0); | ||
} | ||
case FILTER_PREDICATE_TYPE.IS_EXACTLY: { | ||
if (filter_term.length === 0) { | ||
return true; | ||
} | ||
if (!Array.isArray(optionIds)) { | ||
return false; | ||
} | ||
const uniqueArr = (arr) => [...new Set(arr)].sort(); | ||
return uniqueArr(optionIds).toString() === uniqueArr(filter_term).toString(); | ||
} | ||
case FILTER_PREDICATE_TYPE.EMPTY: { | ||
return !Array.isArray(optionIds) || optionIds.length === 0; | ||
} | ||
case FILTER_PREDICATE_TYPE.NOT_EMPTY: { | ||
return Array.isArray(optionIds) && optionIds.length > 0; | ||
} | ||
default: { | ||
return false; | ||
} | ||
} | ||
}; | ||
|
||
export { | ||
multipleSelectFilter, | ||
}; |
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
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
Oops, something went wrong.