When creating new Researcher is now automatically added to to autocomplete. (Issue #141)
This commit is contained in:
parent
3549e5f65f
commit
37aebb3d8d
|
@ -13,7 +13,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto"><button mat-button mat-dialog-close mat-raised-button color="primary">Cancel</button></div>
|
<div class="col-auto"><button mat-button mat-dialog-close mat-raised-button color="primary">Cancel</button></div>
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
<div class="col-auto"><button mat-raised-button color="primary" (click)="send()" type="button">Save</button></div>
|
<div class="col-auto"><button mat-raised-button color="primary" (click)="addResearcher()" type="button">Save</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { takeUntil } from 'rxjs/operators';
|
||||||
import { BaseComponent } from '../../../../core/common/base/base.component';
|
import { BaseComponent } from '../../../../core/common/base/base.component';
|
||||||
import { ExternalResearcherService } from '../../../../core/services/external-sources/researcher/external-researcher.service';
|
import { ExternalResearcherService } from '../../../../core/services/external-sources/researcher/external-researcher.service';
|
||||||
import { ResearcherEditorModel } from './add-researcher.model';
|
import { ResearcherEditorModel } from './add-researcher.model';
|
||||||
|
import { ResearcherModel } from '../../../../core/model/researcher/researcher';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-add-researcher-component',
|
selector: 'app-add-researcher-component',
|
||||||
|
@ -25,12 +26,15 @@ export class AddResearcherComponent extends BaseComponent implements OnInit {
|
||||||
this.formGroup = researcher.buildForm();
|
this.formGroup = researcher.buildForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send(value: any) {
|
send(value: any) {
|
||||||
this.externalResearcherService.createResearcher(this.formGroup.value)
|
this.externalResearcherService.createResearcher(this.formGroup.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
null, null, () => this.dialogRef.close()
|
null, null, () => this.dialogRef.close()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addResearcher() {
|
||||||
|
this.dialogRef.close(this.formGroup.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,19 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
addResearcher() {
|
addResearcher() {
|
||||||
const dialogRef = this.dialog.open(AddResearcherComponent, {
|
const dialogRef = this.dialog.open(AddResearcherComponent, {
|
||||||
data: {}
|
data: this.formGroup.get('researchers')
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
const fullName = result.firstName + " " + result.lastName;
|
||||||
|
this.formGroup.get('researchers').value.push({
|
||||||
|
label: null,
|
||||||
|
name: fullName,
|
||||||
|
id: "dmp:" + fullName,
|
||||||
|
status: 0,
|
||||||
|
tag: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue