From b9598b8d6008511cd4823b552c4736b4597b5564 Mon Sep 17 00:00:00 2001 From: bstetzer32 <64655856+bstetzer32@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:35:56 -0500 Subject: [PATCH] feat: add options for any-tag-set and tag-not-set (#227) * feat: add options for any-tag-set and tag-not-set * feat: add options for any-tag-set and tag-not-set * feat: add options for any-tag-set and tag-not-set * feat: add options for any-tag-set and tag-not-set * fix: removed comments and fixed MUI error Co-authored-by: Nick Charlton --- src/components/Filter.css | 6 ++++++ src/components/FilterTop.js | 28 ++++++++++++++++------------ src/models/Filter.js | 3 +++ 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 src/components/Filter.css diff --git a/src/components/Filter.css b/src/components/Filter.css new file mode 100644 index 000000000..78768ef67 --- /dev/null +++ b/src/components/Filter.css @@ -0,0 +1,6 @@ +/* Option A for divider for verify tool tag filter */ +#tag-option-1 { + border-bottom: 1px solid rgba(0, 0, 0, 0.54); + padding-bottom: 16px; + margin-bottom: 16px; +} diff --git a/src/components/FilterTop.js b/src/components/FilterTop.js index 42e805b83..1a70e9abf 100644 --- a/src/components/FilterTop.js +++ b/src/components/FilterTop.js @@ -10,7 +10,8 @@ import FilterModel, { SPECIES_NOT_SET, ALL_ORGANIZATIONS, ORGANIZATION_NOT_SET, - // TAG_NOT_SET, + TAG_NOT_SET, + ANY_TAG_SET, } from '../models/Filter'; import DateFnsUtils from '@date-io/date-fns'; import { @@ -348,12 +349,18 @@ function Filter(props) { inputRoot: classes.autocompleteInputRoot, }} options={[ - // { - // id: TAG_NOT_SET, - // tagName: 'Not set', - // active: true, - // public: true, - // }, + { + id: TAG_NOT_SET, + tagName: 'Not set', + active: true, + public: true, + }, + { + id: ANY_TAG_SET, + tagName: 'Any tag set', + active: true, + public: true, + }, ...tagsContext.tagList.filter((t) => t.tagName .toLowerCase() @@ -371,11 +378,7 @@ function Filter(props) { onChange={(_oldVal, newVal) => { //triggered by onInputChange console.log('newVal -- ', newVal); - if (newVal && newVal.tagName === 'Not set') { - setTag('Not set'); - } else { - setTag(newVal); - } + setTag(newVal); }} onInputChange={(_oldVal, newVal) => { setTagSearchString(newVal); @@ -383,6 +386,7 @@ function Filter(props) { renderInput={(params) => { return ; }} + getOptionSelected={(option, value) => option.id === value.id} // selectOnFocus // clearOnBlur // handleHomeEndKeys diff --git a/src/models/Filter.js b/src/models/Filter.js index d49e2f6d5..3e639ff04 100644 --- a/src/models/Filter.js +++ b/src/models/Filter.js @@ -7,6 +7,7 @@ export const SPECIES_NOT_SET = 'SPECIES_NOT_SET'; export const ALL_ORGANIZATIONS = 'ALL_ORGANIZATIONS'; export const ORGANIZATION_NOT_SET = 'ORGANIZATION_NOT_SET'; export const TAG_NOT_SET = 'TAG_NOT_SET'; +export const ANY_TAG_SET = 'ANY_TAG_SET'; import { tokenizationStates } from '../common/variables'; export default class Filter { @@ -81,6 +82,8 @@ export default class Filter { if (this.tagId === TAG_NOT_SET) { where.tagId = null; + } else if (this.tagId === ANY_TAG_SET) { + where.tagId = '0'; } else if (this.tagId) { where.tagId = this.tagId; }