<commit_before>import { Component, OnInit, ViewChild, OnDestroy, EventEmitter, Output } from '@angular/core';
import { MarkerComponent } from '../marker/marker.component';
import { MapService } from '../map.service';
import { MapListService } from '../../map-list/map-list.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CommonService } from '../../service/common.service';
import * as L from 'leaflet';
import { Subscription } from "rxjs/Subscription";
import { Observable, throwError } from 'rxjs';
import { Map, GeoJSON, Layer, FeatureGroup, Marker, LatLng } from 'leaflet';
import { DataFormService } from '@geonature_common/form/data-form.service';
//import { LieuxComponent } from '../lieux/lieux.component';




/**
 * Affiche une modale permettant d'aficher la liste des lieux enregistrés pour l'utilisateur actif, puis affiche le lieux sélectionnés sur la carte.
 *
 * Ce composant hérite du composant MarkerComponent: il dispose donc des mêmes inputs et outputs.
 */
@Component({
  selector: 'pnx-placesList',
  templateUrl: 'placesList.component.html'
})
export class PlacesListComponent extends MarkerComponent implements OnInit, OnDestroy {
  @ViewChild('modalContent') public modalContent: any;
  private geojsonSubscription$: Subscription;
  public geojson: any;
  public places:any[];
  public listPlacesSub: Subscription;
  public selectedPlace: GeoJSON.Feature ;
  public delPlaceSub: Subscription;
  public delPlaceRes:string;
  public place:GeoJSON.Feature;
  
  @Output() layerDrawed = new EventEmitter<GeoJSON>();

  constructor(
    public mapService: MapService,
    public modalService: NgbModal,
    public commonService: CommonService,
    private _dfs: DataFormService,
    private _mapListServive: MapListService
    
  ) {
    super(mapService, commonService);
  }

  ngOnInit() {
    this.map = this.mapservice.map;
    this.setPlacesLegend();
    
  }

  

  setPlacesLegend() {
    // icon
    const placesLegend = this.mapservice.addCustomLegend(
      'topleft',
      'ListPlacesLegend',
      'url(assets/images/liste.png)'
    );
    this.map.addControl(new placesLegend());
    document.getElementById('ListPlacesLegend').title = "Liste des lieux";
    L.DomEvent.disableClickPropagation(document.getElementById('ListPlacesLegend'));
       document.getElementById('ListPlacesLegend').onclick = () => {

     this.listPlacesSub = this._dfs.
      getPlaces()
      .subscribe(res => {
          this.places = res;
        },
        console.error
      );

    
      this.modalService.open(this.modalContent);
      
    };
  }

  loadPlace(){
    this.selectedPlace=this.place;

    //Bien cleaner tous les types de géométrie possible
    if (this.mapservice.marker !== undefined) {
      this.mapService.map.removeLayer(this.mapService.marker);
    }
    this.mapservice.removeAllLayers(this.map, this.mapService.leafletDrawFeatureGroup);
    this.mapservice.removeAllLayers(this.map, this.mapService.fileLayerFeatureGroup);

    this.mapservice.firstLayerFromMap = false;
    this.layerDrawed.emit(L.geoJSON(this.selectedPlace));
    this.mapService.loadGeometryReleve(this.selectedPlace, true);
  }

  deletePlace(){
    if(confirm("Êtes-vous sûr de vouloir supprimer ce lieu?")) {
        this._dfs.deletePlace(this.selectedPlace.id).subscribe(res => {
          this.commonService.translateToaster('success', 'Un lieu a été supprimé');
          this.listPlacesSub = this._dfs.
          getPlaces()
          .subscribe(res => {
              this.places = res;
            },
            console.error
          );
        }    
      );
    }
   }
<commit_msg>fix #984: btn valider ferme la modal<commit_after>import { Component, OnInit, ViewChild, OnDestroy, EventEmitter, Output } from '@angular/core';
import { MarkerComponent } from '../marker/marker.component';
import { MapService } from '../map.service';
import { MapListService } from '../../map-list/map-list.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CommonService } from '../../service/common.service';
import * as L from 'leaflet';
import { Subscription } from "rxjs/Subscription";
import { Observable, throwError } from 'rxjs';
import { Map, GeoJSON, Layer, FeatureGroup, Marker, LatLng } from 'leaflet';
import { DataFormService } from '@geonature_common/form/data-form.service';
//import { LieuxComponent } from '../lieux/lieux.component';




/**
 * Affiche une modale permettant d'aficher la liste des lieux enregistrés pour l'utilisateur actif, puis affiche le lieux sélectionnés sur la carte.
 *
 * Ce composant hérite du composant MarkerComponent: il dispose donc des mêmes inputs et outputs.
 */
@Component({
  selector: 'pnx-placesList',
  templateUrl: 'placesList.component.html'
})
export class PlacesListComponent extends MarkerComponent implements OnInit, OnDestroy {
  @ViewChild('modalContent') public modalContent: any;
  private geojsonSubscription$: Subscription;
  public geojson: any;
  public places:any[];
  public listPlacesSub: Subscription;
  public selectedPlace: GeoJSON.Feature ;
  public delPlaceSub: Subscription;
  public delPlaceRes:string;
  public place:GeoJSON.Feature;
  
  @Output() layerDrawed = new EventEmitter<GeoJSON>();

  constructor(
    public mapService: MapService,
    public modalService: NgbModal,
    public commonService: CommonService,
    private _dfs: DataFormService,
    private _mapListServive: MapListService
    
  ) {
    super(mapService, commonService);
  }

  ngOnInit() {
    this.map = this.mapservice.map;
    this.setPlacesLegend();
    
  }

  

  setPlacesLegend() {
    // icon
    const placesLegend = this.mapservice.addCustomLegend(
      'topleft',
      'ListPlacesLegend',
      'url(assets/images/liste.png)'
    );
    this.map.addControl(new placesLegend());
    document.getElementById('ListPlacesLegend').title = "Liste des lieux";
    L.DomEvent.disableClickPropagation(document.getElementById('ListPlacesLegend'));
       document.getElementById('ListPlacesLegend').onclick = () => {

     this.listPlacesSub = this._dfs.
      getPlaces()
      .subscribe(res => {
          this.places = res;
        },
        console.error
      );

    
      this.modalService.open(this.modalContent);
      
    };
  }

  loadPlace(){
    this.selectedPlace=this.place;

    //Bien cleaner tous les types de géométrie possible
    if (this.mapservice.marker !== undefined) {
      this.mapService.map.removeLayer(this.mapService.marker);
    }
    this.mapservice.removeAllLayers(this.map, this.mapService.leafletDrawFeatureGroup);
    this.mapservice.removeAllLayers(this.map, this.mapService.fileLayerFeatureGroup);

    this.mapservice.firstLayerFromMap = false;
    this.layerDrawed.emit(L.geoJSON(this.selectedPlace));
    this.mapService.loadGeometryReleve(this.selectedPlace, true);
    this.modalService.dismissAll();
  }

  deletePlace(){
    if(confirm("Êtes-vous sûr de vouloir supprimer ce lieu?")) {
        this._dfs.deletePlace(this.selectedPlace.id).subscribe(res => {
          this.commonService.translateToaster('success', 'Un lieu a été supprimé');
          this.listPlacesSub = this._dfs.
          getPlaces()
          .subscribe(res => {
              this.places = res;
            },
            console.error
          );
        }    
      );
    }
   }

{'fraction_non_alphanumeric': 0.11829717560376586, 'fraction_numerical': 0.00040933278755628325, 'mean_word_length': 3.4156626506024095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2894113', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2205, 'n_words': 463}