Skip to content

Commit

Permalink
Add back missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Dec 13, 2024
1 parent c030d5c commit 6ab6dd2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/EditStopPage/ModalitiesMenuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions src/models/submodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
};

0 comments on commit 6ab6dd2

Please sign in to comment.