Skip to content

Commit

Permalink
Descoberto como se pega a key do objeto
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuel Victor de Oliveira Fonseca committed Jan 12, 2018
1 parent af541b0 commit 6740145
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</button>

<div layout="row" layout-margin>
<h1 class="mat-headline tc-grey-500" flex> Alterar usuário</h1>
<h1 class="mat-headline tc-grey-500" flex> Alterar atendente</h1>
</div>

</usuario-form>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="tc-grey-500 size-height-50" layout="row" layout-align="start center">
<span> Resultado da pesquisa </span>
<div flex></div>
<span> {{ page?.totalElements}} resultados </span>
<span> {{ atendentes?.length}} resultados </span>
</div>

<mat-card class="push-none bgc-grey-50">
Expand All @@ -24,11 +24,11 @@ <h4 matLine> {{atendente.email}} </h4>
</mat-nav-list>
</mat-card>

<div layout="row" class="push-top push-bottom">
<button mat-raised-button class="tc-grey-500" (click)="showMore()" flex *ngIf="!page?.last">
VER MAIS
</button>
</div>
<!--<div layout="row" class="push-top push-bottom">-->
<!--<button mat-raised-button class="tc-grey-500" (click)="showMore()" flex *ngIf="!page?.last">-->
<!--VER MAIS-->
<!--</button>-->
<!--</div>-->

</div>
</div>
Empty file.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</button>

<div layout="row" layout-margin>
<h1 class="mat-headline tc-grey-500" flex> Inserir usuário</h1>
<h1 class="mat-headline tc-grey-500" flex> Inserir atendente</h1>
</div>
</usuario-form>
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<mat-card class="push-none bgc-grey-50 filters-card">
<div layout="row" layout-align="center center">
<div layout-gt-sm='row' layout-sm='column' flex='90' layout-align-gt-sm='start center' layout-margin>
<!--<mat-card class="push-none bgc-grey-50 filters-card">-->
<!--<div layout="row" layout-align="center center">-->
<!--<div layout-gt-sm='row' layout-sm='column' flex='90' layout-align-gt-sm='start center' layout-margin>-->

<td-chips placeholder="Pesquisar por nome" [(ngModel)]="filter"
flex-md="40" flex-gt-md="45" flex-gt-lg="50"
(add)="onChangeFilters()" (remove)="onChangeFilters()"></td-chips>
<!--<td-chips placeholder="Pesquisar por nome" [(ngModel)]="filter"-->
<!--flex-md="40" flex-gt-md="45" flex-gt-lg="50"-->
<!--(add)="onChangeFilters()" (remove)="onChangeFilters()"></td-chips>-->

<td-chips placeholder="Pesquisar por endereço" [(ngModel)]="enderecoFilters"
flex="30"
(add)="onChangeFilters()" (remove)="onChangeFilters()"></td-chips>
<!--<td-chips placeholder="Pesquisar por endereço" [(ngModel)]="enderecoFilters"-->
<!--flex="30"-->
<!--(add)="onChangeFilters()" (remove)="onChangeFilters()"></td-chips>-->

<div flex-gt-md></div>
<!--<div flex-gt-md></div>-->

<add-button routerLink="inserir"></add-button>
</div>
</div>
<!--<add-button routerLink="inserir"></add-button>-->
<!--</div>-->
<!--</div>-->

</mat-card>
<!--</mat-card>-->

<!--Listagem-->
<div layout="row" layout-align="center start">
Expand All @@ -26,29 +26,26 @@
<div class="tc-grey-500 size-height-50" layout="row" layout-align="start center">
<span> Resultado da pesquisa </span>
<div flex></div>
<span> {{ page?.totalElements}} resultados </span>
<span> {{ unidades?.length}} resultados </span>
</div>

<mat-card class="push-none bgc-grey-50">
<mat-nav-list>
<div *ngFor="let pontoColeta of pontosColeta" routerLink="{{pontoColeta.id}}">

