Fixes bugs on dataset editor on external references tab

This commit is contained in:
apapachristou 2019-09-16 11:09:41 +03:00
parent 7647b4c290
commit 534b8814e7
10 changed files with 85 additions and 52 deletions

View File

@ -3,7 +3,7 @@ export interface RegistryModel {
abbreviation: String;
definition: String;
id: String;
label: String;
name: String;
reference: String;
uri: String;
}

View File

@ -3,7 +3,7 @@ export interface ServiceModel {
abbreviation: String;
definition: String;
uri: String;
label: String;
name: String;
reference: String;
}

View File

@ -23,7 +23,7 @@ export class DatasetWizardEditorModel {
public services: ExternalServiceEditorModel[] = [];
public registries: ExternalRegistryEditorModel[] = [];
public dataRepositories: ExternalDataRepositoryEditorModel[] = [];
public tags: TagModel[] = [];
public tags: ExternalTagEditorModel[] = [];
public externalDatasets: ExternalDatasetEditorModel[] = [];
public dmp: DmpModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
@ -43,7 +43,7 @@ export class DatasetWizardEditorModel {
if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); }
this.dmp = item.dmp;
if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); }
this.tags = item.tags;
if (item.tags) { this.tags = item.tags.map(x => new ExternalTagEditorModel().fromModel(x)); }
this.isProfileLatestVersion = item.isProfileLatestVersion;
return this;
}
@ -59,7 +59,7 @@ export class DatasetWizardEditorModel {
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators],
//externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators],
tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators],
// tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators],
//registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators],
//dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators],
//services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators],
@ -116,6 +116,12 @@ export class DatasetWizardEditorModel {
// }
formGroup.addControl('services', formBuilder.array(servicesFormArray));
const tagsFormArray = new Array<FormGroup>();
this.tags.forEach(item => {
tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled));
});
formGroup.addControl('tags', formBuilder.array(tagsFormArray));
if (this.datasetProfileDefinition) { formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinition.buildForm()); }
// formGroup.addControl('profile', this.profile.buildForm());
return formGroup;
@ -140,20 +146,47 @@ export class DatasetWizardEditorModel {
}
}
export class ExternalTagEditorModel {
public abbreviation: String;
public definition: String;
public id: String;
public name: String;
public reference: String;
public uri: String;
constructor(id?: String, name?: String) {
this.id = id;
this.name = name;
}
fromModel(item: TagModel): ExternalTagEditorModel {
this.id = item.id;
this.name = item.name;
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
return new FormBuilder().group({
id: [this.id],
name: [this.name]
});
}
}
export class ExternalServiceEditorModel {
public id: String;
public abbreviation: String;
public definition: String;
public uri: String;
public label: String;
public name: String;
public reference: String;
constructor(id?: String, abbreviation?: String, definition?: String, uri?: String, label?: String, reference?: String) {
constructor(abbreviation?: String, definition?: String, id?: String, name?: String, reference?: String, uri?: String) {
this.id = id;
this.abbreviation = abbreviation;
this.definition = definition;
this.uri = uri;
this.label = label;
this.name = name;
this.reference = reference;
}
@ -162,7 +195,7 @@ export class ExternalServiceEditorModel {
this.abbreviation = item.abbreviation;
this.definition = item.definition;
this.uri = item.uri;
this.label = item.label;
this.name = item.name;
this.reference = item.reference;
return this;
}
@ -171,7 +204,7 @@ export class ExternalServiceEditorModel {
return new FormBuilder().group({
id: [this.id],
abbreviation: [this.abbreviation],
label: [this.label],
name: [this.name],
reference: [this.reference],
uri: [this.uri],
definition: [this.definition]
@ -183,15 +216,15 @@ export class ExternalRegistryEditorModel {
public abbreviation: String;
public definition: String;
public id: String;
public label: String;
public name: String;
public reference: String;
public uri: String;
constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String) {
constructor(abbreviation?: String, definition?: String, id?: String, name?: String, reference?: String, uri?: String) {
this.abbreviation = abbreviation;
this.definition = definition;
this.id = id;
this.label = label;
this.name = name;
this.reference = reference;
this.uri = uri;
}
@ -200,7 +233,7 @@ export class ExternalRegistryEditorModel {
this.abbreviation = item.abbreviation;
this.definition = item.definition;
this.id = item.id;
this.label = item.label;
this.name = item.name;
this.reference = item.reference;
this.uri = item.uri;
@ -211,7 +244,7 @@ export class ExternalRegistryEditorModel {
return new FormBuilder().group({
id: [this.id],
abbreviation: [this.abbreviation],
label: [this.label],
name: [this.name],
reference: [this.reference],
uri: [this.uri],
definition: [this.definition]

View File

@ -94,7 +94,7 @@
<div class="col-12 row align-items-center">
<div class="col">
<p>
{{i+1}}) {{suggestion.get('label').value}}
{{i+1}}) {{suggestion.get('name').value}}
</p>
</div>
<div class="col-auto">
@ -125,7 +125,7 @@
<div class="col-12 row align-items-center">
<div class="col">
<p>
{{i+1}}) {{suggestion.get('label').value}}
{{i+1}}) {{suggestion.get('name').value}}
</p>
</div>
<div class="col-auto">

View File

@ -16,7 +16,7 @@ import { ExternalSourcesConfigurationService } from '../../../../core/services/e
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
import { SingleAutoCompleteConfiguration } from '../../../../library/auto-complete/single/single-auto-complete-configuration';
import { RequestItem } from '../../../../core/query/request-item';
import { ExternalDataRepositoryEditorModel, ExternalDatasetEditorModel, ExternalRegistryEditorModel, ExternalServiceEditorModel } from '../dataset-wizard-editor.model';
import { ExternalDataRepositoryEditorModel, ExternalDatasetEditorModel, ExternalRegistryEditorModel, ExternalServiceEditorModel, ExternalTagEditorModel } from '../dataset-wizard-editor.model';
import { DatasetExternalDataRepositoryDialogEditorComponent } from './editors/data-repository/dataset-external-data-repository-dialog-editor.component';
import { DatasetExternalDatasetDialogEditorComponent } from './editors/external-dataset/dataset-external-dataset-dialog-editor.component';
import { DatasetExternalRegistryDialogEditorComponent } from './editors/registry/dataset-external-registry-dialog-editor.component';
@ -64,6 +64,14 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' });
});
this.dataRepositoriesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalDataRepositories.bind(this),
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
this.externalDatasetAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalDatasets.bind(this),
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
@ -80,18 +88,10 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
this.dataRepositoriesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalDataRepositories.bind(this),
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
this.servicesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalServices.bind(this),
initialItems: (type) => this.searchDatasetExternalServices('', type),
displayFn: (item) => item ? item.label : null,
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
@ -100,7 +100,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
filterFn: this.searchDatasetTags.bind(this),
initialItems: (type) => this.searchDatasetTags('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name: null,
titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
};
}
@ -115,18 +115,18 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
}
registriesOnItemChange(event) {
const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.reference, event.uri);
(<FormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
}
servicesOnItemChange(event) {
const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.name, event.reference, event.uri);
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
}
tagsOnItemChange(event) {
// const serviceModel = new TagModel(event.id, event.name);
// (<FormArray>this.formGroup.get('tags')).push(serviceModel.buildForm());
const tagModel = new ExternalTagEditorModel(event.id, event.name);
(<FormArray>this.formGroup.get('tags')).push(tagModel.buildForm());
}
@ -160,7 +160,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
if (!result) { return; }
const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri);
const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.name, result.reference, result.uri);
(<FormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
});
}
@ -190,7 +190,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
if (!result) { return; }
const serviceModel = new ExternalServiceEditorModel(result.id, result.abbreviation, result.definition, result.uri, result.label, result.reference);
const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.name, result.reference, result.uri);
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
});
}

