Skip to content

Commit

Permalink
Report list fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoumpierre committed Apr 26, 2018
1 parent 0afcfe3 commit 7a6ba5a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
16 changes: 15 additions & 1 deletion src/pages/reports/detail/reports-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
</ion-navbar>
</ion-header>

<ion-content padding>
<ion-content>
<ion-list class="single-item" *ngIf="report">
<ion-item class="list-item">
<div class="highlight">{{ report.name }}</div>
<div>Total: {{ report.total | currency:'BRL':'R$' }}</div>
</ion-item>

<ion-item *ngFor="let item of report.list" class="list-item">
<ion-avatar item-start>
<img src="assets/images/placeholder-60.jpg" alt="" width="60" height="60">
</ion-avatar>

<p class="highlight">{{ item.name }}</p>
<p>Preço Un: {{ item.total | currency:'BRL':'R$' }}</p>
</ion-item>
</ion-list>
</ion-content>
19 changes: 18 additions & 1 deletion src/pages/reports/detail/reports-detail.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ApiProvider } from "../../../providers/api/api";

/**
* Generated class for the ReportsDetailPage page.
Expand All @@ -14,6 +15,22 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
templateUrl: 'reports-detail.html',
})
export class ReportsDetailPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
private id;
private category;
private report;

constructor(public navCtrl: NavController, public navParams: NavParams, private apiProvider: ApiProvider) {
this.id = this.navParams.get('id');
this.category = this.navParams.get('category');
}

/**
*
*/
ionViewWillEnter() {
console.log('will enter');

this.apiProvider.builder('reports/' + this.category + '/' + this.id).loader().get()
.subscribe((res) => this.report = res);
}
}
2 changes: 1 addition & 1 deletion src/pages/reports/view/reports-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ion-content>
<ion-list class="single-item">
<ion-item *ngFor="let report of reports; let i = index" class="list-item" (click)="goToDetails(report.id)">
<ion-item *ngFor="let report of reports" class="list-item" (click)="goToDetails(report.id)">
<div class="highlight">{{ report.name }}</div>
<div>Total: {{ report.total | currency:'BRL':'R$' }}</div>
</ion-item>
Expand Down
14 changes: 13 additions & 1 deletion src/pages/reports/view/reports-view.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ApiProvider } from "../../../providers/api/api";
import { ReportsDetailPage } from "../detail/reports-detail";

/**
* Generated class for the ReportsViewPage page.
Expand All @@ -22,8 +23,19 @@ export class ReportsViewPage {
this.category = this.navParams.get('category');
}

ionViewDidLoad() {
/**
*
*/
ionViewWillEnter() {
this.apiProvider.builder('reports/' + this.category).loader().get()
.subscribe((res) => this.reports = res);
}

/**
*
* @param {number} id
*/
goToDetails(id: number) {
this.navCtrl.push(ReportsDetailPage, {'id': id, 'category': this.category});
}
}

0 comments on commit 7a6ba5a

Please sign in to comment.