From 4173d421317010e54c0d007b54c0775b37a10314 Mon Sep 17 00:00:00 2001 From: lostcarpark Date: Sat, 5 Oct 2024 20:32:10 +0100 Subject: [PATCH 1/2] Add map links to rooms. --- README.md | 2 ++ src/components/ProgramItem.js | 16 ++++++++++++++++ src/config_example.json | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a60ff60..dc855f5 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ The main place customisations go is the `src/config.json` file. Settings current - `HELP_TEXT.CLOSE_LABEL`: Label for button to dismiss help text. - `HELP_TEXT.CLOSE_ARIA_LABEL`: Label to describe dismiss button. - `LOCATIONS.SEARCHABLE`: Whether the location list can be searched by typing. (Searching can be inconvenient on touch screens.) +- `LOCATIONS.LABEL`: Label to show on map links. +- `LOCATIONS.MAPPING`: Array of locations, with links to show on map. Each room should be specified as: `{ "KEY": "Room name", "MAP_URL": "link to map" }`. - `APPLICATION.LOADING.MESSAGE`: Message to display while loading. - `PROGRAM.LIMIT.SHOW`: If true, "limit number of items" drop-down will be displayed. - `PROGRAM.LIMIT.LABEL`: Label for limit drop-down. diff --git a/src/components/ProgramItem.js b/src/components/ProgramItem.js index 6e626a1..6e3fdb7 100644 --- a/src/components/ProgramItem.js +++ b/src/components/ProgramItem.js @@ -114,6 +114,22 @@ const ProgramItem = ({ item, forceExpanded, now }) => { }); } + if ('MAPPING' in configData.LOCATIONS) { + for (const location of configData.LOCATIONS.MAPPING) { + if (item.loc.toString() === location.KEY) { + links.push( + + ) + } + } + } + const duration = configData.DURATION.SHOW_DURATION && item.mins ? (
diff --git a/src/config_example.json b/src/config_example.json index 16f506f..7f855d1 100644 --- a/src/config_example.json +++ b/src/config_example.json @@ -40,7 +40,11 @@ "CLOSE_ARIA_LABEL": "Dismiss help text" }, "LOCATIONS": { - "SEARCHABLE": false + "SEARCHABLE": false, + "LABEL": "Show on map", + "MAPPING": [ + { "KEY": "Davin - Croke Park", "MAP_URL": "https://map.octocon.com" } + ] }, "APPLICATION": { "LOADING": { From c374527f1cdc83e865ca23b5d293f2c50a1a71e8 Mon Sep 17 00:00:00 2001 From: lostcarpark Date: Wed, 30 Oct 2024 02:37:41 +0000 Subject: [PATCH 2/2] Add routing for locations. --- src/components/AppRoutes.js | 2 ++ src/components/FilterableProgram.js | 11 +++++++++++ src/components/LocationProgramme.js | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/components/LocationProgramme.js diff --git a/src/components/AppRoutes.js b/src/components/AppRoutes.js index aed538f..36a63ff 100644 --- a/src/components/AppRoutes.js +++ b/src/components/AppRoutes.js @@ -15,6 +15,7 @@ import UnfilterableProgram from "./UnfilterableProgram"; import MySchedule from "./MySchedule"; import ItemById from "./ItemById"; import ItemByIdList from "./ItemByIdList"; +import LocationProgramme from "./LocationProgramme"; import People from "./People"; import Person from "./Person"; import Info from "./Info"; @@ -37,6 +38,7 @@ const AppRoutes = () => { } /> } /> } /> + } /> } /> } /> diff --git a/src/components/FilterableProgram.js b/src/components/FilterableProgram.js index 58f2a21..9b8cb3b 100644 --- a/src/components/FilterableProgram.js +++ b/src/components/FilterableProgram.js @@ -1,4 +1,5 @@ import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; import ReactSelect from "react-select"; import { useStoreState, useStoreActions } from "easy-peasy"; import { Temporal } from "@js-temporal/polyfill"; @@ -10,6 +11,8 @@ import ShowPastItems from "./ShowPastItems"; import { LocalTime } from "../utils/LocalTime"; const FilterableProgram = () => { + const navigate = useNavigate(); + const program = useStoreState((state) => state.program); const locations = useStoreState((state) => state.locations); const tags = useStoreState((state) => state.tags); @@ -294,8 +297,16 @@ const FilterableProgram = () => { isSearchable={configData.LOCATIONS.SEARCHABLE} value={selLoc} onChange={(value) => { + console.log(value); resetDisplayLimit(); setSelLoc(value); + if (value.length) { + const locList = value.map((location) => location.value).join('~'); + navigate('/loc/' + locList); + } + else { + navigate('/'); + } }} className="filter-container" classNamePrefix="filter-select" diff --git a/src/components/LocationProgramme.js b/src/components/LocationProgramme.js new file mode 100644 index 0000000..ef785a3 --- /dev/null +++ b/src/components/LocationProgramme.js @@ -0,0 +1,21 @@ +import { useStoreActions } from "easy-peasy"; +import { useParams } from "react-router-dom"; +import FilterableProgram from "./FilterableProgram"; + +const LocationProgramme = () => { + const setSelLoc = useStoreActions( + (actions) => actions.setProgramSelectedLocations + ); + + const params = useParams(); + const locations = params.locList.split("~"); + if (locations.length) { + setSelLoc(locations.map((loc) => { return {value: loc, label: loc}; })); + } + + return ( + + ); +}; + +export default LocationProgramme;