<div *ngFor="let unidade of unidades" routerLink="{{unidade?.key}}">
<mat-list-item>
<h3 matLine> {{pontoColeta.nome}} </h3>
<p matLine *ngIf="pontoColeta?.endereco?.id">Número {{pontoColeta?.endereco?.numero}},
{{pontoColeta?.endereco?.logradouro}}, {{pontoColeta?.endereco?.bairro}} -
{{pontoColeta?.endereco?.cidade?.nome}} - {{pontoColeta?.endereco?.cidade?.estado?.uf}} </p>
<h3 matLine> {{unidade?.payload?.val().nome}} </h3>
<p matLine *ngIf="unidade?.payload?.val().endereco">{{unidade?.payload?.val().endereco}}</p>
</mat-list-item>
<mat-divider></mat-divider>
</div>
</mat-nav-list>
</mat-card>

<div layout="row" class="push-top push-bottom">
<button mat-raised-button class="tc-grey-500" (click)="showMore()" flex *ngIf="!page?.last">
VER MAIS
</button>
</div>
<!--<div layout="row" class="push-top push-bottom">-->
<!--<button mat-raised-button class="tc-grey-500" (click)="showMore()" flex *ngIf="!page?.last">-->
<!--VER MAIS-->
<!--</button>-->
<!--</div>-->

</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {Component, OnInit} from "@angular/core";
import {Router} from "@angular/router";
import {MatDialog, MatSnackBar} from "@angular/material";
import {UnidadeService} from "../../../../service/unidade.service";
import {AngularFireList, SnapshotAction} from "angularfire2/database";
import {Observable} from "rxjs/Observable";

@Component({
selector: 'consultar-unidades',
Expand All @@ -13,31 +15,7 @@ export class ConsultarUnidadesComponent implements OnInit {
/**
*
*/
public filter: String[] = [];

/**
*
*/
public unidades: any[] = [];

/**
*
*/
public pageable = {//PageRequest
size: 20,
page: 0,
sort: null
};

/**
*
*/
public page: any;

/**
*
*/
public enderecoFilters: String[] = [];
public unidades: any;

/**
*
Expand All @@ -53,61 +31,18 @@ export class ConsultarUnidadesComponent implements OnInit {
*
*/
ngOnInit() {
this.listUnidadesByFilters(null, null);
}

/**
* Opção "VER MAIS"
*
*/
public showMore() {
this.pageable.page += 1;
this.listAlunos();
}

/**
* Chamado ao alterar algum filtro
*
*/
public onChangeFilters() {
this.pageable.page = 0;

let enderecoFilters = this.enderecoFilters && this.enderecoFilters.length ? this.enderecoFilters.join() : null;

let filter = this.filter && this.filter.length ? this.filter.join() : null;
this.unidadeService.find(filter, enderecoFilters, this.pageable)
.then((result) => {
// Novo array de unidades mapeado
this.unidades = result.content;
this.page = result;
})
}

/**
* Consulta de unidades com filtros do model
*
*/
public listAlunos() {
this.listUnidadesByFilters(this.filter, this.enderecoFilters);
this.listUnidadesByFilters();
}


/**
* Consulta de unidades
*
*/
public listUnidadesByFilters(filter: String[], enderecoFilters: String[]) {

const enderecoFiltersString = enderecoFilters && enderecoFilters.length ? enderecoFilters.join() : null;

const filterString = filter && filter.length ? filter.join() : null;

this.unidadeService.find(filterString, enderecoFiltersString, this.pageable)
.then((result) => {
// Novo array de unidades mapeado
this.unidades = this.unidades.concat(result.content);
this.page = result;
})
public listUnidadesByFilters() {
this.unidadeService.find().snapshotChanges().subscribe(asdf=> {
this.unidades = asdf;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import {UnidadeService} from "../../../../service/unidade.service";
})
export class VisualizarUnidadeComponent implements OnInit {

/**
*
*/
masks = textMasks;

/**
*
* @type {Usuario}
Expand All @@ -36,9 +31,10 @@ export class VisualizarUnidadeComponent implements OnInit {
*
*/
ngOnInit() {
let unidadeId: number = this.activatedRoute.snapshot.params['id'];
console.log('aqui');
let unidadeId: number = this.activatedRoute.snapshot.params['key'];

this.find(unidadeId);
// this.find(unidadeId);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/web/domain/service/atendente.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class AtendenteService extends AbstractService {

constructor(private af: AngularFireDatabase, private httpClient: HttpClient) {
super();
this.af.list('atendentes').valueChanges().subscribe(atendentes => this.atendentes = atendentes);
}

public save(atendente: Atendente): Promise<any> {
Expand Down
Loading

0 comments on commit 6740145

Please sign in to comment.