Commit 85638a78 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add canvas artifact preview

parent f91343d3
......@@ -3,9 +3,7 @@
<app-step-errors></app-step-errors>
<main
*ngIf="
processApiService.runningMethod != null && processApiService.isCorrectStep()
"
*ngIf="runningMethod != null && isCorrectStep()"
role="main"
class="container"
>
......@@ -28,4 +26,9 @@
</form>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2">Canvas Artifact Preview</h6>
<app-feature-model [featureModel]="companyModel"></app-feature-model>
</div>
</main>
......@@ -5,6 +5,8 @@ import { Instance } from '../../../canvas-meta-model/instance';
import { CompanyModelService } from '../../../canvas-meta-model/company-model.service';
import { CanvasResolveService } from '../../canvas-resolve.service';
import { ProcessApiService } from '../process-api.service';
import { RunningMethod } from '../../../development-process-registry/running-process/running-method';
import { CompanyModel } from '../../../canvas-meta-model/company-model';
@Component({
selector: 'app-create-canvas',
......@@ -13,25 +15,27 @@ import { ProcessApiService } from '../process-api.service';
providers: [ProcessApiService],
})
export class CreateCanvasComponent implements OnInit {
companyModel: CompanyModel;
form: FormGroup;
constructor(
private canvasResolveService: CanvasResolveService,
private companyModelService: CompanyModelService,
private featureModelInstanceFormService: FeatureModelInstanceFormService,
public processApiService: ProcessApiService
private processApiService: ProcessApiService
) {}
ngOnInit(): void {
this.form = this.featureModelInstanceFormService.createForm();
this.processApiService.loaded.subscribe(() => this.loadCompanyModel());
}
async submit(): Promise<void> {
if (this.processApiService.stepInfo) {
const runningMethod = this.processApiService.runningMethod;
const companyModel = await this.companyModelService.get(
runningMethod.decision.stepDecisions[runningMethod.currentStepNumber]
.companyModelId
this.runningMethod.decision.stepDecisions[
this.runningMethod.currentStepNumber
].companyModelId
);
const instance: Partial<Instance> =
this.featureModelInstanceFormService.get(this.form.value);
......@@ -46,4 +50,20 @@ export class CreateCanvasComponent implements OnInit {
);
}
}
private async loadCompanyModel(): Promise<void> {
this.companyModel = await this.companyModelService.get(
this.runningMethod.decision.stepDecisions[
this.runningMethod.currentStepNumber
].companyModelId
);
}
get runningMethod(): RunningMethod {
return this.processApiService.runningMethod;
}
isCorrectStep(): boolean {
return this.processApiService.isCorrectStep();
}
}
import { Injectable, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { Observable, Subject, Subscription } from 'rxjs';
import { RunningProcess } from '../../development-process-registry/running-process/running-process';
import { RunningMethod } from '../../development-process-registry/running-process/running-method';
import { StepInfo } from '../../development-process-registry/module-api/step-info';
......@@ -8,6 +8,12 @@ import { RunningProcessService } from '../../development-process-registry/runnin
@Injectable()
export class ProcessApiService implements OnDestroy {
private _loadedObservable: Observable<void>;
private _loaded: Subject<void>;
get loaded(): Observable<void> {
return this._loadedObservable;
}
runningProcess: RunningProcess = null;
runningMethod: RunningMethod = null;
errorLoading = false;
......@@ -25,6 +31,8 @@ export class ProcessApiService implements OnDestroy {
}
private init(): void {
this._loaded = new Subject<void>();
this._loadedObservable = this._loaded.asObservable();
this.querySubscription = this.route.queryParamMap.subscribe((params) => {
this.stepInfo = {
step: params.has('step') ? +params.get('step') : undefined,
......@@ -48,6 +56,7 @@ export class ProcessApiService implements OnDestroy {
ngOnDestroy(): void {
this.checkUnsubscribeChangesFeed();
this.querySubscription.unsubscribe();
this._loaded.complete();
}
isInitialized(): boolean {
......@@ -91,6 +100,8 @@ export class ProcessApiService implements OnDestroy {
if (this.runningMethod == null) {
this.errorLoading = true;
this.runningMethod = null;
} else {
this._loaded.next();
}
}
......
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