Skip to content
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
2 changes: 1 addition & 1 deletion meinberlin/react/budgeting/react_proposals_init.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function init () {
<React.StrictMode>
<BrowserRouter>
<FetchItemsProvider {...props} isMapAndList>
<ListMapView {...props} listStr={translations.list} />
<ListMapView {...props} listStr={translations.list} mode="list" />
</FetchItemsProvider>
</BrowserRouter>
</React.StrictMode>
Expand Down
4 changes: 2 additions & 2 deletions meinberlin/react/contrib/ControlBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getResultCountText = (count) => {
return django.interpolate(foundProposalsText, [count])
}

export const ControlBar = () => {
export const ControlBar = ({ mapListViewMode }) => {
// grab the results for the list from the useFetchedItems hook
const { results: { list }, isMapAndList, viewMode } = useFetchedItems()
const [expandFilters, setExpandFilters] = useState(true)
Expand Down Expand Up @@ -196,7 +196,7 @@ export const ControlBar = () => {
</div>
{isMapAndList &&
<div className="span6 align--right">
<ControlBarListMapSwitch query={queryParams} />
<ControlBarListMapSwitch mapListViewMode={mapListViewMode} query={queryParams} />
</div>}
</div>
</nav>
Expand Down
4 changes: 2 additions & 2 deletions meinberlin/react/contrib/ControlBarListMapSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const translated = {
map: django.gettext('Map')
}

export const ControlBarListMapSwitch = () => {
export const ControlBarListMapSwitch = ({ mapListViewMode }) => {
const [queryParams, setQueryParams] = useSearchParams()
const viewMode = queryParams.get('mode') || 'list'
const viewMode = queryParams.get('mode') || mapListViewMode || 'list'

const handleClick = () => {
queryParams.set('mode', viewMode === 'list' ? 'map' : 'list')
Expand Down
6 changes: 3 additions & 3 deletions meinberlin/react/contrib/map/ListMapView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { MapWithMarkers } from './Map'
* @param {Object} map - props that are passed to the Map component.
* @param {string} listStr - accessible text for the list
*/
export const ListMapView = ({ map, listStr }) => {
export const ListMapView = ({ map, listStr, mode }) => {
const [queryParams] = useSearchParams()
const { results } = useFetchedItems()
const viewMode = queryParams.get('mode') || 'list'
const viewMode = queryParams.get('mode') || mode || 'list'

const switchDisplays = () => {
if (viewMode === 'map') {
Expand All @@ -34,7 +34,7 @@ export const ListMapView = ({ map, listStr }) => {
return (
<>
<div className="block block--halfgap">
<ControlBar />
<ControlBar mapListViewMode={viewMode} />
</div>
{switchDisplays()}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function init () {
<React.StrictMode>
<BrowserRouter>
<FetchItemsProvider {...props} isMapAndList>
<ListMapView {...props} listStr={django.gettext('Proposals list')} />
<ListMapView {...props} listStr={django.gettext('Proposals list')} mode="list" />
</FetchItemsProvider>
</BrowserRouter>
</React.StrictMode>
Expand Down
2 changes: 1 addition & 1 deletion meinberlin/react/mapideas/react_mapideas_init.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function init () {
<React.StrictMode>
<BrowserRouter>
<FetchItemsProvider {...props} isMapAndList>
<ListMapView {...props} listStr={django.gettext('Map Ideas list')} />
<ListMapView {...props} listStr={django.gettext('Map Ideas list')} mode="map" />
</FetchItemsProvider>
</BrowserRouter>
</React.StrictMode>
Expand Down
2 changes: 1 addition & 1 deletion meinberlin/react/maptopicprio/react_map_topics_init.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function init () {
<React.StrictMode>
<BrowserRouter>
<FetchItemsProvider {...props} isMapAndList>
<ListMapView {...props} listStr={django.gettext('Map topics list')} />
<ListMapView {...props} listStr={django.gettext('Map topics list')} mode="map" />
</FetchItemsProvider>
</BrowserRouter>
</React.StrictMode>
Expand Down