diff --git a/frontend/app/components/monitoring-form-g/monitoring-form.component-g.ts b/frontend/app/components/monitoring-form-g/monitoring-form.component-g.ts
index 6ef0d1724..29a8578e9 100644
--- a/frontend/app/components/monitoring-form-g/monitoring-form.component-g.ts
+++ b/frontend/app/components/monitoring-form-g/monitoring-form.component-g.ts
@@ -11,7 +11,7 @@ import { IDataForm } from '../../interfaces/form';
import { ApiGeomService } from '../../services/api-geom.service';
import { ConfigJsonService } from '../../services/config-json.service';
import { FormService } from '../../services/form.service';
-import { ObjectService } from '../../services/object.service';
+import { IExtraForm } from '../../interfaces/object';
@Component({
selector: 'pnx-monitoring-form-g',
@@ -34,6 +34,10 @@ export class MonitoringFormComponentG implements OnInit {
@Input() sites: {};
@Input() apiService: ApiGeomService;
+ @Input() isExtraForm:boolean = false;
+
+ extraForm: IExtraForm;
+ hideForm: boolean = false;
dataForm: IDataForm;
searchSite = '';
@@ -68,11 +72,16 @@ export class MonitoringFormComponentG implements OnInit {
tap((data) => {
this.obj = data;
this.obj.bIsInitialized = true;
- this.apiService.init(this.obj.endPoint, this.obj.objSelected);
+ this.obj.id = this.obj[this.obj.pk]
}),
- mergeMap((data: any) => this._configService.init(data.moduleCode))
+ mergeMap((data: any) => this._configService.init(data.moduleCode)),
+ mergeMap(() => this._formService.currentExtraFormCtrl )
)
- .subscribe(() => {
+ .subscribe((frmCtrl) => {
+
+ this.isExtraForm ? this.addExtraFormCtrl(frmCtrl) : null;
+ this.isExtraForm ? this.checkValidExtraFormCtrl() : null;
+
this.queryParams = this._route.snapshot.queryParams || {};
this.bChainInput = this._configService.frontendParams()['bChainInput'];
@@ -293,7 +302,6 @@ export class MonitoringFormComponentG implements OnInit {
onSubmit() {
const { patch_update, ...sendValue } = this.dataForm;
const objToUpdateOrCreate = this._formService.postData(sendValue, this.obj);
- console.log(objToUpdateOrCreate);
const action = this.obj.id
? this.apiService.patch(this.obj.id, objToUpdateOrCreate)
: this.apiService.create(objToUpdateOrCreate);
@@ -381,6 +389,25 @@ export class MonitoringFormComponentG implements OnInit {
this.procesPatchUpdateForm();
}
+ addExtraFormCtrl(frmCtrl: IExtraForm){
+ if (frmCtrl.frmName in this.objForm.controls){
+ this.objForm.setControl(frmCtrl.frmName,frmCtrl.frmCtrl)
+ } else{
+ this.objForm.addControl(frmCtrl.frmName,frmCtrl.frmCtrl)
+ }
+
+ this.extraForm = frmCtrl
+ }
+
+ checkValidExtraFormCtrl(){
+ if (this.extraForm.frmName in this.objForm.controls && this.objForm.get(this.extraForm.frmName).value != null && this.objForm.get(this.extraForm.frmName).value.length != 0 ){
+ this.hideForm = false
+ this.objForm.valid
+ } else {
+ this.hideForm = true
+ }
+}
+
getConfigFromBtnSelect(event) {
// this.obj.specific == undefined ? (this.obj.specific = {}) : null;
// TODO: Ajout de tous les id_parents ["id_sites_groups" etc ] dans l'objet obj.dataComplement
diff --git a/frontend/app/components/monitoring-sites-create/monitoring-sites-create.component.html b/frontend/app/components/monitoring-sites-create/monitoring-sites-create.component.html
index cd9a5bcd3..9f1edcf9f 100644
--- a/frontend/app/components/monitoring-sites-create/monitoring-sites-create.component.html
+++ b/frontend/app/components/monitoring-sites-create/monitoring-sites-create.component.html
@@ -8,6 +8,7 @@
diff --git a/frontend/app/components/monitoring-visits/monitoring-visits.component.html b/frontend/app/components/monitoring-visits/monitoring-visits.component.html
index 704a945a9..db5d49214 100644
--- a/frontend/app/components/monitoring-visits/monitoring-visits.component.html
+++ b/frontend/app/components/monitoring-visits/monitoring-visits.component.html
@@ -20,6 +20,7 @@
*ngIf="bEdit"
[(bEdit)]="bEdit"
[apiService]="siteService"
+ [isExtraForm]="true"
>
}) => {
this._objService.changeSelectedObj(data.site, true);
this.site = data.site;
+ this.types_site = data.site['types_site']
this.setVisits(data.visits);
this.baseFilters = { id_base_site: this.site.id_base_site };
});
@@ -163,7 +164,8 @@ export class MonitoringVisitsComponent extends MonitoringGeomComponent implement
}
initValueToSend(){
- return this.site['types_site']
+ this.initSiteVisit()
+ return this.types_site
}
updateForm(){
diff --git a/frontend/app/gnModule.module.ts b/frontend/app/gnModule.module.ts
index 0a4d64b09..6391f20ea 100644
--- a/frontend/app/gnModule.module.ts
+++ b/frontend/app/gnModule.module.ts
@@ -55,7 +55,7 @@ import { BtnSelectComponent } from "./components/btn-select/btn-select.component
import { MonitoringSitesEditComponent } from "./components/monitoring-sites-edit/monitoring-sites-edit.component";
import { MonitoringVisitsComponent } from "./components/monitoring-visits/monitoring-visits.component";
import { OptionListButtonComponent } from "./components/option-list-btn/option-list-btn.component";
-
+import { MatErrorMessagesDirective } from './utils/matErrorMessages.directive';
// my module routing
const routes: Routes = [
/** modules */
@@ -137,6 +137,7 @@ const routes: Routes = [
BtnSelectComponent,
MonitoringVisitsComponent,
OptionListButtonComponent,
+ MatErrorMessagesDirective
],
imports: [
GN2CommonModule,
diff --git a/frontend/app/interfaces/object.ts b/frontend/app/interfaces/object.ts
index cec2af00d..603c59db8 100644
--- a/frontend/app/interfaces/object.ts
+++ b/frontend/app/interfaces/object.ts
@@ -1,3 +1,4 @@
+import { AbstractControl } from "@angular/forms";
import { JsonData } from "../types/jsondata";
import { IPaginated } from "./page";
import { GeoJSON } from "geojson";
@@ -23,3 +24,5 @@ export type SelectObject = {
label: string;
};
+
+export type IExtraForm = {frmCtrl :AbstractControl,frmName:string}
diff --git a/frontend/app/services/form.service.ts b/frontend/app/services/form.service.ts
index c8d6b0ff5..0798b10df 100644
--- a/frontend/app/services/form.service.ts
+++ b/frontend/app/services/form.service.ts
@@ -3,23 +3,29 @@ import { BehaviorSubject, Observable, forkJoin, of } from 'rxjs';
import { concatMap } from 'rxjs/operators';
import { ISite, ISitesGroup } from '../interfaces/geom';
-import { IobjObs, ObjDataType } from '../interfaces/objObs';
import { JsonData } from '../types/jsondata';
import { Utils } from '../utils/utils';
import { MonitoringObjectService } from './monitoring-object.service';
+import { FormControl } from '@angular/forms';
+import { IExtraForm } from '../interfaces/object';
+
@Injectable()
export class FormService {
data: JsonData = {};
+ frmCtrl: FormControl = new FormControl(null);
+ frmCtrlName: string = '';
private dataSub = new BehaviorSubject