From 8a17b1682cff6f0de839b8c4e98ab606b8364136 Mon Sep 17 00:00:00 2001 From: Ishan Ajwani Date: Sun, 14 May 2023 11:20:54 -0400 Subject: [PATCH] feat(bus): option to mark bus as delayed closes #1414 --- intranet/static/js/bus-afternoon.js | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/intranet/static/js/bus-afternoon.js b/intranet/static/js/bus-afternoon.js index 0576065f546..a98bc56c7a7 100644 --- a/intranet/static/js/bus-afternoon.js +++ b/intranet/static/js/bus-afternoon.js @@ -98,6 +98,7 @@ $(function() { .filter(bus => bus.attributes.route_name.includes('JT')) .map(bus => bus.attributes); } else if (action === 'Mark a bus as arrived or on time') { +<<<<<<< HEAD busList = routeList.filter(bus => !bus.attributes.route_name.includes('JT')) .map(bus => { if (bus.attributes.status === 'a') { @@ -109,6 +110,32 @@ $(function() { return bus.attributes; } }); +======= + busList = routeList.map(bus => { + if ((bus.attributes.status === 'a' || bus.attributes.status === 'd') && !bus.attributes.route_name.includes('JT')) { + let attr = JSON.parse(JSON.stringify(bus.attributes)); + attr.route_name = `Mark ${bus.attributes.route_name} as on time`; + return attr; + } + else if (bus.attributes.status === 'o') { + let attr = JSON.parse(JSON.stringify(bus.attributes)); + let attr2 = JSON.parse(JSON.stringify(bus.attributes)); + if (bus.attributes.route_name.includes('JT')) { + attr.route_name = `Mark ${bus.attributes.route_name} as delayed`; + return attr; + } + attr.route_name = `Mark ${bus.attributes.route_name} as delayed`; + attr2.route_name = `Mark ${bus.attributes.route_name} as arrived`; + return [attr, attr2]; + } else { + if (!bus.attributes.route_name.includes('JT')) { + return bus.attributes; + } + return null; + + } + }).flat().filter((element) => element != null); +>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed) } else if (action === 'Assign a bus to this space') { busList = routeList.filter(bus => bus.attributes.status !== 'a') .map(bus => bus.attributes); @@ -166,6 +193,7 @@ $(function() { } else if (this.action === 'Mark a bus as arrived or on time') { let route_name = ''; let st = ''; +<<<<<<< HEAD // TODO: this is also super hacky // Essentially, this checks if the selected route has "Mark" // at the beginning, implying that it's to be marked on time. @@ -174,6 +202,20 @@ $(function() { st = 'o'; } else { route_name = e.target.value; +======= + if (e.target.value.includes('on')) { + route_name = e.target.value.split(' ')[1]; + + st = 'o'; + } + else if (e.target.value.includes('delayed')) { + route_name = e.target.value.split(' ')[1]; + + st = 'd'; + } + else { + route_name = e.target.value.split(' ')[1]; +>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed) st = 'a'; } let route = this.model.findWhere({route_name: route_name}).attributes;