Skip to content

Commit

Permalink
Added request state page. #102
Browse files Browse the repository at this point in the history
  • Loading branch information
skaldo committed Jun 27, 2016
1 parent 7e3a71c commit a56a780
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CitizenApplication/app/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<ion-content padding class="home" has-header="false">
<!--div class="logo"></div-->
<button class="btn" (click)="requestStop()">{{ 'HOME_PAGE.RequestStop' | translate }}</button>
<button class="btn" (click)="goToBusDetail()">{{ 'HOME_PAGE.BusLocation' | translate }}</button>
<button class="btn" (click)="goToRequests()">{{ 'HOME_PAGE.Requests' | translate }}</button>
</ion-content>
8 changes: 3 additions & 5 deletions CitizenApplication/app/pages/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, ElementRef} from '@angular/core';
import {Page, NavController, Toast, Modal} from 'ionic-angular';
import {StopListPage} from '../stop-list/stop-list';
import {BusDetailPage} from '../bus-detail/bus-detail';
import {RequestsPage} from '../requests/requests';
import {RequestStopPage} from '../request-stop/request-stop';
import {ConfigurationService} from '../../providers/config';
import {Logger, LoggerFactory} from '../../providers/logger';
Expand Down Expand Up @@ -33,16 +33,14 @@ export class HomePage {
});
}

goToBusDetail() {
this.nav.push(BusDetailPage, { lineId: 1, time: new Date() });
goToRequests() {
this.nav.push(RequestsPage);
}

// hide nav bar when we enter the page
ionViewWillEnter() {
this.element.nativeElement.removeAttribute('hidden');
}

// show nav bar when we leave the page
ionViewDidLeave() {
this.element.nativeElement.setAttribute('hidden', '');
}
Expand Down
2 changes: 2 additions & 0 deletions CitizenApplication/app/pages/home/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"en": {
"SelectStop": "Select stop:",
"RequestStop": "Request stop",
"Requests": "Stop requests",
"BusLocation": "Where is my bus?"
},
"de": {
"SelectStop": "Haltestelle wählen:",
"RequestStop": "Haltewunsch äußern",
"Requests": "Haltewünsche",
"BusLocation": "Zeige mir meine Bus auf der Karte"
}
}
13 changes: 13 additions & 0 deletions CitizenApplication/app/pages/requests/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"prefix": "REQUESTS_PAGE",
"en": {
"Title": "Requests",
"State": "State",
"NoRequests": "No requests available"
},
"de": {
"Title": "Haltewünsche",
"State": "Status",
"NoRequests": "Keine Haltewünsche verfügbar"
}
}
25 changes: 25 additions & 0 deletions CitizenApplication/app/pages/requests/requests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Generated template for the RequestsPage page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-navbar *navbar>
<ion-title>{{ 'REQUESTS_PAGE.Title' | translate }}</ion-title>
</ion-navbar>

<ion-content padding class="requests">
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content pullingText="{{'C.PullToRefresh' | translate}}" refreshingText="{{'C.Refreshing' | translate}}">
</ion-refresher-content>
</ion-refresher>
<div *ngIf="empty" id="noRequests">{{ 'REQUESTS_PAGE.NoRequests' | translate }}<p>{{'C.PullToRefresh' | translate}}</p></div>
<ion-card *ngFor="let request of requests">
<ion-card-header>
ID: {{request.is}}
</ion-card-header>
<ion-card-content>
{{ 'REQUESTS_PAGE.State' | translate }}: {{request.state}}
</ion-card-content>
</ion-card>
</ion-content>
10 changes: 10 additions & 0 deletions CitizenApplication/app/pages/requests/requests.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.requests {
#noRequests {
text-align: center;
margin-top: 10px;
font-size: 15px;
p {
margin-top: 10px;
}
}
}
43 changes: 43 additions & 0 deletions CitizenApplication/app/pages/requests/requests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Component, ElementRef } from '@angular/core';
import { NavController, Refresher } from 'ionic-angular';
import {ViewRequestState} from '../models';
import {TransformationService} from '../../providers/transformation';

/*
Generated class for the RequestsPage page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
templateUrl: 'build/pages/requests/requests.html',
})
export class RequestsPage {
private requests: Array<ViewRequestState>;
// The length or ! check does not work in the template :/
private empty: boolean;
constructor(private element: ElementRef, private nav: NavController, private dataAccess: TransformationService) {
this.doRefresh();
}

public doRefresh(refresher?: Refresher) {
this.dataAccess.getRequests().subscribe((reqs: Array<ViewRequestState>) => {
this.empty = false;
if (reqs.length === 0) {
this.empty = true;
}
this.requests = reqs;
if (refresher) {
refresher.complete();
}
});
}

ionViewWillEnter() {
this.element.nativeElement.removeAttribute('hidden');
}

ionViewDidLeave() {
this.element.nativeElement.setAttribute('hidden', '');
}
}
1 change: 1 addition & 0 deletions CitizenApplication/app/theme/app.core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@import "../pages/stop-list/stop-list";
@import "../pages/navigator/navigator";
@import "../pages/request-stop/request-stop";
@import "../pages/requests/requests.scss";

@font-face {
font-family: JuraLight;
Expand Down

0 comments on commit a56a780

Please sign in to comment.