From 84a0ee2a6c5ed2d1414d976bfb5608e53352c54e Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Mon, 15 Jul 2024 11:12:05 -0500 Subject: [PATCH 1/5] add global toggle to find challenge page and include the show archived filter in the challenge result list --- src/components/ChallengePane/ChallengePane.jsx | 16 +++++++++++++--- src/components/ChallengePane/Messages.js | 5 +++++ .../WithFilteredChallenges.jsx | 4 +++- .../HOCs/WithSearchRoute/WithSearchRoute.jsx | 3 ++- src/services/Challenge/Challenge.js | 4 ++++ .../ChallengeArchived/ChallengeArchived.js | 10 +++++----- .../Challenge/ChallengeGlobal/ChallengeGlobal.js | 7 +++++++ src/services/Search/Search.js | 6 +++++- 8 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js diff --git a/src/components/ChallengePane/ChallengePane.jsx b/src/components/ChallengePane/ChallengePane.jsx index bbe6851d2..cce7ba8cb 100644 --- a/src/components/ChallengePane/ChallengePane.jsx +++ b/src/components/ChallengePane/ChallengePane.jsx @@ -31,7 +31,7 @@ import TaskChallengeMarkerContent from './TaskChallengeMarkerContent' import StartVirtualChallenge from './StartVirtualChallenge/StartVirtualChallenge' import messages from './Messages' -const ShowArchivedToggleInternal = (props) => { +const ShowChallengeListTogglesInternal = (props) => { return (
{ }} />
+ { + props.setSearchFilters({ filterGlobal: !props.filteringGlobal }) + }} + /> +
) } -const ShowArchivedToggle = WithChallengeSearch(ShowArchivedToggleInternal); +const ShowChallengeListToggles = WithChallengeSearch(ShowChallengeListTogglesInternal); // Setup child components with necessary HOCs const ChallengeResults = WithStatus(ChallengeResultList) @@ -118,6 +127,7 @@ export class ChallengePane extends Component { render() { const showingArchived = this.props.history.location.search.includes("archived=true"); + const filteringGlobal = this.props.history.location.search.includes("filterGlobal") ? this.props.history.location.search.includes("filterGlobal=true") : true; const challengeStatus = [ChallengeStatus.ready, ChallengeStatus.partiallyLoaded, ChallengeStatus.none, @@ -156,7 +166,7 @@ export class ChallengePane extends Component {
- +
diff --git a/src/components/ChallengePane/Messages.js b/src/components/ChallengePane/Messages.js index 6382278aa..f7d2d16f0 100644 --- a/src/components/ChallengePane/Messages.js +++ b/src/components/ChallengePane/Messages.js @@ -37,5 +37,10 @@ export default defineMessages({ showArchivedLabel: { id: "ChallengePane.controls.showArchived.label", defaultMessage: "Show Archived" + }, + + showGlobalLabel: { + id: "ChallengePane.controls.showGlobal.label", + defaultMessage: "Show Global Challenges" } }) diff --git a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx index 83682defa..5d5fbaada 100644 --- a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx +++ b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx @@ -11,13 +11,15 @@ import { challengePassesCategorizationKeywordsFilter } from '../../../services/Challenge/ChallengeCategorizationKeywords/ChallengeCategorizationKeywords'; import { challengePassesLocationFilter } from '../../../services/Challenge/ChallengeLocation/ChallengeLocation' +import { challengePassesGlobalFilter } + from '../../../services/Challenge/ChallengeGlobal/ChallengeGlobal' import { challengePassesArchivedFilter } from '../../../services/Challenge/ChallengeArchived/ChallengeArchived' import { challengePassesProjectFilter } from '../../../services/Challenge/ChallengeProject/ChallengeProject' const allFilters = [ - challengePassesArchivedFilter, + challengePassesGlobalFilter,challengePassesArchivedFilter, challengePassesDifficultyFilter, challengePassesKeywordFilter, challengePassesCategorizationKeywordsFilter, diff --git a/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx b/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx index bb2544e0f..e739f2cc2 100644 --- a/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx +++ b/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx @@ -37,7 +37,8 @@ export const WithSearchRoute = function(WrappedComponent, searchGroup) { project: param => this.props.setSearchFilters({project: param, searchType: SEARCH_TYPE_PROJECT}), query: param => this.props.setSearch(param), challengeSearch: param => this.props.setChallengeSearchMapBounds(toLatLngBounds(param), true), - archived: param => this.props.setSearchFilters({ archived: param === "true" }) + archived: param => this.props.setSearchFilters({ archived: param === "true" }), + filterGlobal: param => this.props.setSearchFilters({ filterGlobal: param === "true" }) } state = { diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index cd594436c..c87fcdc15 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -443,6 +443,10 @@ export const extendedFind = function (criteria, limit = RESULTS_PER_PAGE, admin queryParams.ca = filters.archived; } + if (filters.filterGlobal) { + queryParams.fg = filters.filterGlobal; + } + // Keywords/tags can come from both the the query and the filter, so we need to // combine them into a single keywords array. const keywords = queryParts.tagTokens.concat( diff --git a/src/services/Challenge/ChallengeArchived/ChallengeArchived.js b/src/services/Challenge/ChallengeArchived/ChallengeArchived.js index 84b2ff7a0..2f48987af 100644 --- a/src/services/Challenge/ChallengeArchived/ChallengeArchived.js +++ b/src/services/Challenge/ChallengeArchived/ChallengeArchived.js @@ -1,7 +1,7 @@ export const challengePassesArchivedFilter = function(filter, challenge) { - if (!filter.archived) { - return challenge.isArchived === false - } - - return true + if (!filter.archived) { + return challenge.isArchived === false } + + return true +} diff --git a/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js new file mode 100644 index 000000000..50c60a35e --- /dev/null +++ b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js @@ -0,0 +1,7 @@ +export const challengePassesGlobalFilter = function(filter, challenge) { + if (filter.filterGlobal) { + return challenge.isGlobal === false + } + + return true +} diff --git a/src/services/Search/Search.js b/src/services/Search/Search.js index 888edc28a..0e5724166 100644 --- a/src/services/Search/Search.js +++ b/src/services/Search/Search.js @@ -95,7 +95,8 @@ export const PARAMS_MAP = { difficulty: 'cd', tags: 'tt', excludeTasks: 'tExcl', - archived: "ca" + archived: "ca", + filterGlobal: "fg" } @@ -158,6 +159,9 @@ export const generateSearchParametersString = (filters, boundingBox, savedChalle if (filters.archived) { searchParameters[PARAMS_MAP.archived] = filters.archived; } + if (filters.filterGlobal) { + searchParameters[PARAMS_MAP.filterGlobal] = filters.filterGlobal; + } if (filters.reviewRequestedBy) { searchParameters[PARAMS_MAP.reviewRequestedBy] = filters.reviewRequestedBy if (invertFields.reviewRequestedBy) { From 8eee166d4d375007907cef4e09f9ad49b6941ac3 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Sun, 11 Aug 2024 21:08:41 -0500 Subject: [PATCH 2/5] remove archived filter fix --- src/components/ChallengePane/ChallengePane.jsx | 4 ++-- .../HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx | 4 +--- .../Challenge/ChallengeArchived/ChallengeArchived.js | 7 ------- 3 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 src/services/Challenge/ChallengeArchived/ChallengeArchived.js diff --git a/src/components/ChallengePane/ChallengePane.jsx b/src/components/ChallengePane/ChallengePane.jsx index cce7ba8cb..762064fbd 100644 --- a/src/components/ChallengePane/ChallengePane.jsx +++ b/src/components/ChallengePane/ChallengePane.jsx @@ -46,7 +46,7 @@ const ShowChallengeListTogglesInternal = (props) => { { props.setSearchFilters({ filterGlobal: !props.filteringGlobal }) }} @@ -127,7 +127,7 @@ export class ChallengePane extends Component { render() { const showingArchived = this.props.history.location.search.includes("archived=true"); - const filteringGlobal = this.props.history.location.search.includes("filterGlobal") ? this.props.history.location.search.includes("filterGlobal=true") : true; + const filteringGlobal = this.props.history.location.search.includes("filterGlobal=true") const challengeStatus = [ChallengeStatus.ready, ChallengeStatus.partiallyLoaded, ChallengeStatus.none, diff --git a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx index 5d5fbaada..879d9b736 100644 --- a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx +++ b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx @@ -13,13 +13,11 @@ import { challengePassesLocationFilter } from '../../../services/Challenge/ChallengeLocation/ChallengeLocation' import { challengePassesGlobalFilter } from '../../../services/Challenge/ChallengeGlobal/ChallengeGlobal' -import { challengePassesArchivedFilter } - from '../../../services/Challenge/ChallengeArchived/ChallengeArchived' import { challengePassesProjectFilter } from '../../../services/Challenge/ChallengeProject/ChallengeProject' const allFilters = [ - challengePassesGlobalFilter,challengePassesArchivedFilter, + challengePassesGlobalFilter, challengePassesDifficultyFilter, challengePassesKeywordFilter, challengePassesCategorizationKeywordsFilter, diff --git a/src/services/Challenge/ChallengeArchived/ChallengeArchived.js b/src/services/Challenge/ChallengeArchived/ChallengeArchived.js deleted file mode 100644 index 2f48987af..000000000 --- a/src/services/Challenge/ChallengeArchived/ChallengeArchived.js +++ /dev/null @@ -1,7 +0,0 @@ -export const challengePassesArchivedFilter = function(filter, challenge) { - if (!filter.archived) { - return challenge.isArchived === false - } - - return true -} From d6ded0900416f7c011a6872ab613a7f5cf732ea8 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Fri, 15 Nov 2024 13:26:37 -0600 Subject: [PATCH 3/5] add archived filter back --- .../HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx | 3 +++ .../Challenge/ChallengeArchived/ChallengeArchived.js | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 src/services/Challenge/ChallengeArchived/ChallengeArchived.js diff --git a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx index 879d9b736..fb80d7292 100644 --- a/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx +++ b/src/components/HOCs/WithFilteredChallenges/WithFilteredChallenges.jsx @@ -11,12 +11,15 @@ import { challengePassesCategorizationKeywordsFilter } from '../../../services/Challenge/ChallengeCategorizationKeywords/ChallengeCategorizationKeywords'; import { challengePassesLocationFilter } from '../../../services/Challenge/ChallengeLocation/ChallengeLocation' +import { challengePassesArchivedFilter } + from '../../../services/Challenge/ChallengeArchived/ChallengeArchived' import { challengePassesGlobalFilter } from '../../../services/Challenge/ChallengeGlobal/ChallengeGlobal' import { challengePassesProjectFilter } from '../../../services/Challenge/ChallengeProject/ChallengeProject' const allFilters = [ + challengePassesArchivedFilter, challengePassesGlobalFilter, challengePassesDifficultyFilter, challengePassesKeywordFilter, diff --git a/src/services/Challenge/ChallengeArchived/ChallengeArchived.js b/src/services/Challenge/ChallengeArchived/ChallengeArchived.js new file mode 100644 index 000000000..2f48987af --- /dev/null +++ b/src/services/Challenge/ChallengeArchived/ChallengeArchived.js @@ -0,0 +1,7 @@ +export const challengePassesArchivedFilter = function(filter, challenge) { + if (!filter.archived) { + return challenge.isArchived === false + } + + return true +} From 4f49a99f6784c128e8fdbc1c581473f18b02ed69 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 3 Dec 2024 14:19:30 -0600 Subject: [PATCH 4/5] fix naming conventions --- src/components/ChallengePane/ChallengePane.jsx | 8 ++++---- src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx | 2 +- src/services/Challenge/Challenge.js | 4 ++-- src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js | 2 +- src/services/Search/Search.js | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/ChallengePane/ChallengePane.jsx b/src/components/ChallengePane/ChallengePane.jsx index 762064fbd..e629a5c98 100644 --- a/src/components/ChallengePane/ChallengePane.jsx +++ b/src/components/ChallengePane/ChallengePane.jsx @@ -46,9 +46,9 @@ const ShowChallengeListTogglesInternal = (props) => { { - props.setSearchFilters({ filterGlobal: !props.filteringGlobal }) + props.setSearchFilters({ global: !props.showingGlobal }) }} />
@@ -127,7 +127,7 @@ export class ChallengePane extends Component { render() { const showingArchived = this.props.history.location.search.includes("archived=true"); - const filteringGlobal = this.props.history.location.search.includes("filterGlobal=true") + const showingGlobal = this.props.history.location.search.includes("global=true") const challengeStatus = [ChallengeStatus.ready, ChallengeStatus.partiallyLoaded, ChallengeStatus.none, @@ -166,7 +166,7 @@ export class ChallengePane extends Component {
- +
diff --git a/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx b/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx index e739f2cc2..fd6846ff4 100644 --- a/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx +++ b/src/components/HOCs/WithSearchRoute/WithSearchRoute.jsx @@ -38,7 +38,7 @@ export const WithSearchRoute = function(WrappedComponent, searchGroup) { query: param => this.props.setSearch(param), challengeSearch: param => this.props.setChallengeSearchMapBounds(toLatLngBounds(param), true), archived: param => this.props.setSearchFilters({ archived: param === "true" }), - filterGlobal: param => this.props.setSearchFilters({ filterGlobal: param === "true" }) + global: param => this.props.setSearchFilters({ global: param === "true" }) } state = { diff --git a/src/services/Challenge/Challenge.js b/src/services/Challenge/Challenge.js index c87fcdc15..7ec5d5752 100644 --- a/src/services/Challenge/Challenge.js +++ b/src/services/Challenge/Challenge.js @@ -443,8 +443,8 @@ export const extendedFind = function (criteria, limit = RESULTS_PER_PAGE, admin queryParams.ca = filters.archived; } - if (filters.filterGlobal) { - queryParams.fg = filters.filterGlobal; + if (filters.global) { + queryParams.cg = filters.global; } // Keywords/tags can come from both the the query and the filter, so we need to diff --git a/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js index 50c60a35e..71e53c4d8 100644 --- a/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js +++ b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js @@ -1,5 +1,5 @@ export const challengePassesGlobalFilter = function(filter, challenge) { - if (filter.filterGlobal) { + if (filter.global) { return challenge.isGlobal === false } diff --git a/src/services/Search/Search.js b/src/services/Search/Search.js index 0e5724166..92bdddb17 100644 --- a/src/services/Search/Search.js +++ b/src/services/Search/Search.js @@ -96,7 +96,7 @@ export const PARAMS_MAP = { tags: 'tt', excludeTasks: 'tExcl', archived: "ca", - filterGlobal: "fg" + global: "cg" } @@ -159,8 +159,8 @@ export const generateSearchParametersString = (filters, boundingBox, savedChalle if (filters.archived) { searchParameters[PARAMS_MAP.archived] = filters.archived; } - if (filters.filterGlobal) { - searchParameters[PARAMS_MAP.filterGlobal] = filters.filterGlobal; + if (filters.global) { + searchParameters[PARAMS_MAP.global] = filters.global; } if (filters.reviewRequestedBy) { searchParameters[PARAMS_MAP.reviewRequestedBy] = filters.reviewRequestedBy From aa7aa1b374f136c229ade529babb48a869974785 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 10 Dec 2024 13:06:56 -0600 Subject: [PATCH 5/5] fix condition --- src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js index 71e53c4d8..95ca4f597 100644 --- a/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js +++ b/src/services/Challenge/ChallengeGlobal/ChallengeGlobal.js @@ -1,5 +1,5 @@ export const challengePassesGlobalFilter = function(filter, challenge) { - if (filter.global) { + if (!filter.global) { return challenge.isGlobal === false }