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

Merge branch 'feat/structure-query-param' into 'dev'

Feat/structure query param

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!122
parents f57fb5b2 4cafe7d7
Branches
Tags
3 merge requests!178release V1.10.0,!135Dev,!122Feat/structure query param
......@@ -17,7 +17,7 @@ export class PanelComponent implements OnInit {
this.selectedFeature = this.features.pendingStructures;
}
public changeActiveFeature(newFeature: AdminPannelEnum) {
public changeActiveFeature(newFeature: AdminPannelEnum): void {
this.selectedFeature = newFeature;
}
}
......@@ -8,6 +8,7 @@ import { Filter } from '../structure-list/models/filter.model';
import { GeoJson } from '../map/models/geojson.model';
import { GeojsonService } from '../services/geojson.service';
import { CustomRegExp } from '../utils/CustomRegExp';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-carto',
......@@ -26,14 +27,21 @@ export class CartoComponent implements OnInit {
public isMapPhone = false;
public searchedValue = null;
public locate = false; // Use to sync location between search and map
constructor(private structureService: StructureService, private geoJsonService: GeojsonService) {}
constructor(
private structureService: StructureService,
private geoJsonService: GeojsonService,
private activatedRoute: ActivatedRoute
) {}
ngOnInit(): void {
if (navigator.geolocation) {
this.getLocation();
} else {
this.getStructures(null);
if (!this.activatedRoute.snapshot.queryParamMap.get('search')) {
if (navigator.geolocation) {
this.getLocation();
} else {
this.getStructures(null);
}
}
if (history.state.data) {
this.currentStructure = new Structure(history.state.data);
}
......
......@@ -45,11 +45,17 @@ export class CardComponent implements OnInit {
public cardClicked(): void {
this.showDetails.emit(this.structure);
const queryString = this.route.snapshot.queryParamMap.get('search');
this.router.navigate([], {
relativeTo: this.route,
queryParams: {
id: this.structure._id,
},
queryParams: queryString
? {
id: this.structure._id,
search: queryString,
}
: {
id: this.structure._id,
},
});
}
......
......@@ -130,8 +130,12 @@ export class StructureDetailsComponent implements OnInit {
}
public close(): void {
this.router.navigate([], {
this.router.navigate(['/acteurs'], {
relativeTo: this.route,
queryParams: {
id: null,
},
queryParamsHandling: 'merge',
});
}
......
......@@ -9,6 +9,8 @@ import { Filter } from '../../models/filter.model';
import { Module } from '../../models/module.model';
import { StructureCounter } from '../../models/structureCounter.model';
import { SearchService } from '../../services/search.service';
import { Location } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-structure-list-search',
......@@ -36,20 +38,35 @@ export class StructureListSearchComponent implements OnInit, OnChanges {
public numberAccompanimentChecked = 0;
public numberMoreFiltersChecked = 0;
public queryString: string;
// Modal confirmation variable
public isConfirmationModalOpen = false;
public confirmationModalContent =
'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,
private route: ActivatedRoute,
private router: Router
) {
this.searchForm = this.fb.group({
searchTerm: '',
});
}
ngOnInit(): void {
// Will store the different categories
this.queryString = this.activatedRoute.snapshot.queryParamMap.get('search');
this.categories = [];
this.checkedModulesFilter = new Array();
if (this.queryString) {
const filters: Filter[] = [];
filters.push(new Filter('query', this.queryString));
this.searchEvent.emit(filters);
}
}
ngOnChanges(changes: SimpleChanges): void {
......@@ -75,6 +92,15 @@ export class StructureListSearchComponent implements OnInit, OnChanges {
// Sends an array containing all filters
public applyFilter(term: string): void {
// Add search input filter
if (term) {
this.router.navigate(['/acteurs'], {
relativeTo: this.route,
queryParams: {
search: term,
},
queryParamsHandling: 'merge',
});
}
const filters: Filter[] = [];
if (term) {
filters.push(new Filter('query', term));
......
......@@ -16,7 +16,7 @@
<app-card
*ngFor="let structure of structuresListChunked"
[structure]="structure"
(showDetails)="showDetails($event)"
(showDetails)="showDetails($event, filters)"
(hover)="handleCardHover($event)"
></app-card>
<p *ngIf="structureList && structureList.length <= 0">Il n'y a aucune réponse correspondant à votre recherche</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment