diff --git a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.html b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.html index efc06d7332..691717c737 100644 --- a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.html +++ b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.html @@ -168,7 +168,18 @@
Correspondance des champs avec le modèle
- + + + + {{ entitythemes.entity.label }} + +
diff --git a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.scss b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.scss index 39796ad922..f8e9f499f8 100644 --- a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.scss +++ b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.scss @@ -110,4 +110,9 @@ ng-select span.in_use { &__content { padding: 1em; } + + .entity-tab-label { + padding: 4px; + } + } diff --git a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.ts b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.ts index 943e052445..1cb3e617a7 100644 --- a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.ts +++ b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/fields-mapping-step.component.ts @@ -48,6 +48,7 @@ export class FieldsMappingStepComponent implements OnInit { public fieldMappingForm = new FormControl(); // form to select the mapping to use public mappingFormControl: FormGroup; // form group to associate each source fields to import fields public createOrRenameMappingForm = new FormControl(null, [Validators.required]); // form to add a new mapping + public entitiesForms: Record = {}; public modalCreateMappingForm = new FormControl(''); public displayAllValues: boolean = false; // checkbox to (not) show fields associated by the selected mapping @@ -144,11 +145,26 @@ export class FieldsMappingStepComponent implements OnInit { ); } + /** + * Count the number of invalid controls + * in an entity FormGroup + */ + invalidEntityControls(entityFormLabel: string) { + let result: number = 0; + let entityForm = this.entitiesForms[entityFormLabel]; + + Object.values(entityForm.controls).forEach((c) => { + result += c.invalid ? 1 : 0; + }); + return result; + } + /** * A function to populate the mapping form based on target fields. */ populateMappingForm() { this.targetFields.forEach((entity) => { + this.entitiesForms[entity.entity.label] = this._fb.group({}); entity.themes.forEach(({ fields }) => { fields.forEach((field) => { const { name_field, autogenerated } = field; @@ -162,6 +178,7 @@ export class FieldsMappingStepComponent implements OnInit { this.onFieldMappingChange(name_field, value); }); this.mappingFormControl.addControl(name_field, control); + this.entitiesForms[entity.entity.label].addControl(name_field, control); } else { // If a control with a given name already exists, it would not be replaced with a new one. // The existing one will be updated with a new obser. We make sure to sync the references of it. diff --git a/frontend/src/app/modules/imports/models/cruved.model.ts b/frontend/src/app/modules/imports/models/cruved.model.ts index 54505d6db5..2d428e38f9 100644 --- a/frontend/src/app/modules/imports/models/cruved.model.ts +++ b/frontend/src/app/modules/imports/models/cruved.model.ts @@ -16,12 +16,13 @@ export interface CruvedWithScope { D: number; } -export function toBooleanCruved(cruved: CruvedWithScope,compare_function:Function = (c)=> c>0): Cruved { +export function toBooleanCruved( + cruved: CruvedWithScope, + compare_function: Function = (c) => c > 0 +): Cruved { return Object.assign( {}, - ...Object.entries( - cruved as CruvedWithScope - ).map(([key, value]) => ({ + ...Object.entries(cruved as CruvedWithScope).map(([key, value]) => ({ [key]: value > 0, })) ); diff --git a/frontend/src/app/modules/imports/services/data.service.ts b/frontend/src/app/modules/imports/services/data.service.ts index 92bde5934f..7c2970483b 100644 --- a/frontend/src/app/modules/imports/services/data.service.ts +++ b/frontend/src/app/modules/imports/services/data.service.ts @@ -85,7 +85,10 @@ export class ImportDataService { } updateImport(idImport, data): Observable { - return this._http.post(`${this.getUrlApiForADestination()}/imports/${idImport}/update`, data); + return this._http.post( + `${this.getUrlApiForADestination()}/imports/${idImport}/update`, + data + ); } createFieldMapping(name: string, values: FieldMappingValues): Observable { @@ -107,15 +110,21 @@ export class ImportDataService { } getContentMappings(): Observable> { - return this._http.get>(`${this.getUrlApiForADestination()}/contentmappings/`); + return this._http.get>( + `${this.getUrlApiForADestination()}/contentmappings/` + ); } getFieldMapping(id_mapping: number): Observable { - return this._http.get(`${this.getUrlApiForADestination()}/fieldmappings/${id_mapping}/`); + return this._http.get( + `${this.getUrlApiForADestination()}/fieldmappings/${id_mapping}/` + ); } getContentMapping(id_mapping: number): Observable { - return this._http.get(`${this.getUrlApiForADestination()}/contentmappings/${id_mapping}/`); + return this._http.get( + `${this.getUrlApiForADestination()}/contentmappings/${id_mapping}/` + ); } updateFieldMapping( @@ -157,11 +166,15 @@ export class ImportDataService { } deleteFieldMapping(id_mapping: number): Observable { - return this._http.delete(`${this.getUrlApiForADestination()}/fieldmappings/${id_mapping}/`); + return this._http.delete( + `${this.getUrlApiForADestination()}/fieldmappings/${id_mapping}/` + ); } deleteContentMapping(id_mapping: number): Observable { - return this._http.delete(`${this.getUrlApiForADestination()}/contentmappings/${id_mapping}/`); + return this._http.delete( + `${this.getUrlApiForADestination()}/contentmappings/${id_mapping}/` + ); } /** @@ -184,11 +197,15 @@ export class ImportDataService { * @param idImport : integer */ getColumnsImport(idImport: number): Observable> { - return this._http.get>(`${this.getUrlApiForADestination()}/imports/${idImport}/columns`); + return this._http.get>( + `${this.getUrlApiForADestination()}/imports/${idImport}/columns` + ); } getImportValues(idImport: number): Observable { - return this._http.get(`${this.getUrlApiForADestination()}/imports/${idImport}/values`); + return this._http.get( + `${this.getUrlApiForADestination()}/imports/${idImport}/values` + ); } getBibFields(): Observable> { @@ -196,7 +213,10 @@ export class ImportDataService { } setImportFieldMapping(idImport: number, values: FieldMappingValues): Observable { - return this._http.post(`${this.getUrlApiForADestination()}/imports/${idImport}/fieldmapping`, values); + return this._http.post( + `${this.getUrlApiForADestination()}/imports/${idImport}/fieldmapping`, + values + ); } setImportContentMapping(idImport: number, values: ContentMappingValues): Observable { @@ -207,15 +227,22 @@ export class ImportDataService { } getNomencInfo(id_import: number) { - return this._http.get(`${this.getUrlApiForADestination()}/imports/${id_import}/contentMapping`); + return this._http.get( + `${this.getUrlApiForADestination()}/imports/${id_import}/contentMapping` + ); } prepareImport(import_id: number): Observable { - return this._http.post(`${this.getUrlApiForADestination()}/imports/${import_id}/prepare`, {}); + return this._http.post( + `${this.getUrlApiForADestination()}/imports/${import_id}/prepare`, + {} + ); } getValidData(import_id: number): Observable { - return this._http.get(`${this.getUrlApiForADestination()}/imports/${import_id}/preview_valid_data`); + return this._http.get( + `${this.getUrlApiForADestination()}/imports/${import_id}/preview_valid_data` + ); } getBbox(sourceId: number): Observable { @@ -225,7 +252,10 @@ export class ImportDataService { } finalizeImport(import_id): Observable { - return this._http.post(`${this.getUrlApiForADestination()}/imports/${import_id}/import`, {}); + return this._http.post( + `${this.getUrlApiForADestination()}/imports/${import_id}/import`, + {} + ); } getErrorCSV(importId: number) { @@ -241,7 +271,9 @@ export class ImportDataService { } getImportErrors(importId): Observable> { - return this._http.get>(`${this.getUrlApiForADestination()}/imports/${importId}/errors`); + return this._http.get>( + `${this.getUrlApiForADestination()}/imports/${importId}/errors` + ); } getTaxaRepartition(sourceId: number, taxa_rank: string) {