Skip to content

Commit

Permalink
Feat(mapping) sort mapping and put a ng-select
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Narcisi authored and jacquesfize committed Apr 8, 2024
1 parent 86f07fc commit 808545e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ <h5 class="card-title mb-0">Correspondance des champs avec le modèle</h5>
<fieldset>
<div *ngIf="userFieldMappings.length > 0" class="form-group">
<legend class="px-1">Choix d’un modèle d'import prédéfini</legend>
<select
class="form-control"
<ng-select
id="mappingSelection"
[items]="userFieldMappings"
[clearable]="true"
[formControl]="fieldMappingForm"
[compareWith]="areMappingFieldEqual"
[disableControl]="!userFieldMappings.length"
>
<option [ngValue]="null"></option>
<option *ngFor="let fieldMapping of userFieldMappings" [ngValue]="fieldMapping">
{{ fieldMapping.label }}
</option>
</select>
<ng-template ng-option-tmp let-item="item" let-index="index" let-search="searchTerm">
<div>
<span class="pre-wrap">
{{ item.label }}
</span>
</div>
</ng-template>
</ng-select>
</div>

<div class="d-flex flex-row justify-content-center mt-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class FieldsMappingStepComponent implements OnInit {
targetFields: this._importDataService.getBibFields(),
sourceFields: this._importDataService.getColumnsImport(this.importData.id_import),
}).subscribe(({ fieldMappings, targetFields, sourceFields }) => {
this.userFieldMappings = fieldMappings;
this.userFieldMappings = fieldMappings.sort((a, b) => a.label.localeCompare(b.label));

this.targetFields = targetFields;
this.mappedTargetFields = new Set();
Expand Down Expand Up @@ -272,9 +272,11 @@ export class FieldsMappingStepComponent implements OnInit {
'Le mapping ' + this.fieldMappingForm.value.label + ' a bien été supprimé'
);
this.fieldMappingForm.setValue(null, { emitEvent: false });
this.userFieldMappings = this.userFieldMappings.filter((mapping) => {
return mapping.id !== mapping_id;
});
this.userFieldMappings = this.userFieldMappings
.filter((mapping) => {
return mapping.id !== mapping_id;
})
.sort((a, b) => a.label.localeCompare(b.label));
this.spinner = false;
},
() => {
Expand Down

0 comments on commit 808545e

Please sign in to comment.