Skip to content

Commit 229ed9a

Browse files
integrate sub-community filter
1 parent 0e84539 commit 229ed9a

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ exports[`Matches shallow shapshot 1`] = `
8181
autoBlur={true}
8282
clearable={false}
8383
id="community-select"
84-
onChange={[MockFunction]}
84+
onChange={[Function]}
8585
options={
8686
Array [
8787
Object {
@@ -96,7 +96,6 @@ exports[`Matches shallow shapshot 1`] = `
9696
}
9797
selectRef={[Function]}
9898
simpleValue={true}
99-
value="1"
10099
valueRenderer={[Function]}
101100
/>
102101
</div>
@@ -277,7 +276,7 @@ exports[`Matches shallow shapshot 2`] = `
277276
autoBlur={true}
278277
clearable={false}
279278
id="community-select"
280-
onChange={[MockFunction]}
279+
onChange={[Function]}
281280
options={
282281
Array [
283282
Object {
@@ -292,7 +291,6 @@ exports[`Matches shallow shapshot 2`] = `
292291
}
293292
selectRef={[Function]}
294293
simpleValue={true}
295-
value="1"
296294
valueRenderer={[Function]}
297295
/>
298296
</div>

src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function FiltersPanel({
5151
onClose,
5252
// onSaveFilter,
5353
selectCommunity,
54-
selectedCommunityId,
54+
// selectedCommunityId,
5555
setFilterState,
5656
setSearchText,
5757
validKeywords,
@@ -238,10 +238,14 @@ export default function FiltersPanel({
238238
autoBlur
239239
clearable={false}
240240
id="community-select"
241-
onChange={selectCommunity}
241+
// onChange={selectCommunity}
242+
onChange={(value) => {
243+
const group = value;
244+
setFilterState({ ..._.clone(filterState), group });
245+
}}
242246
options={communityOps}
243247
simpleValue
244-
value={selectedCommunityId}
248+
value={filterState.group}
245249
valueRenderer={option => (
246250
<span styleName="active-community">
247251
{option.name}
@@ -351,7 +355,7 @@ export default function FiltersPanel({
351355
name: '',
352356
tags: [],
353357
types: [],
354-
communityId: 'All',
358+
group: '',
355359
startDateStart: null,
356360
endDateEnd: null,
357361
});
@@ -403,7 +407,7 @@ FiltersPanel.propTypes = {
403407
isReviewOpportunitiesBucket: PT.bool,
404408
// onSaveFilter: PT.func,
405409
selectCommunity: PT.func.isRequired,
406-
selectedCommunityId: PT.string.isRequired,
410+
// selectedCommunityId: PT.string.isRequired,
407411
setFilterState: PT.func.isRequired,
408412
setSearchText: PT.func.isRequired,
409413
validKeywords: PT.arrayOf(PT.string).isRequired,

src/shared/reducers/challenge-listing/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ function onSelectCommunity(state, { payload }) {
381381
* the code simple we just reset them each time a filter is modified.
382382
* (This community selection defines community-specific filter for
383383
* challenges). */
384-
allPastChallengesLoaded: false,
385-
lastRequestedPageOfPastChallenges: -1,
384+
// allPastChallengesLoaded: false,
385+
// lastRequestedPageOfPastChallenges: -1,
386386
// pastSearchTimestamp: -1,
387387
};
388388
}
@@ -400,7 +400,7 @@ function onSetFilter(state, { payload }) {
400400
* do it very carefuly (many params are not validated). */
401401
const filter = _.pickBy(_.pick(
402402
payload,
403-
['tags', 'types', 'name', 'startDateStart', 'endDateEnd'],
403+
['tags', 'types', 'name', 'startDateStart', 'endDateEnd', 'group'],
404404
), value => (!_.isArray(value) && value && value !== '') || (_.isArray(value) && value.length > 0));
405405
// if (_.isPlainObject(filter.tags)) {
406406
// filter.tags = _.values(filter.tags);
@@ -802,7 +802,7 @@ function create(initialState) {
802802
name: '',
803803
tags: [],
804804
types: [],
805-
communityId: 'All',
805+
group: '',
806806
startDateStart: null,
807807
endDateEnd: null,
808808
},

src/shared/utils/challenge-listing/buckets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export function filterChanged(filter, prevFilter) {
174174
|| (filter.name !== prevFilter.name)
175175
|| (filter.startDateStart !== prevFilter.startDateStart)
176176
|| (filter.endDateEnd !== prevFilter.endDateEnd)
177+
|| (filter.group !== prevFilter.group)
177178
|| _.filter(filter.tags, val => _.indexOf(prevFilter.tags, val) < 0).length > 0
178179
|| _.filter(prevFilter.tags, val => _.indexOf(filter.tags, val) < 0).length > 0
179180
|| _.filter(filter.types, val => _.indexOf(prevFilter.types, val) < 0).length > 0

src/shared/utils/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function updateQuery(update) {
4747
* fields in the target object. */
4848
_.forIn(update, (value, key) => {
4949
if (_.isArray(value)) filterArray.push(value.map(item => `${key}[]=${item}`).join('&'));
50-
else if (_.isUndefined(value)) delete query[key];
50+
else if (_.isUndefined(value) || _.isEmpty(value)) delete query[key];
5151
else query += `${key}=${value}`;
5252
});
5353
if (query === '?') {

0 commit comments

Comments
 (0)