Allow to edit user created Data Repositories

This commit is contained in:
George Kalampokis 2020-04-10 18:52:14 +03:00
parent 982aea0cbf
commit 3ce7fe7595
3 changed files with 42 additions and 3 deletions

View File

@ -132,6 +132,9 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
@Override @Override
public void update(DataRepository entity) { public void update(DataRepository entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
} }

View File

@ -18,11 +18,31 @@
<span class="col"> <span class="col">
{{i+1}}) {{suggestion.get('name').value}} {{i+1}}) {{suggestion.get('name').value}}
</span> </span>
<div class="col-auto" *ngIf="isInternal(suggestion)">
<mat-form-field>
<input matInput placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.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.DATA-REPOSITORY.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.DATA-REPOSITORY.URI' | translate}}" type="text" name="uri" [formControl]="suggestion.get('uri')">
</mat-form-field>
</div>
<div class="col-auto"> <div class="col-auto">
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{'DATASET-EDITOR.FIELDS.DATAREPOSITORIES-INFO' | translate}}" type="text" name="info" [formControl]="suggestion.get('info')"> <input matInput placeholder="{{'DATASET-EDITOR.FIELDS.DATAREPOSITORIES-INFO' | translate}}" type="text" name="info" [formControl]="suggestion.get('info')">
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-auto" *ngIf='!viewOnly && isInternal(suggestion)'>
<button mat-raised-button (click)="updateDataRepository(suggestion)">
Update
</button>
</div>
<div class="col-auto" *ngIf='!viewOnly'> <div class="col-auto" *ngIf='!viewOnly'>
<button mat-icon-button (click)="callback(i)"> <button mat-icon-button (click)="callback(i)">
<mat-icon>close</mat-icon> <mat-icon>close</mat-icon>

View File

@ -25,6 +25,7 @@ import { takeUntil } from 'rxjs/operators';
import { ENTER, COMMA } from '@angular/cdk/keycodes'; import { ENTER, COMMA } from '@angular/cdk/keycodes';
import { MatChipInputEvent } from '@angular/material/chips'; import { MatChipInputEvent } from '@angular/material/chips';
import { isNullOrUndefined } from 'util'; import { isNullOrUndefined } from 'util';
import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service';
@Component({ @Component({
selector: 'app-dataset-external-references-editor-component', selector: 'app-dataset-external-references-editor-component',
@ -87,7 +88,8 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
private router: Router, private router: Router,
private language: TranslateService, private language: TranslateService,
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
private externalSourcesConfigurationService: ExternalSourcesConfigurationService private externalSourcesConfigurationService: ExternalSourcesConfigurationService,
private externalDataRepositoryService: ExternalDataRepositoryService
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
@ -242,8 +244,22 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
addTag(ev: MatChipInputEvent) { addTag(ev: MatChipInputEvent) {
console.log((<FormArray>this.formGroup.get('tags')).value); console.log((<FormArray>this.formGroup.get('tags')).value);
if (ev.value !== '' && isNullOrUndefined(((<FormArray>this.formGroup.get('tags')).value as ExternalTagEditorModel[]).find(tag => tag.name === ev.value))) { if (ev.value !== '' && isNullOrUndefined(((<FormArray>this.formGroup.get('tags')).value as ExternalTagEditorModel[]).find(tag => tag.name === ev.value))) {
(<FormArray>this.formGroup.get('tags')).push(new ExternalTagEditorModel('',ev.value).buildForm()); (<FormArray>this.formGroup.get('tags')).push(new ExternalTagEditorModel('', ev.value).buildForm());
} }
ev.input.value=''; ev.input.value = '';
}
isInternal(element: any): boolean {
return element.get('source').value === 'Internal';
}
updateDataRepository(dataRepository: FormGroup) {
this.externalDataRepositoryService.create(dataRepository.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
(result) => {
dataRepository.setValue(result);
}
);
} }
} }