chore: filter empty state handling in issue filter selection

This commit is contained in:
gurusainath 2023-09-14 22:34:44 +05:30
parent 3c9e62d308
commit fce6907465
6 changed files with 12 additions and 6 deletions

View File

@ -33,12 +33,13 @@ export const FilterAssignees = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};

View File

@ -16,12 +16,13 @@ export const FilterCreatedBy = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};

View File

@ -21,12 +21,13 @@ export const FilterLabels = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};

View File

@ -57,12 +57,13 @@ export const FilterPriority = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};

View File

@ -88,12 +88,13 @@ export const FilterStateGroup = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};

View File

@ -18,12 +18,13 @@ export const FilterState = observer(() => {
const [previewEnabled, setPreviewEnabled] = React.useState(true);
const handleFilter = (key: string, value: string) => {
const _value =
let _value =
issueFilterStore?.userFilters?.filters?.[key] != null
? issueFilterStore?.userFilters?.filters?.[key].includes(value)
? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value)
: [...issueFilterStore?.userFilters?.filters?.[key], value]
: [value];
_value = _value && _value.length > 0 ? _value : null;
issueFilterStore.handleUserFilter("filters", key, _value);
};