Permalink
Browse files

Show shuttle departure times on cards and refactor cancelShuttle

  • Loading branch information...
dawneraq committed Apr 18, 2017
1 parent 521e6bf commit c8eac0b9c43fa06f1c778cad0025b812ecd75368
Showing with 27 additions and 6 deletions.
  1. +18 −3 web/app/dashboard/dashboard.component.ts
  2. +9 −3 web/views/partials/dashboard.html
@@ -104,6 +104,7 @@ export class DashboardComponent implements OnInit {
this.shuttles.splice(index, 1);
}
this.getShuttles();
+ // TODO show a candybar or something
}
)
}
@@ -130,9 +131,21 @@ export class DashboardComponent implements OnInit {
this.getShuttles()
)
}
- cancelshuttle(shuttle: Shuttle) {
- this.dashboardService.cancelshuttle(shuttle).then(data => this.getShuttles());
+ cancelShuttle(shuttleId: string) {
+ let c = this.getShuttleById(shuttleId);
+ this.dashboardService.cancelshuttle(c).then(data => this.getShuttles());
+ // TODO make this change in the backend
+ }
+ cancelShuttleGroup(shuttleGroup: ShuttleGroup) {
+ let cancelPromises = [];
+
+ shuttleGroup.shuttles.forEach(shuttleId => {
+ let cancelPromise = this.dashboardService.cancelshuttle(this.getShuttleById(shuttleId));
+ cancelPromises.push(cancelPromise);
+ }, this);
+ Promise.all(cancelPromises).then(data => this.getShuttles());
+ // TODO make this change in the backend
}
addshuttle(shuttle: Shuttle) {
this.dashboardService.addshuttle(shuttle);
@@ -144,5 +157,7 @@ export class DashboardComponent implements OnInit {
// this.dashboardService.modifyshuttle(shuttle);
//
// }
-
+ getShuttleById(shuttleId: string) {
+ return this.shuttles.find(shuttle => shuttle._id == shuttleId);
+ }
}
@@ -92,14 +92,20 @@ <h2 class="mdl-card__title-text">{{shuttleGroup.origin[0].name}}
<!-- shuttle cards -->
<div *ngFor="let shuttleId of shuttleGroup.shuttles" class="demo-card-event mdl-card mdl-shadow--2dp">
<div class="mdl-card__title mdl-card--expand shuttle-card-body">
- <strong>
- Shuttle {{ shuttleId }}
- </strong>
+ <p>
+ <span *ngIf="godmode">Shuttle: {{ shuttleId }}<br/></span>
+ Departs {{ getShuttleById(shuttleId)?.departureDateTime | date: 'h:mm a' }}<br/>
+ {{ getShuttleById(shuttleId)?.departureDateTime | date: 'MMMM d, y' }}
+ </p>
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
Sign Up
</a>
+ <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" *ngIf="godmode" (click)="cancelShuttle(shuttleId)">
+ <i class="material-icons">clear</i>
+ Cancel
+ </a>
<div class="mdl-layout-spacer"></div>
<i class="material-icons">event</i>
</div>

0 comments on commit c8eac0b

Please sign in to comment.