From 6ab6dd2c7570d6cb3261dc9ed67c3fbe2cc9ca2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Fri, 13 Dec 2024 21:17:03 +0100 Subject: [PATCH] Add back missing function --- .../EditStopPage/ModalitiesMenuItems.js | 6 +++-- src/models/submodes.js | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/EditStopPage/ModalitiesMenuItems.js b/src/components/EditStopPage/ModalitiesMenuItems.js index 462d03c4d..76dae88a5 100644 --- a/src/components/EditStopPage/ModalitiesMenuItems.js +++ b/src/components/EditStopPage/ModalitiesMenuItems.js @@ -15,8 +15,10 @@ limitations under the Licence. */ import React from "react"; import MenuItem from "@mui/material/MenuItem"; import ModalityIconSvg from "../MainPage/ModalityIconSvg"; -import { getInverseSubmodesWhitelist } from "../../models/submodes"; -import { getStopPlacesForSubmodes } from "../../utils/roleUtils"; +import { + getInverseSubmodesWhitelist, + getStopPlacesForSubmodes, +} from "../../models/submodes"; import MoreMenuItem from "../MainPage/MoreMenuItem"; class ModalitiesMenuItems extends React.Component { diff --git a/src/models/submodes.js b/src/models/submodes.js index b49ed1e66..5c85a9be1 100644 --- a/src/models/submodes.js +++ b/src/models/submodes.js @@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence. */ +import stopTypes from "./stopTypes"; + export const submodes = [ "airportLinkBus", "expressBus", @@ -49,3 +51,25 @@ export const submodes = [ export const getInverseSubmodesWhitelist = (whitelist) => { return submodes.filter((submode) => whitelist.indexOf(submode) === -1); }; + +export const getStopPlacesForSubmodes = (legalSubmodes) => { + let result = []; + + if (!legalSubmodes || !legalSubmodes.length) return result; + + const stopTypeKeys = Object.keys(stopTypes); + + for (let i = 0; i < stopTypeKeys.length; i++) { + const stopType = stopTypes[stopTypeKeys[i]]; + const submodes = stopType.submodes || []; + legalSubmodes.forEach((legalSubmode) => { + if (submodes.indexOf(legalSubmode) > -1) { + if (result.indexOf(stopTypeKeys[i]) === -1 && legalSubmode !== null) { + result.push(stopTypeKeys[i]); + } + } + }); + } + return result; + return stopPlace.permissions?.canEdit || false; +};