From ae095cd555291dfd59acb3ed5e8ee568ab42aef4 Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde <toulemonde@cines.fr> Date: Wed, 20 Oct 2021 10:48:48 +0200 Subject: [PATCH] fixes --- src/app/mapping/mapping.component.html | 22 +++++++++++----------- src/app/mapping/mapping.component.ts | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/app/mapping/mapping.component.html b/src/app/mapping/mapping.component.html index 1ab79da2e..d29920f9b 100644 --- a/src/app/mapping/mapping.component.html +++ b/src/app/mapping/mapping.component.html @@ -26,7 +26,7 @@ </div> <ng-container - *ngFor="let dataset of dcatVocabulary ; let index = index ; trackBy:trackByIndex ;"> + *ngFor="let dataset of dcatVocabulary ; let index = index"> <nb-form-field> <div class="row"> @@ -49,22 +49,22 @@ <nb-form-field> <input - *ngIf="dataset.identifier === 'dct:hasVersion' || dataset.identifier === 'dct:title' " - required #autoInput #{{dataset.identifier}}="ngModel" fullWidth - id="{{dataset.identifier}}" name="{{dataset.identifier}}" nbInput + *ngIf=" dataset.identifier === 'dct:title' " + required fullWidth + name=" {{index}}" nbInput (ngModelChange)="onModelChange($event)" [nbAutocomplete]="auto" - [(ngModel)]="selectedPaths[index]" autocomplete="false" - (focus)="reset()" /> + [(ngModel)]="selectedPaths[index]" + (focus)="reset()" placeholder="{{index}}" /> <div *ngIf="dataset.identifier.invalid && (dataset.identifier.dirty || dataset.identifier.touched)"> champ obligatoire</div> <input - *ngIf=" dataset.identifier !== 'dct:hasVersion' && dataset.identifier !== 'dct:title'" - #autoInput #{{dataset.identifier}}="ngModel" fullWidth - id="{{dataset.identifier}}" name="{{dataset.identifier}}" nbInput + *ngIf=" dataset.identifier !== 'dct:title'" + fullWidth + name=" {{index}}" nbInput (ngModelChange)="onModelChange($event)" [nbAutocomplete]="auto" - [(ngModel)]="selectedPaths[index]" autocomplete="false" - (focus)="reset()" /> + [(ngModel)]="selectedPaths[index]" + (focus)="reset()" placeholder="{{index}}" /> <nb-autocomplete #auto> diff --git a/src/app/mapping/mapping.component.ts b/src/app/mapping/mapping.component.ts index 2b045e8b9..e923301c5 100644 --- a/src/app/mapping/mapping.component.ts +++ b/src/app/mapping/mapping.component.ts @@ -2,6 +2,7 @@ import { HttpResponse } from '@angular/common/http'; import { Component, Input, OnInit, ViewChild } from '@angular/core'; +import { FormArray } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { FileSaverService } from 'ngx-filesaver'; @@ -29,7 +30,7 @@ export class MappingComponent implements OnInit { vocabularies: Dataset[]; filteredOptions: Observable<string[]>; keys: string[] = []; - selectedPaths: string[]; + selectedPaths: string[] ; mappedMetadatas: Map<number, string>[] = []; DatasetToPublish: Map<string, string>[]; index: number = 0 @@ -69,8 +70,8 @@ export class MappingComponent implements OnInit { dataset => { this.dcatVocabulary = dataset; this.vocabularies = dataset; - this.selectedPaths = new Array(this.dcatVocabulary.length); - console.table(this.selectedPaths) + console.log(this.dcatVocabulary.length) + this.selectedPaths = []; }, error => { console.error(error); @@ -480,12 +481,14 @@ export class MappingComponent implements OnInit { addField(index: number) { let addedDcat: Dataset = new Dataset(this.dcatVocabulary[index].name, this.dcatVocabulary[index].identifier, this.dcatVocabulary[index].usageNote, true); this.dcatVocabulary.splice(index + 1, 0, addedDcat); - this.selectedPaths.splice(index + 1, 0, ''); + this.selectedPaths = this.selectedPaths.splice(index + 1, 0, ''); + console.table(this.selectedPaths) } deleteField(index: number) { this.dcatVocabulary.splice(index, 1); this.selectedPaths.splice(index, 1); + console.table(this.selectedPaths) } @@ -515,7 +518,7 @@ export class MappingComponent implements OnInit { deleteProperty(key: number) { this.mappedMetadatas[this.index].delete(key); } - + trackByIndex(index: number): any { return index; } @@ -550,3 +553,7 @@ export class MappingComponent implements OnInit { +function addField(index: any, number: any) { + throw new Error('Function not implemented.'); +} + -- GitLab