Skip to content

Commit

Permalink
consistency of id_synthese field name
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Mar 8, 2024
1 parent 4dd7665 commit c7b7e6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ export class SyntheseCarteComponent implements OnInit, AfterViewInit, OnChanges,

onEachFeature(feature, layer) {
// make a cache a layers in a dict with id key
this.layerDictCache(feature.properties.observations.id, layer);
this.layerDictCache(feature.properties.observations.id_synthese, layer);
// set style
if (this.areasEnable) {
this.setAreasStyle(layer, feature.properties.observations.id.length);
this.setAreasStyle(layer, feature.properties.observations.id_synthese.length);
}
this.layerEvent(feature, layer, feature.properties.observations.id);
this.layerEvent(feature, layer, feature.properties.observations.id_synthese);
}

/**
Expand Down Expand Up @@ -323,7 +323,7 @@ export class SyntheseCarteComponent implements OnInit, AfterViewInit, OnChanges,
const geojsonLayer = new L.GeoJSON(change.inputSyntheseData.currentValue, {
pointToLayer: (feature, latlng) => {
const circleMarker = L.circleMarker(latlng);
let countObs = feature.properties.observations.id.length;
let countObs = feature.properties.observations.id_synthese.length;
(circleMarker as any).nb_obs = countObs;
circleMarker.bindTooltip(`${countObs}`, {
permanent: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export class SyntheseListComponent implements OnInit, OnChanges, AfterContentChe
this.mapListService.tableData.map((row) => {
// mandatory to sort (each row must have a selected attr)
row.selected = false;
if (ids.includes(row.id)) {
if (ids.includes(row.id_synthese)) {
row.selected = true;
}
});

let observations = this.mapListService.tableData.filter((e) => {
return ids.includes(e.id);
return ids.includes(e.id_synthese);
});

this.mapListService.tableData.sort((a, b) => {
Expand All @@ -83,7 +83,7 @@ export class SyntheseListComponent implements OnInit, OnChanges, AfterContentChe
this.mapListService.selectedRow = observations;
const page = Math.trunc(
this.mapListService.tableData.findIndex((e) => {
return e.id === ids[0];
return e.id_synthese === ids[0];
}) / this.rowNumber
);
this.table.offset = page;
Expand Down Expand Up @@ -111,7 +111,7 @@ export class SyntheseListComponent implements OnInit, OnChanges, AfterContentChe
*/
onSort(event) {
if (event.newValue === undefined) {
let selectedObsIds = this.mapListService.selectedRow.map((obs) => obs.id);
let selectedObsIds = this.mapListService.selectedRow.map((obs) => obs.id_synthese);
this.mapListService.mapSelected.next(selectedObsIds);
}
}
Expand All @@ -133,7 +133,7 @@ export class SyntheseListComponent implements OnInit, OnChanges, AfterContentChe
}

openInfoModal(row) {
row.id_synthese = row.id;
row.id_synthese = row.id_synthese;
const modalRef = this.ngbModal.open(SyntheseInfoObsComponent, {
size: 'lg',
windowClass: 'large-modal',
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/app/syntheseModule/synthese.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class SyntheseComponent implements OnInit {
this._mapListService.geojsonData = this.simplifyGeoJson(cloneDeep(data));
this.formatDataForTable(data);

this._mapListService.idName = 'id';
this._mapListService.idName = 'id_synthese';
this.searchService.dataLoaded = true;
},
() => {
Expand All @@ -137,9 +137,9 @@ export class SyntheseComponent implements OnInit {
const idSynthese = new Set();
geojson.features.forEach((feature) => {
feature.properties.observations.forEach((obs) => {
if (!idSynthese.has(obs.id)) {
if (!idSynthese.has(obs.id_synthese)) {
this._mapListService.tableData.push(obs);
idSynthese.add(obs.id);
idSynthese.add(obs.id_synthese);
}
});
});
Expand Down Expand Up @@ -190,7 +190,7 @@ export class SyntheseComponent implements OnInit {
let ids = [];
for (let feature of geojson.features) {
feature.properties.observations.forEach((obs) => {
ids.push(obs['id']);
ids.push(obs['id_synthese']);
});
}
return ids;
Expand All @@ -205,11 +205,11 @@ export class SyntheseComponent implements OnInit {

let ids = [];
for (let obs of Object.values(feature.properties.observations)) {
if (obs['id']) {
ids.push(obs['id']);
if (obs['id_synthese']) {
ids.push(obs['id_synthese']);
}
}
feature.properties.observations = { id: ids };
feature.properties.observations = { id_synthese: ids };
}
if (noGeomMessage) {
this._toasterService.warning(
Expand Down

0 comments on commit c7b7e6c

Please sign in to comment.