diff --git a/src/frontend/app/administration/contact/list/import/contact-import.component.html b/src/frontend/app/administration/contact/list/import/contact-import.component.html index abf0f4f4feb37d48d25322f50f7a69c83fe849bf..2907ce1fab7ecc9776f65def2b37dee947b508c1 100644 --- a/src/frontend/app/administration/contact/list/import/contact-import.component.html +++ b/src/frontend/app/administration/contact/list/import/contact-import.component.html @@ -3,11 +3,13 @@ <div mat-dialog-content> <mat-toolbar class="import-tool" [class.hide]="csvData.length === 0 || loading"> <span style="flex:1;"> - <mat-slide-toggle color="primary" [checked]="hasHeader" (change)="toggleHeader()">{{'lang.csvHeader' | translate}} + <mat-slide-toggle color="primary" [checked]="hasHeader" (change)="toggleHeader()"> + {{'lang.csvHeader' | translate}} </mat-slide-toggle> </span> <span style="flex:1;text-align: center;"><i class="fa fa-users" - color="primary"></i> {{'lang.contactsOfFile' | translate}} : <b color="primary">{{countAll}}</b> + color="primary"></i> {{'lang.contactsOfFile' | translate}} : <b + color="primary">{{countAll}}</b> </span> <span style="flex:1;text-align: center;"><i class="fa fa-user-plus" color="primary"></i> {{'lang.additions' | translate}} : <b @@ -49,7 +51,7 @@ <mat-table *ngIf="csvData.length > 0" #table [dataSource]="dataSource" style="width:5000px;"> <ng-container *ngFor="let column of contactColumns;let i=index;"> <ng-container [matColumnDef]="column.id"> - <mat-header-cell *matHeaderCellDef> + <mat-header-cell *matHeaderCellDef style="padding-left: 5px;padding-right: 5px;"> <i class="fas fa-database" color="primary" [title]="'lang.dbColumn' | translate"></i> <b color="primary" [title]="'lang.dbColumn' | translate">{{column.label}}</b> @@ -65,9 +67,17 @@ </mat-option> </mat-select> </mat-form-field> + <mat-checkbox color="primary" (change)="toggleEmptyMode(column.id,$event.checked)" + [title]="'lang.toggleEmptyValues' | translate"></mat-checkbox> </mat-header-cell> - <mat-cell *matCellDef="let element"> - {{element[column.id]}} + <mat-cell *matCellDef="let element" style="padding-left: 5px;padding-right: 5px;"> + <ng-container + *ngIf="column.emptyValueMode && functionsService.empty(element[column.id]); else elseTemplate"> + <i style="opacity: 0.5;">{{'lang.emptyValue' | translate}}</i> + </ng-container> + <ng-template #elseTemplate> + {{element[column.id]}} + </ng-template> </mat-cell> </ng-container> </ng-container> @@ -79,6 +89,9 @@ <div class="alert-message alert-message-info" [innerHTML]="'lang.infoImportcontacts' | translate" style="min-width: 100%"> </div> + <div class="alert-message alert-message-info" [innerHTML]="'lang.infoImportcontacts2' | translate" + style="min-width: 100%"> + </div> </ng-template> </div> <span class="divider-modal"></span> diff --git a/src/frontend/app/administration/contact/list/import/contact-import.component.ts b/src/frontend/app/administration/contact/list/import/contact-import.component.ts index 9da6c2aadfbbf34045f151569a3d99400a269b3a..7e2dbae0a66f3fb3a6340e63184a3e756276565d 100644 --- a/src/frontend/app/administration/contact/list/import/contact-import.component.ts +++ b/src/frontend/app/administration/contact/list/import/contact-import.component.ts @@ -41,67 +41,83 @@ export class ContactImportComponent implements OnInit { contactColumns: any[] = [ { id: 'id', - label: this.translate.instant('lang.id') + label: this.translate.instant('lang.id'), + emptyValueMode: false }, { id: 'company', - label: this.translate.instant('lang.contactsParameters_company') + label: this.translate.instant('lang.contactsParameters_company'), + emptyValueMode: false, }, { id: 'civility', - label: this.translate.instant('lang.contactsParameters_civility') + label: this.translate.instant('lang.contactsParameters_civility'), + emptyValueMode: false }, { id: 'firstname', - label: this.translate.instant('lang.contactsParameters_firstname') + label: this.translate.instant('lang.contactsParameters_firstname'), + emptyValueMode: false }, { id: 'lastname', - label: this.translate.instant('lang.contactsParameters_lastname') + label: this.translate.instant('lang.contactsParameters_lastname'), + emptyValueMode: false }, { id: 'function', - label: this.translate.instant('lang.contactsParameters_function') + label: this.translate.instant('lang.contactsParameters_function'), + emptyValueMode: false }, { id: 'department', - label: this.translate.instant('lang.contactsParameters_department') + label: this.translate.instant('lang.contactsParameters_department'), + emptyValueMode: false }, { id: 'email', - label: this.translate.instant('lang.contactsParameters_email') + label: this.translate.instant('lang.contactsParameters_email'), + emptyValueMode: false }, { id: 'phone', - label: this.translate.instant('lang.contactsParameters_phone') + label: this.translate.instant('lang.contactsParameters_phone'), + emptyValueMode: false }, { id: 'addressAdditional1', - label: this.translate.instant('lang.contactsParameters_addressAdditional1') + label: this.translate.instant('lang.contactsParameters_addressAdditional1'), + emptyValueMode: false }, { id: 'addressNumber', - label: this.translate.instant('lang.contactsParameters_addressNumber') + label: this.translate.instant('lang.contactsParameters_addressNumber'), + emptyValueMode: false }, { id: 'addressStreet', - label: this.translate.instant('lang.contactsParameters_addressStreet') + label: this.translate.instant('lang.contactsParameters_addressStreet'), + emptyValueMode: false }, { id: 'addressAdditional2', - label: this.translate.instant('lang.contactsParameters_addressAdditional2') + label: this.translate.instant('lang.contactsParameters_addressAdditional2'), + emptyValueMode: false }, { id: 'addressPostcode', - label: this.translate.instant('lang.contactsParameters_addressPostcode') + label: this.translate.instant('lang.contactsParameters_addressPostcode'), + emptyValueMode: false }, { id: 'addressTown', - label: this.translate.instant('lang.contactsParameters_addressTown') + label: this.translate.instant('lang.contactsParameters_addressTown'), + emptyValueMode: false }, { id: 'addressCountry', - label: this.translate.instant('lang.contactsParameters_addressCountry') + label: this.translate.instant('lang.contactsParameters_addressCountry'), + emptyValueMode: false }, ]; @@ -166,8 +182,14 @@ export class ContactImportComponent implements OnInit { ).subscribe(); } - changeColumn(coldb: string, colCsv: string) { + + toggleEmptyMode(id: string, state: boolean) { + this.contactColumns.filter(col => col.id === id)[0].emptyValueMode = state; + } + + changeColumn(coldb: any, colCsv: string) { this.contactData = []; + for (let index = this.hasHeader ? 1 : 0; index < this.csvData.length; index++) { const data = this.csvData[index]; @@ -211,7 +233,6 @@ export class ContactImportComponent implements OnInit { for (let index = 0; index < rawCsv.length; index++) { objData = {}; dataCol = rawCsv[index].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim()); - dataCol.forEach((element: any, index2: number) => { objData[this.csvColumns[index2]] = element; }); @@ -297,7 +318,11 @@ export class ContactImportComponent implements OnInit { if ((this.hasHeader && index > 0) || !this.hasHeader) { const objContact = {}; this.contactColumns.forEach((key) => { - objContact[key.id] = element[this.associatedColmuns[key.id]]; + if (key.emptyValueMode && this.functionsService.empty(element[this.associatedColmuns[key.id]])) { + objContact[key.id] = false; + } else { + objContact[key.id] = element[this.associatedColmuns[key.id]].includes('##') ? element[this.associatedColmuns[key.id]].split('##') : element[this.associatedColmuns[key.id]]; + } }); dataToSend.push(objContact); } diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index 54def97500a5055dace6db607d8bfe33d4d82b7c..a4f7affb6a83c979b90dc6db9b5b732078c22952 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -1976,6 +1976,7 @@ "arAlreadyReceived": "Cet AR a déjà été reçu", "contactsOfFile": "Contact du fichier", "infoImportcontacts": "La colonne <b>id</b> est utilisée pour identifier un contact", + "infoImportcontacts2": "Les valeurs <b>vide</b> ne sont <b>pas</b> prise en compte par défaut lors de modifications de contacts", "importContacts": "Importer des contacts", "argumentCivilityNotCorrect": "La donnée civility n'est pas une civilité valide pour un contact", "argumentLastnameAndCompanyEmpty": "Les données lastname et company sont vides pour un contact", @@ -1989,5 +1990,7 @@ "confirmImportContacts": "Voulez-vous importer <b>{{0}}</b> contacts", "importedContacts": "contacts importés", "registeredMailNotFound": "Ce recommandé n'existe pas", - "registeredMailNotInDepositList": "Ce recommandé n'est pas dans un descriptif de pli" + "registeredMailNotInDepositList": "Ce recommandé n'est pas dans un descriptif de pli", + "toggleEmptyValues": "Prendre en compte les valeurs vides", + "emptyValue": "Valeur vide" }