Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(link-value): enter newly created link value automatically (DEV-687) #710

Merged
merged 1 commit into from Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
}
}