Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ import { Location } from '@angular/common';
import { FormService } from '../../services/form.service';
import { Router } from '@angular/router';
import { TOOLTIPMESSAGEALERT, TOOLTIPMESSAGEALERT_CHILD } from '../../constants/guard';
import { GeoJSONService } from '../../services/geojson.service';
import { GeoJSONService, DisplayMode } from '../../services/geojson.service';
import { Utils } from '../../utils/utils';
import { Popup } from '../../utils/popup';

@Component({
selector: 'pnx-monitoring-form',
Expand Down Expand Up @@ -116,7 +117,8 @@ export class MonitoringFormComponent implements OnInit {
private _router: Router,
private _geojsonService: GeoJSONService,
private _location: Location,
private translate: TranslateService
private translate: TranslateService,
private _popup: Popup
) {}

ngOnInit() {
Expand Down Expand Up @@ -262,6 +264,7 @@ export class MonitoringFormComponent implements OnInit {
const dynamicGroupsArray = this.objForm.get('dynamicGroups') as FormArray;
if (dynamicGroupsArray) this.subscribeToDynamicGroupsChanges(dynamicGroupsArray);
this.setDefaultFormValue();
this.display_geometry();
});
}

Expand All @@ -276,6 +279,66 @@ export class MonitoringFormComponent implements OnInit {
});
}

display_geometry() {
// Affichage des
let displayType: DisplayMode = 'info';
if (!this.obj.id) {
displayType = 'info_zoom';
}
if (!['sites_group', 'site'].includes(this.obj.objectType)) {
return;
}
if (this.obj.objectType == 'sites_group') {
this._geojsonService.getSitesGroupsGeometries(this.onEachFeatureGroupSite(), {}, displayType);
}
if (this.obj.objectType == 'site') {
// Get id_sites_group
const id_sites_group =
this.queryParams['id_sites_group'] || this.obj.properties['id_sites_group'];

// S'il y a un id_site group
// et qu'il est spécifié dans les parents_path
// Affichage
if (
id_sites_group &&
('id_sites_group' in this.queryParams ||
(this.queryParams['parents_path'] || []).includes('sites_group'))
) {
// Display sites group and sites
this._geojsonService.getSitesGroupsGeometriesWithSites(
this.onEachFeatureGroupSite(),
this.onEachFeatureSite(),
{ id_sites_group: id_sites_group },
{ id_sites_group: id_sites_group },
displayType
);
} else {
// Display site
this._geojsonService.getSitesGroupsChildGeometries(
this.onEachFeatureSite(),
{},
displayType
);
}
}
}
onEachFeatureSite() {
return (feature, layer) => {
const popup = this._popup.setSitePopup(this.obj.moduleCode, feature, {
parents_path: ['module', 'sites_group'],
});
layer.bindPopup(popup);
};
}
onEachFeatureGroupSite() {
return (feature, layer) => {
const popup = this._popup.setSiteGroupPopup(this.obj.moduleCode, feature, {
parents_path: ['module', 'sites_group'],
});
layer.bindPopup(popup);
};
}

/** pour réutiliser des paramètres déjà saisis */
keepDefinitions() {
return this.objFormsDefinition.filter((def) =>
Expand Down Expand Up @@ -378,7 +441,8 @@ export class MonitoringFormComponent implements OnInit {
}
this.objForm.patchValue({ geometry: null });
this.initForm();
// });
// Force le rafraichissement des géométries de façon à ammender le layer avec la dernière données saisie
this.display_geometry();
}

/** Pour donner des valeurs par defaut si la valeur n'est pas définie
Expand Down Expand Up @@ -888,6 +952,7 @@ export class MonitoringFormComponent implements OnInit {
}

ngOnDestroy() {
this._geojsonService.removeAllFeatureGroup();
this.objForm.patchValue({ geometry: null });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ export class MonitoringSitesDetailComponent extends MonitoringGeomComponent impl
if (this.parentsPath.includes('sites_group')) {
this.siteGroupIdParent = data.site.id_sites_group;
}
// if (this.siteGroupIdParent) {
// // Quand il y a un group de site défini affichage du groupes de sites
// // et autre sites associés pour avoir des repères
// this.geojsonService.getSitesGroupsGeometriesWithSites(
// this.onEachFeatureSite(),
// this.onEachFeatureSite(),
// { id_sites_group: this.siteGroupIdParent },
// { id_sites_group: this.siteGroupIdParent },
// true
// );
// }

// ajout des propriétés spécifiques au type de site
// dans l'objet MonitoringObject
Expand Down
Loading