Skip to content

Commit

Permalink
#5 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiosanabria committed Apr 4, 2017
1 parent 39188b2 commit a057668
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/app/main.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,11 @@ export class MainService {
deg2rad(deg) {
return deg * (Math.PI / 180)
}

isUndefined(variable) {
if ("undefined" === typeof variable) {
console.log("variable is undefined");
}
}
}

17 changes: 14 additions & 3 deletions src/pages/principal/principal.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@
<!--TODO
buscador que hizo sergio por ciudad.
-->
<ion-searchbar #searchP [hidden]="!showSearch" [(ngModel)]="search" (ionBlur)="cancelarBusqueda($event)"
(ionClear)="cancelarBusqueda($event)" (ionCancel)="cancelarBusqueda($event)"
[placeholder]="('buscarEvenProms' | translate)"></ion-searchbar>
<!--<ion-searchbar #searchP [hidden]="!showSearch" [(ngModel)]="search" (ionBlur)="cancelarBusqueda($event)"-->
<!--(ionClear)="cancelarBusqueda($event)" (ionCancel)="cancelarBusqueda($event)"-->
<!--[placeholder]="('buscarEvenProms' | translate)"></ion-searchbar>-->

<ion-title>
<ion-select center #searchP [hidden]="!showSearch" [(ngModel)]="search">
<ion-option *ngFor="let l of localidades" [value]="l.descripcion">
{{l.descripcion | uppercase}}
</ion-option>

</ion-select>
</ion-title>


<ion-buttons *ngIf="!showSearch" end>
<!--<button (click)="modalSearch({charNum: 0})" ion-button icon-only>-->
<!--<ion-icon name="options"></ion-icon>-->
Expand Down
53 changes: 37 additions & 16 deletions src/pages/principal/principal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Output, EventEmitter, ViewChild} from '@angular/core';
import {ToastController, Slides, Events, Content} from "ionic-angular";
import {ToastController, Slides, Events, Content, Select} from "ionic-angular";
import {ModalSearch} from '../../pages/modals/search';
import {MainService} from "../../app/main.service";
import 'leaflet';
Expand Down Expand Up @@ -38,9 +38,14 @@ export class PrincipalPage {

showSearch: Boolean = false;

// search = "";

search = "";

@ViewChild('searchP') searchP: Searchbar;
localidades: any;


@ViewChild('searchP') searchP: Select;

constructor(private navController: NavController,
public mainservice: MainService,
Expand All @@ -53,7 +58,7 @@ export class PrincipalPage {

this.doRefresh(false);

this.mainservice.getDistanceFromLatLonInKm(-27.3672616,-55.8915074, -27.3669613, -55.8925728)
this.mainservice.getDistanceFromLatLonInKm(-27.3672616, -55.8915074, -27.3669613, -55.8925728)


this.events.subscribe(this.mainservice.event_location_detected, (location) => {
Expand All @@ -73,6 +78,17 @@ export class PrincipalPage {
this.search = this.mainservice.currentLocalidad;
}


this.mainservice.getAll('localidades/publicaciones').then(
(response) => {
this.localidades = response;
if (response.length > 0) {
this.search = response[0].descripcion;
}

}
);

}

setCurrentLocalidad(lat, lng) {
Expand Down Expand Up @@ -109,21 +125,21 @@ export class PrincipalPage {

cancelarBusqueda() {
this.mainservice.currentLocalidad = this.search;
this.showSearch = false;

}

mostrarBusqueda() {
this.showSearch = true;
this.searchP.open();

console.log(this.searchP);

setTimeout(() => {
this.searchP.setFocus();
}, 150);
// console.log(this.searchP);
//
// setTimeout(() => {
// this.searchP.setFocus();
// }, 150);

}

getPublicaciones(userID, fields, loader, refresher) {
getPublicaciones(userID, fields, loader, refresher, error?) {
let resource = 'publicaciones/' + userID + '/persona'
this.mainservice.getAll(resource, fields)
.then(
Expand All @@ -138,7 +154,12 @@ export class PrincipalPage {
})
.catch(
(ex) => {
console.error('error publicaciones', ex);
console.error('error publicaciones', ex)

if (this.mainservice.isUndefined(error)) {
this.getPublicaciones(userID, fields, loader, refresher, true);
return;
}

this.errorNoConexion = true;
//this.publicaciones = [];
Expand All @@ -161,13 +182,13 @@ export class PrincipalPage {

doRefresh(refresher, fields?) {
let esperetxt = this.mainservice.getTranslate('espere');
if (esperetxt =='espere'){
if (esperetxt == 'espere') {
let lan = this.mainservice.getNavigatorLenguaje();
if (lan=='en'){
if (lan == 'en') {
esperetxt = 'Espere, por favor';
}else if (lan=='pt'){
} else if (lan == 'pt') {
esperetxt = 'Aguarde, por favor';
}else{
} else {
esperetxt = 'Please wait';
}
}
Expand Down

0 comments on commit a057668

Please sign in to comment.