|
|
|
@@ -1,4 +1,4 @@ |
|
|
|
import { Component, OnInit, ViewChild,ElementRef } from '@angular/core'; |
|
|
|
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; |
|
|
|
import { MallService } from '../services/mall.service'; |
|
|
|
import { ToastService } from '../services/toast.service'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
@@ -32,23 +32,23 @@ export class MallsPage implements OnInit { |
|
|
|
|
|
|
|
async presentLoading() { |
|
|
|
this.loader = await this.loadingController.create({ |
|
|
|
message: 'Please wait...', |
|
|
|
spinner: 'dots', |
|
|
|
mode: 'ios' |
|
|
|
message: 'Please wait...', |
|
|
|
spinner: 'dots', |
|
|
|
mode: 'ios' |
|
|
|
}); |
|
|
|
await this.loader.present(); |
|
|
|
} |
|
|
|
|
|
|
|
async presentAlert(message: string) { |
|
|
|
const alert = await this.alertController.create({ |
|
|
|
message: message, |
|
|
|
mode: 'ios', |
|
|
|
buttons: ['OK'] |
|
|
|
message: message, |
|
|
|
mode: 'ios', |
|
|
|
buttons: ['OK'] |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await alert.present(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getMallsByFoodType(type: string) { |
|
|
|
this.selectedFoodType = type; |
|
|
|
this.mallService.mallsByTypes(type).then((response: Array<any>) => { |
|
|
|
@@ -81,15 +81,15 @@ export class MallsPage implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
toggleSearchBar() { |
|
|
|
if (this.searchTerm.length > 0) { |
|
|
|
this.searchTerm = ''; |
|
|
|
this.tempMalls = JSON.parse(JSON.stringify(this.allMalls)); |
|
|
|
} else { |
|
|
|
this.showSearchBar = !this.showSearchBar; |
|
|
|
setTimeout(()=>{ // this will make the execution after the above boolean has changed |
|
|
|
this.searchElement.nativeElement.focus(); |
|
|
|
}, 1); |
|
|
|
} |
|
|
|
if (this.searchTerm.length > 0) { |
|
|
|
this.searchTerm = ''; |
|
|
|
this.tempMalls = JSON.parse(JSON.stringify(this.allMalls)); |
|
|
|
} else { |
|
|
|
this.showSearchBar = !this.showSearchBar; |
|
|
|
setTimeout(() => { // this will make the execution after the above boolean has changed |
|
|
|
this.searchElement.nativeElement.focus(); |
|
|
|
}, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
searchAllMalls() { |
|
|
|
@@ -112,14 +112,14 @@ export class MallsPage implements OnInit { |
|
|
|
|
|
|
|
window.navigator['share'](shareData); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getMallsByLocation() { |
|
|
|
if (navigator.geolocation) { |
|
|
|
if (navigator.geolocation) { |
|
|
|
navigator.geolocation.getCurrentPosition((position) => { |
|
|
|
this.presentLoading(); |
|
|
|
this.mallService.mallsByLocation(position.coords.latitude, position.coords.longitude).then((response: any) => { |
|
|
|
if (response.length > 0) { |
|
|
|
if (response.length > 0) { |
|
|
|
this.allMalls = response; |
|
|
|
this.tempMalls = response; |
|
|
|
this.loader ? this.loader.dismiss() : null; |
|
|
|
@@ -146,6 +146,7 @@ export class MallsPage implements OnInit { |
|
|
|
getAllMalls() { |
|
|
|
this.mallService.allMalls().then((response) => { |
|
|
|
this.allMalls = response; |
|
|
|
localStorage.setItem("malls", JSON.stringify(this.allMalls)) |
|
|
|
this.tempMalls = response; |
|
|
|
this.loader ? this.loader.dismiss() : null; |
|
|
|
}, (error) => { |
|
|
|
@@ -160,19 +161,19 @@ export class MallsPage implements OnInit { |
|
|
|
|
|
|
|
sortBy(type: string) { |
|
|
|
this.selected_sort = type; |
|
|
|
switch(this.selected_sort) { |
|
|
|
case 'name': this.tempMalls.sort(function(a: any, b: any){ |
|
|
|
if(a.mall.mall_name < b.mall.mall_name) { return -1; } |
|
|
|
if(a.mall.mall_name > b.mall.mall_name) { return 1; } |
|
|
|
switch (this.selected_sort) { |
|
|
|
case 'name': this.tempMalls.sort(function (a: any, b: any) { |
|
|
|
if (a.mall.mall_name < b.mall.mall_name) { return -1; } |
|
|
|
if (a.mall.mall_name > b.mall.mall_name) { return 1; } |
|
|
|
return 0; |
|
|
|
}); |
|
|
|
break; |
|
|
|
case 'rating': this.tempMalls.sort(function(a: any, b: any){ |
|
|
|
if(a.mall.rating < b.mall.rating) { return -1; } |
|
|
|
if(a.mall.rating > b.mall.rating) { return 1; } |
|
|
|
break; |
|
|
|
case 'rating': this.tempMalls.sort(function (a: any, b: any) { |
|
|
|
if (a.mall.rating < b.mall.rating) { return -1; } |
|
|
|
if (a.mall.rating > b.mall.rating) { return 1; } |
|
|
|
return 0; |
|
|
|
}).reverse(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|