Skip to content

Update filter to TCO20 and TCO21 #5078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"tc-ui": "^1.0.12",
"topcoder-react-lib": "1000.24.4",
"topcoder-react-lib": "1000.24.5",
"topcoder-react-ui-kit": "2.0.1",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function ChallengeFilters({
}) {
let filterRulesCount = 0;
if (filterState.groups && filterState.groups.length) filterRulesCount += 1;
if (filterState.events && filterState.events.length) filterRulesCount += 1;
if (filterState.tags && filterState.tags.length) filterRulesCount += 1;
if (filterState.types && filterState.types.length) filterRulesCount += 1;
if (filterState.endDateStart || filterState.startDateEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,21 @@ export default function FiltersPanel({
);
};

const mapCommunityOps = (community) => {
if (community.challengeFilter
&& community.challengeFilter.events && community.challengeFilter.events.length) {
return `event_${community.challengeFilter.events[0]}`;
}

return community.communityName === 'All' ? '' : community.groupIds[0];
};

const communityOps = communityFilters.filter(community => (
(!community.hidden && !community.hideFilter && !_.isEmpty(community.groupIds)) || community.communityName === 'All'
))
.map(community => ({
label: community.communityName,
value: community.communityName === 'All' ? '' : community.groupIds[0],
value: mapCommunityOps(community),
name: community.communityName,
data: getLabel(community),
}));
Expand All @@ -202,6 +211,16 @@ export default function FiltersPanel({

const mapOps = item => ({ label: item, value: item });
const mapTypes = item => ({ label: item.name, value: item.abbreviation });
const getCommunityOption = () => {
if (filterState.events && filterState.events.length) {
return `event_${filterState.events[0]}`;
}
if (filterState.groups && filterState.groups.length) {
return filterState.groups[0];
}
return '';
};

return (
<div styleName={className}>
<div styleName="header">
Expand Down Expand Up @@ -247,13 +266,26 @@ export default function FiltersPanel({
id="community-select"
// onChange={selectCommunity}
onChange={(value) => {
const group = value;
setFilterState({ ..._.clone(filterState), groups: group === '' ? [] : [group] });
if (value && value.startsWith('event_')) {
const event = value.split('_')[1];
setFilterState({
..._.clone(filterState),
events: event === '' ? [] : [event],
groups: [],
});
} else {
const group = value;
setFilterState({
..._.clone(filterState),
groups: group === '' ? [] : [group],
events: [],
});
}
// setFilterState({ ..._.clone(filterState), groups: [value] });
}}
options={communityOps}
simpleValue
value={filterState.groups && filterState.groups.length ? filterState.groups[0] : ''}
value={getCommunityOption()}
valueRenderer={option => (
<span styleName="active-community">
{option.name}
Expand Down Expand Up @@ -398,6 +430,7 @@ export default function FiltersPanel({
tags: [],
types: [],
groups: [],
events: [],
endDateStart: null,
startDateEnd: null,
});
Expand Down
3 changes: 2 additions & 1 deletion src/shared/reducers/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function onSetFilter(state, { payload }) {
* do it very carefuly (many params are not validated). */
const filter = _.pickBy(_.pick(
payload,
['tags', 'types', 'name', 'startDateEnd', 'endDateStart', 'groups', 'tracks'],
['tags', 'types', 'name', 'startDateEnd', 'endDateStart', 'groups', 'events', 'tracks'],
), value => (!_.isArray(value) && value && value !== '') || (_.isArray(value) && value.length > 0));
// if (_.isPlainObject(filter.tags)) {
// filter.tags = _.values(filter.tags);
Expand Down Expand Up @@ -854,6 +854,7 @@ function create(initialState) {
tags: [],
types: [],
groups: [],
events: [],
startDateEnd: null,
endDateStart: null,
status: 'Active',
Expand Down
2 changes: 2 additions & 0 deletions src/shared/utils/challenge-listing/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export function filterChanged(filter, prevFilter) {
|| (filter.endDateStart !== prevFilter.endDateStart)
// eslint-disable-next-line max-len
|| (!_.isEqual(filter.groups, prevFilter.groups))
|| (!_.isEqual(filter.events, prevFilter.events))
|| _.filter(filter.tags, val => _.indexOf(prevFilter.tags, val) < 0).length > 0
|| _.filter(prevFilter.tags, val => _.indexOf(filter.tags, val) < 0).length > 0
|| _.filter(filter.types, val => _.indexOf(prevFilter.types, val) < 0).length > 0
Expand Down Expand Up @@ -204,6 +205,7 @@ export function isFilterEmpty(filter) {
tags: [],
types: [],
groups: [],
events: [],
startDateStart: null,
endDateEnd: null,
status: 'Active',
Expand Down