Set the default select value for filterOptions (#4221)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Fixes https://github.com/mattermost/focalboard/issues/4206
This commit is contained in:
Rajat Dabade 2022-11-24 13:00:37 +05:30 committed by GitHub
parent 4051e1eb05
commit 77c798cc7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 20 deletions

View file

@ -1013,7 +1013,7 @@ exports[`components/viewHeader/filterComponent return filterComponent and filter
type="button"
>
<span>
includes
(unknown)
</span>
</button>
</div>

View file

@ -1499,7 +1499,7 @@ exports[`components/viewHeader/filterEntry return filterEntry and click on statu
type="button"
>
<span>
includes
(unknown)
</span>
</button>
</div>

View file

@ -84,7 +84,7 @@ const FilterEntry = (props: Props): JSX.Element => {
</Menu>
</MenuWrapper>
<MenuWrapper>
<Button>{OctoUtils.filterConditionDisplayString(filter.condition, intl)}</Button>
<Button>{OctoUtils.filterConditionDisplayString(filter.condition, intl, propertyType.filterValueType)}</Button>
<Menu>
{propertyType.filterValueType === 'options' &&
<>

View file

@ -102,26 +102,42 @@ class OctoUtils {
return [newBlocks, newSourceBlock, idMap]
}
static filterConditionDisplayString(filterCondition: FilterCondition, intl: IntlShape): string {
switch (filterCondition) {
case 'includes': return intl.formatMessage({id: 'Filter.includes', defaultMessage: 'includes'})
case 'notIncludes': return intl.formatMessage({id: 'Filter.not-includes', defaultMessage: 'doesn\'t include'})
case 'isEmpty': return intl.formatMessage({id: 'Filter.is-empty', defaultMessage: 'is empty'})
case 'isNotEmpty': return intl.formatMessage({id: 'Filter.is-not-empty', defaultMessage: 'is not empty'})
case 'isSet': return intl.formatMessage({id: 'Filter.is-set', defaultMessage: 'is set'})
case 'isNotSet': return intl.formatMessage({id: 'Filter.is-not-set', defaultMessage: 'is not set'})
case 'is': return intl.formatMessage({id: 'Filter.is', defaultMessage: 'is'})
case 'contains': return intl.formatMessage({id: 'Filter.contains', defaultMessage: 'contains'})
case 'notContains': return intl.formatMessage({id: 'Filter.not-contains', defaultMessage: 'doesn\'t contain'})
case 'startsWith': return intl.formatMessage({id: 'Filter.starts-with', defaultMessage: 'starts with'})
case 'notStartsWith': return intl.formatMessage({id: 'Filter.not-starts-with', defaultMessage: 'doesn\'t start with'})
case 'endsWith': return intl.formatMessage({id: 'Filter.ends-with', defaultMessage: 'ends with'})
case 'notEndsWith': return intl.formatMessage({id: 'Filter.not-ends-with', defaultMessage: 'doesn\'t end with'})
default: {
static filterConditionDisplayString(filterCondition: FilterCondition, intl: IntlShape, filterValueType: string): string {
if (filterValueType === 'options') {
switch (filterCondition) {
case 'includes': return intl.formatMessage({id: 'Filter.includes', defaultMessage: 'includes'})
case 'notIncludes': return intl.formatMessage({id: 'Filter.not-includes', defaultMessage: 'doesn\'t include'})
case 'isEmpty': return intl.formatMessage({id: 'Filter.is-empty', defaultMessage: 'is empty'})
case 'isNotEmpty': return intl.formatMessage({id: 'Filter.is-not-empty', defaultMessage: 'is not empty'})
default: {
return intl.formatMessage({id: 'Filter.includes', defaultMessage: 'includes'})
}
}
} else if (filterValueType === 'boolean') {
switch (filterCondition) {
case 'isSet': return intl.formatMessage({id: 'Filter.is-set', defaultMessage: 'is set'})
case 'isNotSet': return intl.formatMessage({id: 'Filter.is-not-set', defaultMessage: 'is not set'})
default: {
return intl.formatMessage({id: 'Filter.is-set', defaultMessage: 'is set'})
}
}
} else if (filterValueType === 'text') {
switch (filterCondition) {
case 'is': return intl.formatMessage({id: 'Filter.is', defaultMessage: 'is'})
case 'contains': return intl.formatMessage({id: 'Filter.contains', defaultMessage: 'contains'})
case 'notContains': return intl.formatMessage({id: 'Filter.not-contains', defaultMessage: 'doesn\'t contain'})
case 'startsWith': return intl.formatMessage({id: 'Filter.starts-with', defaultMessage: 'starts with'})
case 'notStartsWith': return intl.formatMessage({id: 'Filter.not-starts-with', defaultMessage: 'doesn\'t start with'})
case 'endsWith': return intl.formatMessage({id: 'Filter.ends-with', defaultMessage: 'ends with'})
case 'notEndsWith': return intl.formatMessage({id: 'Filter.not-ends-with', defaultMessage: 'doesn\'t end with'})
default: {
return intl.formatMessage({id: 'Filter.is', defaultMessage: 'is'})
}
}
} else {
Utils.assertFailure()
return '(unknown)'
}
}
}
}