diff --git a/meinberlin/apps/budgeting/assets/BudgetingProposalList.jsx b/meinberlin/apps/budgeting/assets/BudgetingProposalList.jsx index b70003c31e..8a0b03d890 100644 --- a/meinberlin/apps/budgeting/assets/BudgetingProposalList.jsx +++ b/meinberlin/apps/budgeting/assets/BudgetingProposalList.jsx @@ -15,6 +15,7 @@ export const BudgetingProposalList = (props) => { const countText = django.ngettext('you have 1 vote left.', 'you have %s votes left.', votes) return django.interpolate(countText, [votes]) } + const noResults = django.gettext('Nothing to show') const fetchProposals = () => { const url = props.proposals_api_url + location.search @@ -96,7 +97,9 @@ export const BudgetingProposalList = (props) => {
- {renderList(data)} + {Object.keys(data).length > 0 + ? renderList(data) + : noResults}
diff --git a/meinberlin/apps/budgeting/assets/ControlBar.jsx b/meinberlin/apps/budgeting/assets/ControlBar.jsx index cdcdd2c6f8..b2227377e4 100644 --- a/meinberlin/apps/budgeting/assets/ControlBar.jsx +++ b/meinberlin/apps/budgeting/assets/ControlBar.jsx @@ -3,14 +3,15 @@ import { ControlBarDropdown } from './ControlBarDropdown' import { ControlBarListMapSwitch } from './ControlBarListMapSwitch' import { ControlBarSearch } from './ControlBarSearch' import { ControlBarSearchTerm } from './ControlBarSearchTerm' -import { SpacedSpan } from './SpacedSpan' +import { FilterToggle } from '../../contrib/assets/FilterToggle' import django from 'django' import { useSearchParams } from 'react-router-dom' const translated = { showFilters: django.gettext('Show filters'), hideFilters: django.gettext('Hide filters'), - filters: django.gettext('Filters') + filters: django.gettext('Filters'), + nav: django.gettext('Search, filter and sort the ideas list') } const getResultCountText = (count) => { @@ -21,9 +22,21 @@ const getResultCountText = (count) => { export const ControlBar = props => { const [expandFilters, setExpandFilters] = useState() + const [resultString, setResultString] = useState(false) const [queryParams, setQueryParams] = useSearchParams() const [term, setTerm] = useState(queryParams.get('search') || '') + // check list is filtered not just ordered + // else needed for search term deletion + const handleResultString = () => { + const entryArray = Array.from(queryParams.keys()) + if ((entryArray.length === 2 && entryArray[1] !== 'ordering') || (entryArray.length > 2)) { + setResultString(true) + } else { + setResultString(false) + } + } + const applyFilter = (filterType, filterChoice) => { if (filterChoice[0] !== '') { queryParams.set(filterType, filterChoice[0]) @@ -34,84 +47,85 @@ export const ControlBar = props => { // to avoid empty pagination page for given // filter settings, always show first page, queryParams.delete('page') - + handleResultString() setQueryParams(queryParams) } const applySearch = (value) => { setTerm(value) applyFilter('search', [value]) + handleResultString() + } + + const handleToggleFilters = (e) => { + e.preventDefault() + setExpandFilters(!expandFilters) } return ( -
+