Commit bbbe39b7 by Nabil Sadki

Offres : filters

parent acb1c015
...@@ -17,7 +17,8 @@ const routes: Routes = [ ...@@ -17,7 +17,8 @@ const routes: Routes = [
loadChildren: './pages/offres/offre-details/offre-details.module#OffreDetailsPageModule', loadChildren: './pages/offres/offre-details/offre-details.module#OffreDetailsPageModule',
canActivate: [AuthGuardService] canActivate: [AuthGuardService]
}, },
{ path: 'login-help', loadChildren: './modals/login-help/login-help.module#LoginHelpPageModule' }, { path: 'login-help', loadChildren: './modals/login-help/login-help.module#LoginHelpPageModule' }, { path: 'offres-carte-filters', loadChildren: './modals/offres-carte-filters/offres-carte-filters.module#OffresCarteFiltersPageModule' },
]; ];
......
...@@ -29,6 +29,7 @@ import { environment } from 'src/environments/environment'; ...@@ -29,6 +29,7 @@ import { environment } from 'src/environments/environment';
import { AuthService } from './services/auth.service'; import { AuthService } from './services/auth.service';
import { AuthGuardService } from './services/auth-guard.service'; import { AuthGuardService } from './services/auth-guard.service';
import { LoginHelpPageModule } from './modals/login-help/login-help.module'; import { LoginHelpPageModule } from './modals/login-help/login-help.module';
import { OffresCarteFiltersPageModule } from './modals/offres-carte-filters/offres-carte-filters.module';
// import { AngularFireAuthModule } from '@angular/fire/auth'; // import { AngularFireAuthModule } from '@angular/fire/auth';
// import * as firebase from 'firebase'; // import * as firebase from 'firebase';
...@@ -41,13 +42,15 @@ import { LoginHelpPageModule } from './modals/login-help/login-help.module'; ...@@ -41,13 +42,15 @@ import { LoginHelpPageModule } from './modals/login-help/login-help.module';
imports: [ imports: [
BrowserModule, BrowserModule,
IonicModule.forRoot(), IonicModule.forRoot(),
AppRoutingModule, LotsAGagnerFilterPageModule, AppRoutingModule,
IonicStorageModule.forRoot({ IonicStorageModule.forRoot({
name: '__allo_testeurs_app', name: '__allo_testeurs_app',
driverOrder: ['websql', 'sqlite', 'indexeddb'] driverOrder: ['websql', 'sqlite', 'indexeddb']
}), }),
HttpClientModule, HttpClientModule,
LoginHelpPageModule LotsAGagnerFilterPageModule,
LoginHelpPageModule,
OffresCarteFiltersPageModule
], ],
providers: [ providers: [
StatusBar, StatusBar,
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
</ion-menu-button> </ion-menu-button>
</ion-buttons> </ion-buttons>
<ion-buttons slot="end"> <!-- <ion-buttons slot="end">
<ion-button (click)="showHideMoreFilters()"> <ion-button (click)="showHideMoreFilters()">
<ion-icon name="options"></ion-icon> <ion-icon name="options"></ion-icon>
</ion-button> </ion-button>
</ion-buttons> </ion-buttons> -->
<!--<ion-title>--> <!--<ion-title>-->
<!--<span ion-text>Super promos!</span>--> <!--<span ion-text>Super promos!</span>-->
<!--<ion-searchbar hidden [(ngModel)]="terms" placeholder="Rechercher"></ion-searchbar>--> <!--<ion-searchbar hidden [(ngModel)]="terms" placeholder="Rechercher"></ion-searchbar>-->
......
...@@ -108,6 +108,11 @@ ...@@ -108,6 +108,11 @@
</ion-item> </ion-item>
</ion-card> </ion-card>
</div> </div>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button (click)="presentFiltersModal()">
<ion-icon name="funnel"></ion-icon>
</ion-fab-button>
</ion-fab>
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)"> <ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Chargement..."> <ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Chargement...">
</ion-infinite-scroll-content> </ion-infinite-scroll-content>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
justify-content: center; justify-content: center;
} }
ion-img { ion-img {
height: 10rem; height: 15rem;
background: var(--ion-color-tertiary, #989aa2); background: var(--ion-color-tertiary, #989aa2);
object-fit: cover; object-fit: cover;
} }
......
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { ToastController, IonInfiniteScroll } from '@ionic/angular'; import { ToastController, IonInfiniteScroll, ModalController } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { AlloService } from '../../../services/allo-service'; import { AlloService } from '../../../services/allo-service';
import { AuthService } from '../../../services/auth.service'; import { AuthService } from '../../../services/auth.service';
import { TripService } from '../../../services/trip-service'; import { TripService } from '../../../services/trip-service';
import { Storage } from '@ionic/storage'; import { OffresCarteFiltersPage } from '../../../modals/offres-carte-filters/offres-carte-filters.page';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-offres-carte', selector: 'app-offres-carte',
...@@ -20,6 +21,7 @@ export class OffresCartePage implements OnInit { ...@@ -20,6 +21,7 @@ export class OffresCartePage implements OnInit {
public _ALLO: AlloService, public _ALLO: AlloService,
public _AUTH: AuthService, public _AUTH: AuthService,
public _TRIP: TripService, public _TRIP: TripService,
public modalController: ModalController,
public toastCtrl: ToastController, public toastCtrl: ToastController,
private router: Router, private router: Router,
private storage: Storage) { } private storage: Storage) { }
...@@ -55,6 +57,14 @@ export class OffresCartePage implements OnInit { ...@@ -55,6 +57,14 @@ export class OffresCartePage implements OnInit {
toast.present(); toast.present();
} }
async presentFiltersModal() {
const modal = await this.modalController.create({
component: OffresCarteFiltersPage,
cssClass: 'modal-filters'
});
return await modal.present();
}
async doRefresh(refresher) { async doRefresh(refresher) {
try { try {
this.toast.dismiss(); this.toast.dismiss();
......
...@@ -66,8 +66,7 @@ export class TripService { ...@@ -66,8 +66,7 @@ export class TripService {
}); });
}); });
setTimeout(() => { setTimeout(() => {
this.filtredProducts = this.products; this.resetData();
this.offersCardList = this.filtredProducts.slice(0, 2);
}, 2000); }, 2000);
} }
if (null !== data && 'object' === typeof data && data.hasOwnProperty('cats')) { if (null !== data && 'object' === typeof data && data.hasOwnProperty('cats')) {
...@@ -82,6 +81,11 @@ export class TripService { ...@@ -82,6 +81,11 @@ export class TripService {
} }
} }
resetData() {
this.filtredProducts = this.products;
this.offersCardList = this.filtredProducts.slice(0, 2);
}
getRequest() { getRequest() {
if (this.platform.is('cordova')) { if (this.platform.is('cordova')) {
return this.httpAdv.get('http://www.allo-testeurs.com/services.json?' + Math.random(), {}, {}); return this.httpAdv.get('http://www.allo-testeurs.com/services.json?' + Math.random(), {}, {});
...@@ -117,8 +121,24 @@ export class TripService { ...@@ -117,8 +121,24 @@ export class TripService {
} }
filterList(categoryId) { filterList(categoryId) {
this.filtredProducts = this.products.filter(item => { console.log(this.products);
return item.categories_ids.includes(categoryId) || categoryId === 'all';
this.filtredProducts = this.filterByCategoryId(categoryId);
this.offersCardList = this.filtredProducts.slice(0, 2);
this.offersCardListPointer = 1;
}
filterByCategoryId(categoryId) {
return this.filtredProducts.filter(item => {
return item.categories_ids.includes(parseInt(categoryId)) || categoryId === 'all';
});
}
filterByBrandId(brandId) {
console.log(brandId);
this.filtredProducts = this.filtredProducts.filter(item => {
return item.brand_id === brandId || brandId === 'all';
}); });
this.offersCardList = this.filtredProducts.slice(0, 2); this.offersCardList = this.filtredProducts.slice(0, 2);
this.offersCardListPointer = 1; this.offersCardListPointer = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment