Skip to content
Permalink
Browse files
feat(link-value): enter newly created value automatically (#710)
  • Loading branch information
mdelez committed Apr 8, 2022
1 parent c6fe803 commit 5ccd18d17e33d3b89f38365d5d9f4add7e25dede
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
@@ -29,7 +29,7 @@ export class CreateLinkResourceComponent implements OnInit {
@Input() resourceClassDef: string;
@Input() currentOntoIri: string;

@Output() closeDialog: EventEmitter<any> = new EventEmitter<any>();
@Output() closeDialog: EventEmitter<ReadResource> = new EventEmitter<ReadResource>();

@ViewChild('selectProps') selectPropertiesComponent: SelectPropertiesComponent;

@@ -129,7 +129,7 @@ export class CreateLinkResourceComponent implements OnInit {

this._dspApiConnection.v2.res.createResource(createResource).subscribe(
(res: ReadResource) => {
this.closeDialog.emit();
this.closeDialog.emit(res);
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
@@ -7,9 +7,11 @@ import {
OnDestroy,
OnInit,
Output,
SimpleChanges
SimpleChanges,
ViewChild
} from '@angular/core';
import { AbstractControl, FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import {
CreateLinkValue,
@@ -49,9 +51,10 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
@Input() currentOntoIri: string;

@Output() referredResourceClicked: EventEmitter<ReadLinkValue> = new EventEmitter();

@Output() referredResourceHovered: EventEmitter<ReadLinkValue> = new EventEmitter();

@ViewChild(MatAutocompleteTrigger) autocomplete: MatAutocompleteTrigger;

resources: ReadResource[] = [];
restrictToResourceClass: string;
valueFormControl: FormControl;
@@ -259,6 +262,16 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
disableClose: true
};

this._dialog.open(DialogComponent, dialogConfig);
const dialogRef = this._dialog.open(DialogComponent, dialogConfig);

dialogRef.afterClosed().subscribe((event: any) => {
const newResource = event as ReadResource;

// set value of value form control to the newly created resource
this.form.controls.value.setValue(newResource);

// hide the autocomplete results
this.autocomplete.closePanel();
});
}
}

0 comments on commit 5ccd18d

Please sign in to comment.