Skip to content

Commit

Permalink
update field id (#1338)
Browse files Browse the repository at this point in the history
fixes multiselect
  • Loading branch information
ErinLMoore authored Jul 20, 2023
1 parent 9249c20 commit 688d983
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions apps/concierge_site/assets/js/bus-direction-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const toggleBusDirection = direction => {
const updateAlternateRoutes = (before, after, direction) => {
// read existing alternate routes from DOM
const alternativeRoutes = JSON.parse(
decodeURI(document.getElementById("trip_alternate_routes").value)
decodeURI(document.getElementById("new-tripleg-form_alternate_routes").value)
);

// return if their are no alternative routes specified
Expand All @@ -24,22 +24,22 @@ const updateAlternateRoutes = (before, after, direction) => {
(accumulator, primaryRoute) =>
primaryRoute === before
? // update the route that has been changed
Object.assign({}, accumulator, {
[after]: alternativeRoutes[primaryRoute].map(alternativeRoute => {
// replace the direction on nested alternate routes
const [route, suffix] = alternativeRoute.split(" - ", 2);
return `${route} - ${direction}${suffix.substring(1)}`;
})
Object.assign({}, accumulator, {
[after]: alternativeRoutes[primaryRoute].map(alternativeRoute => {
// replace the direction on nested alternate routes
const [route, suffix] = alternativeRoute.split(" - ", 2);
return `${route} - ${direction}${suffix.substring(1)}`;
})
})
: // otherwise, return original key and value
Object.assign({}, accumulator, {
[`${primaryRoute}`]: alternativeRoutes[primaryRoute]
}),
Object.assign({}, accumulator, {
[`${primaryRoute}`]: alternativeRoutes[primaryRoute]
}),
{}
);

// commit all alternate routes back to the DOM
document.getElementById("trip_alternate_routes").value = encodeURI(
document.getElementById("new-tripleg-form_alternate_routes").value = encodeURI(
JSON.stringify(updatedAlternateRoutes)
);
};
4 changes: 2 additions & 2 deletions apps/concierge_site/assets/js/select-multi-fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const handleRouteFormSubmit = e => {
removeElByQuery("#bus-error");

const existingAlternativeRoutes = JSON.parse(
decodeURI(document.getElementById("trip_alternate_routes").value)
decodeURI(document.getElementById("new-tripleg-form_alternate_routes").value)
);

const formEl = e.target;
Expand Down Expand Up @@ -82,7 +82,7 @@ const handleRouteFormSubmit = e => {
);

// commit all alternate routes back to the DOM
document.getElementById("trip_alternate_routes").value = encodeURI(
document.getElementById("new-tripleg-form_alternate_routes").value = encodeURI(
JSON.stringify(updatedAlternateRoutes)
);
};
Expand Down

0 comments on commit 688d983

Please sign in to comment.