Skip to content
Snippets Groups Projects
Commit e2244d3d authored by Antonin COQUET's avatar Antonin COQUET
Browse files

add querystring to route param

parent 8bf82fdb
No related branches found
No related tags found
3 merge requests!178release V1.10.0,!135Dev,!122Feat/structure query param
...@@ -9,6 +9,8 @@ import { Filter } from '../../models/filter.model'; ...@@ -9,6 +9,8 @@ import { Filter } from '../../models/filter.model';
import { Module } from '../../models/module.model'; import { Module } from '../../models/module.model';
import { StructureCounter } from '../../models/structureCounter.model'; import { StructureCounter } from '../../models/structureCounter.model';
import { SearchService } from '../../services/search.service'; import { SearchService } from '../../services/search.service';
import { Location } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'app-structure-list-search', selector: 'app-structure-list-search',
...@@ -36,20 +38,34 @@ export class SearchComponent implements OnInit, OnChanges { ...@@ -36,20 +38,34 @@ export class SearchComponent implements OnInit, OnChanges {
public numberAccompanimentChecked = 0; public numberAccompanimentChecked = 0;
public numberMoreFiltersChecked = 0; public numberMoreFiltersChecked = 0;
public queryString = 'placeholder';
// Modal confirmation variable // Modal confirmation variable
public isConfirmationModalOpen = false; public isConfirmationModalOpen = false;
public confirmationModalContent = public confirmationModalContent =
'Afin d’ajouter votre structure,vous allez être redirigé vers le formulaire Grand Lyon à remplir.'; 'Afin d’ajouter votre structure,vous allez être redirigé vers le formulaire Grand Lyon à remplir.';
constructor(public searchService: SearchService, private fb: FormBuilder, private geoJsonService: GeojsonService) { constructor(
public searchService: SearchService,
private fb: FormBuilder,
private geoJsonService: GeojsonService,
private activatedRoute: ActivatedRoute,
private location: Location
) {
this.searchForm = this.fb.group({ this.searchForm = this.fb.group({
searchTerm: '', searchTerm: '',
}); });
} }
ngOnInit(): void { ngOnInit(): void {
// Will store the different categories // Will store the different categories
this.queryString = this.activatedRoute.snapshot.queryParamMap.get('search');
this.categories = []; this.categories = [];
this.checkedModulesFilter = new Array(); this.checkedModulesFilter = new Array();
if (this.queryString) {
console.log('we search', this.queryString);
const filters: Filter[] = [];
filters.push(new Filter('query', this.queryString));
this.searchEvent.emit(filters);
}
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
...@@ -75,6 +91,13 @@ export class SearchComponent implements OnInit, OnChanges { ...@@ -75,6 +91,13 @@ export class SearchComponent implements OnInit, OnChanges {
// Sends an array containing all filters // Sends an array containing all filters
public applyFilter(term: string): void { public applyFilter(term: string): void {
// Add search input filter // Add search input filter
if (term) {
this.location.go('/acteurs?search=' + term);
} else {
this.location.go('/acteurs');
}
this.queryString = this.activatedRoute.snapshot.queryParamMap.get('search');
console.log('query string is:', this.queryString);
const filters: Filter[] = []; const filters: Filter[] = [];
if (term) { if (term) {
filters.push(new Filter('query', term)); filters.push(new Filter('query', term));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment