Skip to content

Feature refactor challengelist #5067

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 2 commits into from
Oct 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default function ChallengeFilters({
if (filterState.groups && filterState.groups.length) filterRulesCount += 1;
if (filterState.tags && filterState.tags.length) filterRulesCount += 1;
if (filterState.types && filterState.types.length) filterRulesCount += 1;
if (filterState.endDateEnd || filterState.startDateStart) filterRulesCount += 1;
if (filterState.endDateStart || filterState.startDateEnd) {
filterRulesCount += 1;
}
if (isReviewOpportunitiesBucket && filterState.reviewOpportunityType) filterRulesCount += 1;
if (selectedCommunityId !== '' && selectedCommunityId !== 'All') filterRulesCount += 1;
const isTrackOn = track => filterState.tracks[track];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,21 @@ export default function FiltersPanel({
</label>
<DateRangePicker
numberOfMonths={1}
endDate={filterState.endDateEnd && moment(filterState.endDateEnd)}
endDate={filterState.startDateEnd && moment(filterState.startDateEnd)}
id="date-range-picker-one-month"
onDatesChange={(dates) => {
const d = dates.endDate ? dates.endDate.toISOString() : null;
const s = dates.startDate ? dates.startDate.toISOString() : null;
setFilterState({ ..._.clone(filterState), startDateStart: s, endDateEnd: d });
setFilterState({
..._.clone(filterState),
endDateStart: s,
startDateEnd: d,
});
}}
startDate={filterState.startDateStart && moment(filterState.startDateStart)}
startDate={
filterState.endDateStart
&& moment(filterState.endDateStart)
}
/>
</div>
<div styleName="filter dates hideonemonthdatepicker">
Expand All @@ -328,15 +335,20 @@ export default function FiltersPanel({
</label>
<DateRangePicker
numberOfMonths={2}
endDate={filterState.endDateEnd && moment(filterState.endDateEnd)}
endDate={filterState.startDateEnd && moment(filterState.startDateEnd)}
id="date-range-picker-two-months"
onDatesChange={(dates) => {
const d = dates.endDate ? dates.endDate.toISOString() : null;
const s = dates.startDate ? dates.startDate.toISOString() : null;
setFilterState({ ..._.clone(filterState), startDateStart: s, endDateEnd: d });
setFilterState({
..._.clone(filterState),
endDateStart: s,
startDateEnd: d,
});
}}
startDate={
filterState.startDateStart && moment(filterState.startDateStart)
filterState.endDateStart
&& moment(filterState.endDateStart)
}
/>
</div>
Expand All @@ -358,8 +370,8 @@ export default function FiltersPanel({
tags: [],
types: [],
groups: [],
startDateStart: null,
endDateEnd: null,
endDateStart: null,
startDateEnd: null,
});
selectCommunity(defaultCommunityId);
setSearchText('');
Expand Down
14 changes: 7 additions & 7 deletions src/shared/reducers/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,19 @@ function onSetFilter(state, { payload }) {
* do it very carefuly (many params are not validated). */
const filter = _.pickBy(_.pick(
payload,
['tags', 'types', 'name', 'startDateStart', 'endDateEnd', 'groups'],
['tags', 'types', 'name', 'startDateEnd', 'endDateStart', 'groups'],
), value => (!_.isArray(value) && value && value !== '') || (_.isArray(value) && value.length > 0));
// if (_.isPlainObject(filter.tags)) {
// filter.tags = _.values(filter.tags);
// }
// if (_.isPlainObject(filter.subtracks)) {
// filter.subtracks = _.values(filter.subtracks);
// }
if (filter.startDateStart && !moment(filter.startDateStart).isValid()) {
delete filter.startDateStart;
if (filter.startDateEnd && !moment(filter.startDateEnd).isValid()) {
delete filter.startDateEnd;
}
if (filter.endDateEnd && !moment(filter.endDateEnd).isValid()) {
delete filter.endDateEnd;
if (filter.endDateStart && !moment(filter.endDateStart).isValid()) {
delete filter.endDateStart;
}
// console.log(`aaaaa`);
// console.log(filter);
Expand Down Expand Up @@ -810,8 +810,8 @@ function create(initialState) {
tags: [],
types: [],
groups: [],
startDateStart: null,
endDateEnd: null,
startDateEnd: null,
endDateStart: null,
},

selectedCommunityId: 'All',
Expand Down
4 changes: 2 additions & 2 deletions src/shared/utils/challenge-listing/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export function filterChanged(filter, prevFilter) {
|| (filter.tracks.DS !== prevFilter.tracks.DS)
|| (filter.tracks.QA !== prevFilter.tracks.QA)
|| (filter.name !== prevFilter.name)
|| (filter.startDateStart !== prevFilter.startDateStart)
|| (filter.endDateEnd !== prevFilter.endDateEnd)
|| (filter.startDateEnd !== prevFilter.startDateEnd)
|| (filter.endDateStart !== prevFilter.endDateStart)
// eslint-disable-next-line max-len
|| (filter.groups.length !== prevFilter.groups.length || filter.groups[0] !== prevFilter.groups[0])
|| _.filter(filter.tags, val => _.indexOf(prevFilter.tags, val) < 0).length > 0
Expand Down