@@ -98,6 +98,7 @@ $(function() {
9898 . filter ( bus => bus . attributes . route_name . includes ( 'JT' ) )
9999 . map ( bus => bus . attributes ) ;
100100 } else if ( action === 'Mark a bus as arrived or on time' ) {
101+ < << << << HEAD
101102 busList = routeList . filter ( bus => ! bus . attributes . route_name . includes ( 'JT' ) )
102103 . map ( bus => {
103104 if ( bus . attributes . status === 'a' ) {
@@ -109,6 +110,32 @@ $(function() {
109110 return bus . attributes ;
110111 }
111112 } ) ;
113+ = === ===
114+ busList = routeList . map ( bus => {
115+ if ( ( bus . attributes . status === 'a' || bus . attributes . status === 'd' ) && ! bus . attributes . route_name . includes ( 'JT' ) ) {
116+ let attr = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
117+ attr . route_name = `Mark ${ bus . attributes . route_name } as on time` ;
118+ return attr ;
119+ }
120+ else if ( bus . attributes . status === 'o' ) {
121+ let attr = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
122+ let attr2 = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
123+ if ( bus . attributes . route_name . includes ( 'JT' ) ) {
124+ attr . route_name = `Mark ${ bus . attributes . route_name } as delayed` ;
125+ return attr ;
126+ }
127+ attr . route_name = `Mark ${ bus . attributes . route_name } as delayed` ;
128+ attr2 . route_name = `Mark ${ bus . attributes . route_name } as arrived` ;
129+ return [ attr , attr2 ] ;
130+ } else {
131+ if ( ! bus . attributes . route_name . includes ( 'JT' ) ) {
132+ return bus . attributes ;
133+ }
134+ return null ;
135+
136+ }
137+ } ) . flat ( ) . filter ( ( element ) => element != null ) ;
138+ > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
112139 } else if ( action === 'Assign a bus to this space' ) {
113140 busList = routeList . filter ( bus => bus . attributes . status !== 'a' )
114141 . map ( bus => bus . attributes ) ;
@@ -166,6 +193,7 @@ $(function() {
166193 } else if ( this . action === 'Mark a bus as arrived or on time' ) {
167194 let route_name = '' ;
168195 let st = '' ;
196+ < << << << HEAD
169197 // TODO: this is also super hacky
170198 // Essentially, this checks if the selected route has "Mark"
171199 // at the beginning, implying that it's to be marked on time.
@@ -174,6 +202,20 @@ $(function() {
174202 st = 'o' ;
175203 } else {
176204 route_name = e . target . value ;
205+ = === ===
206+ if ( e . target . value . includes ( 'on' ) ) {
207+ route_name = e . target . value . split ( ' ' ) [ 1 ] ;
208+
209+ st = 'o' ;
210+ }
211+ else if ( e . target . value . includes ( 'delayed' ) ) {
212+ route_name = e . target . value . split ( ' ' ) [ 1 ] ;
213+
214+ st = 'd' ;
215+ }
216+ else {
217+ route_name = e . target . value . split ( ' ' ) [ 1 ] ;
218+ > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
177219 st = 'a' ;
178220 }
179221 let route = this . model . findWhere ( { route_name : route_name } ) . attributes ;
0 commit comments