Skip to content

Commit

Permalink
Merge pull request #9789 from CitizenLabDotCo/master
Browse files Browse the repository at this point in the history
Release 2024-12-16
  • Loading branch information
jamesspeake authored Dec 16, 2024
2 parents 26aa042 + edc28e0 commit 4c832f0
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion back/app/services/export/xlsx/inputs_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def generate_for_timeline_project(workbook, project)
end

def create_phase_sheet(workbook, phase)
inputs = eager_load_inputs(phase.ideas.published)
inputs = eager_load_inputs(phase.ideas.submitted_or_published)
sheet_generator = InputSheetGenerator.new inputs, phase
sheet_name = MultilocService.new.t phase.title_multiloc
sheet_generator.generate_sheet(workbook, sheet_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ interface Props {
onClick: (event: FormEvent) => void;
ideaQueryParameters: InputFiltersProps['ideaQueryParameters'];
filtersActive: boolean;
onReset: () => void;
}

const BottomBar = memo<Props>(
({ onClick, ideaQueryParameters, onReset, filtersActive }) => {
({ onClick, ideaQueryParameters, filtersActive }) => {
const { data: ideasFilterCounts } =
useIdeasFilterCounts(ideaQueryParameters);

Expand All @@ -43,7 +42,7 @@ const BottomBar = memo<Props>(
}}
/>
</Button>
<ResetFiltersButton onClick={onReset} filtersActive={filtersActive} />
<ResetFiltersButton filtersActive={filtersActive} />
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface Props extends InputFiltersProps {
const FiltersModal = ({
opened,
ideaQueryParameters,
onClearFilters,
onClose,
...filtersProps
}: Props) => {
Expand All @@ -32,7 +31,6 @@ const FiltersModal = ({
<BottomBar
onClick={onClose}
ideaQueryParameters={ideaQueryParameters}
onReset={onClearFilters}
filtersActive={filtersProps.filtersActive}
/>
}
Expand All @@ -41,7 +39,6 @@ const FiltersModal = ({
<Box p="16px">
<InputFilters
ideaQueryParameters={ideaQueryParameters}
onClearFilters={onClearFilters}
// We have a reset filters button in TopBar
showResetButton={false}
{...filtersProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const FiltersModal = lazy(() => import('./FiltersModal'));

const ButtonWithFiltersModal = ({
ideaQueryParameters,
onClearFilters,
...filtersProps
}: InputFiltersProps) => {
const isSmallerThanTablet = useBreakpoint('tablet');
Expand Down Expand Up @@ -45,7 +44,6 @@ const ButtonWithFiltersModal = ({
<FiltersModal
opened={filtersModalOpened}
ideaQueryParameters={ideaQueryParameters}
onClearFilters={onClearFilters}
onClose={closeModal}
{...filtersProps}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface InputFiltersProps {
ideasFilterCounts: IIdeasFilterCounts | NilOrError;
numberOfSearchResults: number;
ideaQueryParameters: Partial<IIdeaQueryParameters>;
onClearFilters: () => void;
onSearch: (searchTerm: string) => void;
onChangeStatus: (ideaStatus: string | null) => void;
onChangeTopics: (topics: string[] | null) => void;
Expand All @@ -44,7 +43,6 @@ const InputFilters = ({
numberOfSearchResults,
ideaQueryParameters,
phaseId,
onClearFilters,
showResetButton = true,
showStatusFilter = true,
showSearchField = true,
Expand Down Expand Up @@ -101,10 +99,7 @@ const InputFilters = ({
)}
{showResetButton && (
<Box mt="8px">
<ResetFiltersButton
onClick={onClearFilters}
filtersActive={filtersActive}
/>
<ResetFiltersButton filtersActive={filtersActive} />
</Box>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface Props extends InputFiltersProps {

const FiltersMapView = ({
ideaQueryParameters,
onClearFilters,
onClose,
...filtersProps
}: Props) => {
Expand All @@ -25,7 +24,6 @@ const FiltersMapView = ({
<Box p="16px">
<InputFilters
ideaQueryParameters={ideaQueryParameters}
onClearFilters={onClearFilters}
// A reset button is available in the filters top bar
showResetButton={false}
// BE doesn't currently support filtering map markers by status.
Expand All @@ -38,7 +36,6 @@ const FiltersMapView = ({
<BottomBar
onClick={onClose}
ideaQueryParameters={ideaQueryParameters}
onReset={onClearFilters}
filtersActive={filtersProps.filtersActive}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@ import React from 'react';

import { Button } from '@citizenlab/cl2-component-library';

import tracks from 'components/IdeaCards/tracks';

import { trackEventByName } from 'utils/analytics';
import { FormattedMessage } from 'utils/cl-intl';
import { updateSearchParams } from 'utils/cl-router/updateSearchParams';

import ideaCardsMessages from '../messages';

interface Props {
onClick: () => void;
filtersActive: boolean;
}

const ResetFiltersButton = ({ onClick, filtersActive }: Props) => {
const ResetFiltersButton = ({ filtersActive }: Props) => {
const handleOnClick = () => {
trackEventByName(tracks.clearFiltersClicked);
updateSearchParams({
search: undefined,
idea_status: undefined,
topics: undefined,
});
};

return (
<Button onClick={onClick} buttonStyle="text" disabled={!filtersActive}>
<Button
onClick={handleOnClick}
buttonStyle="text"
disabled={!filtersActive}
>
<FormattedMessage {...ideaCardsMessages.resetFilters} />
</Button>
);
Expand Down
10 changes: 0 additions & 10 deletions front/app/components/IdeaCards/IdeasWithFiltersSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ const IdeasWithFiltersSidebar = ({
[onUpdateQuery]
);

const clearFilters = useCallback(() => {
trackEventByName(tracks.clearFiltersClicked);
onUpdateQuery({
search: undefined,
idea_status: undefined,
topics: undefined,
});
}, [onUpdateQuery]);

const filtersActive = !!(
ideaQueryParameters.search ||
ideaQueryParameters.idea_status ||
Expand All @@ -213,7 +204,6 @@ const IdeasWithFiltersSidebar = ({
ideasFilterCounts,
numberOfSearchResults: ideasCount,
ideaQueryParameters,
onClearFilters: clearFilters,
onSearch: handleSearchOnChange,
onChangeStatus: handleStatusOnChange,
onChangeTopics: handleTopicsOnChange,
Expand Down
4 changes: 1 addition & 3 deletions front/app/components/IdeasMap/desktop/MapIdeasList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ const MapIdeasList = memo<Props>(
onChangeStatus,
onChangeTopics,
handleSortOnChange,
onClearFilters,
filtersActive,
ideasFilterCounts,
numberOfSearchResults,
} = inputFiltersProps ?? {};

const hasInputFilterProps =
onChangeStatus && onChangeTopics && handleSortOnChange && onClearFilters;
onChangeStatus && onChangeTopics && handleSortOnChange;

const { data: ideaCustomFieldsSchema } = useIdeaJsonFormSchema({
projectId,
Expand Down Expand Up @@ -127,7 +126,6 @@ const MapIdeasList = memo<Props>(
<>
<FiltersMapView
ideaQueryParameters={ideaQueryParameters || {}}
onClearFilters={onClearFilters}
filtersActive={!!filtersActive}
ideasFilterCounts={ideasFilterCounts}
numberOfSearchResults={
Expand Down

0 comments on commit 4c832f0

Please sign in to comment.