Commit 71dbd296 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add show description to instance selection

parent f34eb437
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
> >
<option <option
*ngFor="let expertModel of expertModels" *ngFor="let expertModel of expertModels"
[ngValue]="expertModel._id" [ngValue]="expertModel"
> >
{{ expertModel.name }} {{ expertModel.name }}
</option> </option>
...@@ -24,13 +24,26 @@ ...@@ -24,13 +24,26 @@
<select id="instance" formControlName="instance" class="form-control"> <select id="instance" formControlName="instance" class="form-control">
<option <option
*ngFor="let instance of expertModel ? expertModel.getPatterns() : []" *ngFor="let instance of expertModel ? expertModel.getPatterns() : []"
[ngValue]="instance.id" [ngValue]="instance"
> >
{{ instance.name }} {{ instance.name }}
</option> </option>
</select> </select>
</div> </div>
</div> </div>
<div
*ngIf="
(selectPatternForm.valid || showsPattern) &&
instance != null &&
instance.description
"
class="form-group form-row"
>
<label class="col-sm-4 col-form-label">Description</label>
<div class="col-sm-8">
{{ instance.description }}
</div>
</div>
<div class="form-group form-row"> <div class="form-group form-row">
<div class="col-sm-12"> <div class="col-sm-12">
<button <button
......
...@@ -3,8 +3,6 @@ import { ...@@ -3,8 +3,6 @@ import {
EventEmitter, EventEmitter,
Input, Input,
OnChanges, OnChanges,
OnDestroy,
OnInit,
Output, Output,
SimpleChanges, SimpleChanges,
} from '@angular/core'; } from '@angular/core';
...@@ -16,16 +14,13 @@ import { ...@@ -16,16 +14,13 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { Instance } from '../../../canvas-meta-model/instance'; import { Instance } from '../../../canvas-meta-model/instance';
import { ExpertModel } from '../../../canvas-meta-model/expert-model'; import { ExpertModel } from '../../../canvas-meta-model/expert-model';
import { Subscription } from 'rxjs';
@Component({ @Component({
selector: 'app-instance-select-pattern-form', selector: 'app-instance-select-pattern-form',
templateUrl: './instance-select-pattern-form.component.html', templateUrl: './instance-select-pattern-form.component.html',
styleUrls: ['./instance-select-pattern-form.component.css'], styleUrls: ['./instance-select-pattern-form.component.css'],
}) })
export class InstanceSelectPatternFormComponent export class InstanceSelectPatternFormComponent implements OnChanges {
implements OnInit, OnChanges, OnDestroy
{
@Input() expertModels: ExpertModel[] = []; @Input() expertModels: ExpertModel[] = [];
@Input() showsPattern = false; @Input() showsPattern = false;
...@@ -40,22 +35,8 @@ export class InstanceSelectPatternFormComponent ...@@ -40,22 +35,8 @@ export class InstanceSelectPatternFormComponent
instance: [null, Validators.required], instance: [null, Validators.required],
}); });
expertModel: ExpertModel;
private formSubscription: Subscription;
constructor(private fb: FormBuilder) {} constructor(private fb: FormBuilder) {}
ngOnInit() {
this.formSubscription = this.featureModelControl.valueChanges.subscribe(
(value) => {
this.expertModel = this.expertModels.find(
(expertModel) => expertModel._id === value
);
}
);
}
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes.showsPattern) { if (changes.showsPattern) {
if (changes.showsPattern.currentValue) { if (changes.showsPattern.currentValue) {
...@@ -66,19 +47,21 @@ export class InstanceSelectPatternFormComponent ...@@ -66,19 +47,21 @@ export class InstanceSelectPatternFormComponent
} }
} }
ngOnDestroy() {
if (this.formSubscription) {
this.formSubscription.unsubscribe();
}
}
submit() { submit() {
this.showPattern.emit({ this.showPattern.emit({
instance: this.expertModel.getInstance(this.instanceControl.value), instance: this.instance,
featureModelId: this.expertModel._id, featureModelId: this.expertModel._id,
}); });
} }
get expertModel(): ExpertModel | undefined {
return this.featureModelControl.value;
}
get instance(): Instance | undefined {
return this.instanceControl.value;
}
get featureModelControl(): FormControl { get featureModelControl(): FormControl {
return this.selectPatternForm.get('featureModel') as FormControl; return this.selectPatternForm.get('featureModel') as FormControl;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment