Add additional editors for the remaining external references

This commit is contained in:
George Kalampokis 2020-04-14 16:43:09 +03:00
parent 80a11b2cb3
commit 2ba3f11687
6 changed files with 109 additions and 6 deletions

View File

@ -139,7 +139,9 @@ public class Registry implements DataEntity<Registry, UUID> {
@Override
public void update(Registry entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
}
@Override

View File

@ -134,7 +134,9 @@ public class Service implements DataEntity<Service, UUID> {
@Override
public void update(Service entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
}
@Override

View File

@ -5,5 +5,6 @@ export interface ServiceModel {
uri: String;
label: String;
reference: String;
source: String;
}

View File

@ -184,14 +184,16 @@ export class ExternalServiceEditorModel {
public uri: String;
public label: String;
public reference: String;
public source: String;
constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String) {
constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) {
this.id = id;
this.abbreviation = abbreviation;
this.definition = definition;
this.uri = uri;
this.label = label;
this.reference = reference;
this.source = source;
}
fromModel(item: ServiceModel): ExternalServiceEditorModel {
@ -201,6 +203,7 @@ export class ExternalServiceEditorModel {
this.uri = item.uri;
this.label = item.label;
this.reference = item.reference;
this.source = item.source;
return this;
}
@ -211,7 +214,8 @@ export class ExternalServiceEditorModel {
label: [this.label, Validators.required],
reference: [this.reference],
uri: [this.uri, Validators.required],
definition: [this.definition]
definition: [this.definition],
source: [this.source]
});
}
}

View File

@ -75,6 +75,16 @@
{{i+1}}) {{suggestion.get('name').value}}
</p>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.LABEL' | translate}}" type="text" name="name" [formControl]="suggestion.get('name')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.ABBREVIATION' | translate}}" type="text" name="abbreviation" [formControl]="suggestion.get('abbreviation')">
</mat-form-field>
</div>
<div class="col-auto">
<mat-form-field>
<input matInput placeholder="{{'DATASET-EDITOR.FIELDS.EXTERNAL-DATASET-INFO' | translate}}" type="text" name="info" [formControl]="suggestion.get('info')">
@ -90,6 +100,11 @@
<mat-error *ngIf="suggestion.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-auto" *ngIf='!viewOnly && isInternal(suggestion)'>
<button mat-raised-button (click)="updateExternalDataset(suggestion)" type="button" color="primary">
{{ 'DATASET-EDITOR.ACTIONS.UPDATE' | translate }}
</button>
</div>
<div class="col-auto">
<button mat-icon-button (click)="callback(i)" *ngIf='!viewOnly'>
<mat-icon>close</mat-icon>
@ -120,6 +135,26 @@
{{i+1}}) {{suggestion.get('label').value}}
</p>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.LABEL' | translate}}" type="text" name="label" [formControl]="suggestion.get('label')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.ABBREVIATION' | translate}}" type="text" name="abbreviation" [formControl]="suggestion.get('abbreviation')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.REGISTRY.URI' | translate}}" type="text" name="uri" [formControl]="suggestion.get('uri')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf='!viewOnly && isInternal(suggestion)'>
<button mat-raised-button (click)="updateRegistry(suggestion)" type="button" color="primary">
{{ 'DATASET-EDITOR.ACTIONS.UPDATE' | translate }}
</button>
</div>
<div class="col-auto">
<button mat-icon-button (click)="callback(i)" *ngIf='!viewOnly'>
<mat-icon>close</mat-icon>
@ -151,6 +186,26 @@
{{i+1}}) {{suggestion.get('label').value}}
</p>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.LABEL' | translate}}" type="text" name="label" [formControl]="suggestion.get('label')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.ABBREVIATION' | translate}}" type="text" name="abbreviation" [formControl]="suggestion.get('abbreviation')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.SERVICES.URI' | translate}}" type="text" name="uri" [formControl]="suggestion.get('uri')">
</mat-form-field>
</div>
<div class="col-auto" *ngIf='!viewOnly && isInternal(suggestion)'>
<button mat-raised-button (click)="updateRegistry(suggestion)" type="button" color="primary">
{{ 'DATASET-EDITOR.ACTIONS.UPDATE' | translate }}
</button>
</div>
<div class="col-auto">
<button mat-icon-button (click)="callback(i)" *ngIf='!viewOnly'>
<mat-icon>close</mat-icon>

View File

@ -26,6 +26,9 @@ import { ENTER, COMMA } from '@angular/cdk/keycodes';
import { MatChipInputEvent } from '@angular/material/chips';
import { isNullOrUndefined } from 'util';
import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service';
import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service';
import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service';
import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service';
@Component({
selector: 'app-dataset-external-references-editor-component',
@ -89,7 +92,10 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
private language: TranslateService,
private externalSourcesService: ExternalSourcesService,
private externalSourcesConfigurationService: ExternalSourcesConfigurationService,
private externalDataRepositoryService: ExternalDataRepositoryService
private externalDataRepositoryService: ExternalDataRepositoryService,
private externalDatasetService: ExternalDatasetService,
private externalRegistryService: ExternalRegistryService,
private externalServiceService: ExternalServiceService,
) { super(); }
ngOnInit() {
@ -195,7 +201,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
if (!result) { return; }
const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri);
const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source);
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
});
}
@ -254,6 +260,9 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
}
isInternal(element: any): boolean {
if (element.get('source') == null) {
console.log(element);
}
return element.get('source').value === 'Internal';
}
@ -266,4 +275,34 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
}
);
}
updateExternalDataset(externalDataset: FormGroup) {
this.externalDatasetService.create(externalDataset.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
(result) => {
externalDataset.setValue(result);
}
);
}
updateRegistry(registry: FormGroup) {
this.externalRegistryService.create(registry.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
(result) => {
registry.setValue(result);
}
);
}
updateService(service: FormGroup) {
this.externalServiceService.create(service.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
(result) => {
service.setValue(result);
}
);
}
}