View File

@ -1,15 +1,15 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-4">
<mat-form-field class="col-auto">
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-4">
<mat-form-field class="col-auto">
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.ABBREVIATION' | translate}}" required>
<mat-error *ngIf="formGroup.get('abbreviation').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-4">
<mat-form-field class="col-auto">
<input matInput formControlName="uri" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.URI' | translate}}" required>
<mat-error *ngIf="formGroup.get('uri').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -1,11 +1,11 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-md-6">
<mat-form-field class="col-auto">
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<mat-form-field class="col-auto">
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.ABBREVIATION' | translate}}" required>
<mat-error *ngIf="formGroup.get('abbreviation').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -1,15 +1,15 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'DATASET-REFERENCED-MODELS.REGISTRY.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-md-4">
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-form-field class="col-auto">
<input matInput formControlName="name" placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-auto">
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.ABBREVIATION' | translate}}" required>
<mat-error *ngIf="formGroup.get('abbreviation').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-auto">
<input matInput formControlName="uri" placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.URI' | translate}}" required>
<mat-error *ngIf="formGroup.get('uri').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -1,15 +1,15 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'DATASET-REFERENCED-MODELS.SERVICES.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-md-4">
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-form-field class="col-auto">
<input matInput formControlName="name" placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-auto">
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.ABBREVIATION' | translate}}" required>
<mat-error *ngIf="formGroup.get('abbreviation').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-auto">
<input matInput formControlName="uri" placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.URI' | translate}}" required>
<mat-error *ngIf="formGroup.get('uri').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -941,18 +941,18 @@
"URI": "Uri"
},
"DATA-REPOSITORY": {
"TITLE": "Add New Service",
"TITLE": "Add New Data Repository",
"LABEL": "Label",
"ABBREVIATION": "Abbreviation",
"URI": "Uri"
},
"EXTERNAL-DATASET": {
"TITLE": "Add New Service",
"TITLE": "Add New External Dataset Description",
"LABEL": "Label",
"ABBREVIATION": "Abbreviation"
},
"REGISTRY": {
"TITLE": "Add New Service",
"TITLE": "Add New Registry",
"LABEL": "Label",
"ABBREVIATION": "Abbreviation",
"URI": "Uri"