Commit 74ba04e4 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Fix return types of exection steps and artifact mappings

parent a0319b27
......@@ -8,7 +8,7 @@ import {
Output,
SimpleChanges,
} from '@angular/core';
import { FormGroupDirective } from '@angular/forms';
import { FormControl, FormGroup, FormGroupDirective } from '@angular/forms';
import { Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';
import { ModuleService } from '../../development-process-registry/module-api/module.service';
......@@ -41,7 +41,7 @@ export class DevelopmentMethodArtifactMappingComponent
private moduleService: ModuleService
) {}
ngOnInit() {
ngOnInit(): void {
this.updateSubscriptions();
this.outputChangeSubscription = this.outputControl.valueChanges
.pipe(
......@@ -54,13 +54,13 @@ export class DevelopmentMethodArtifactMappingComponent
.subscribe();
}
ngOnChanges(changes: SimpleChanges) {
ngOnChanges(changes: SimpleChanges): void {
if (changes.developmentMethod) {
this.updateSubscriptions();
}
}
ngOnDestroy() {
ngOnDestroy(): void {
if (this.outputChangeSubscription) {
this.outputChangeSubscription.unsubscribe();
}
......@@ -69,7 +69,7 @@ export class DevelopmentMethodArtifactMappingComponent
}
}
updateSubscriptions() {
updateSubscriptions(): void {
if (this.stepChangeSubscription) {
this.stepChangeSubscription.unsubscribe();
this.stepChangeSubscription = null;
......@@ -95,7 +95,7 @@ export class DevelopmentMethodArtifactMappingComponent
}
}
updateGroupArtifacts(groupNumber: number) {
updateGroupArtifacts(groupNumber: number): void {
const group = this.developmentMethod.outputArtifacts[groupNumber];
this.artifacts = group.map((artifact) => {
if (!artifact.element || !artifact.element.metaModel) {
......@@ -111,7 +111,7 @@ export class DevelopmentMethodArtifactMappingComponent
});
}
updateStepArtifacts(stepNumber: number) {
updateStepArtifacts(stepNumber: number): void {
const step = this.developmentMethod.executionSteps[stepNumber];
this.artifacts = this.moduleService.getModuleMethod(
step.module,
......@@ -119,23 +119,26 @@ export class DevelopmentMethodArtifactMappingComponent
).input;
}
get formGroup() {
get formGroup(): FormGroup {
return this.formGroupDirective.control;
}
get outputControl() {
return this.formGroup.get('output');
get outputControl(): FormControl {
return this.formGroup.get('output') as FormControl;
}
get stepControl() {
return this.formGroup.get('step');
get stepControl(): FormControl {
return this.formGroup.get('step') as FormControl;
}
get groupControl() {
return this.formGroup.get('group');
get groupControl(): FormControl {
return this.formGroup.get('group') as FormControl;
}
artifactConformsToMetaModel(artifact: { name: string; metaModelType: any }) {
artifactConformsToMetaModel(artifact: {
name: string;
metaModelType: any;
}): boolean {
return artifact.metaModelType === this.metaModel.metaModelType;
}
}
import { Component, Input } from '@angular/core';
import { DevelopmentMethod } from '../../development-process-registry/development-method/development-method';
import { FormArrayName } from '@angular/forms';
import { FormArray, FormArrayName } from '@angular/forms';
import { ArtifactMappingFormService } from '../shared/artifact-mapping-form.service';
@Component({
......@@ -18,15 +18,15 @@ export class DevelopmentMethodArtifactMappingsComponent {
private formArrayName: FormArrayName
) {}
addMapping() {
addMapping(): void {
this.formArray.push(this.artifactMappingService.createMappingForm());
}
removeMapping(index: number) {
removeMapping(index: number): void {
this.formArray.removeAt(index);
}
get formArray() {
get formArray(): FormArray {
return this.formArrayName.control;
}
}
......@@ -63,7 +63,7 @@ export class DevelopmentMethodSelectExecutionStepComponent
private moduleService: ModuleService
) {}
ngOnInit() {
ngOnInit(): void {
if (this.moduleControl.value != null) {
this.initMethods(this.moduleControl.value);
}
......@@ -94,7 +94,7 @@ export class DevelopmentMethodSelectExecutionStepComponent
.subscribe();
}
ngOnChanges(changes: SimpleChanges) {
ngOnChanges(changes: SimpleChanges): void {
if (changes.developmentMethod) {
const developmentMethod: DevelopmentMethod =
changes.developmentMethod.currentValue;
......@@ -108,7 +108,7 @@ export class DevelopmentMethodSelectExecutionStepComponent
}
}
ngOnDestroy() {
ngOnDestroy(): void {
if (this.moduleChangeSubscription) {
this.moduleChangeSubscription.unsubscribe();
}
......@@ -116,11 +116,11 @@ export class DevelopmentMethodSelectExecutionStepComponent
this.openMethodInput.complete();
}
initMethods(module: Module) {
initMethods(module: Module): void {
this.methods = Object.values(module.methods);
}
initConfiguration(method: ModuleMethod) {
initConfiguration(method: ModuleMethod): void {
if (
method.configurationFormComponent != null &&
method.createConfigurationForm != null
......@@ -145,12 +145,12 @@ export class DevelopmentMethodSelectExecutionStepComponent
}
}
clearConfiguration() {
clearConfiguration(): void {
this.configurationFormHost.viewContainerRef.clear();
this.formGroup.removeControl('predefinedInput');
}
calculateInput() {
calculateInput(): void {
if (this.selectedMethod != null) {
this.artifactInputs = this.developmentMethod.checkStepInputArtifacts(
this.stepNumber,
......@@ -161,7 +161,7 @@ export class DevelopmentMethodSelectExecutionStepComponent
}
}
searchModule = (input: Observable<string>) => {
searchModule = (input: Observable<string>): Observable<Module[]> => {
return merge(getTypeaheadInputPipe(input), this.openModuleInput).pipe(
map((term) =>
this.modules
......@@ -173,7 +173,7 @@ export class DevelopmentMethodSelectExecutionStepComponent
);
};
searchMethod = (input: Observable<string>) => {
searchMethod = (input: Observable<string>): Observable<ModuleMethod[]> => {
return merge(getTypeaheadInputPipe(input), this.openMethodInput).pipe(
map((term) =>
this.methods
......@@ -185,27 +185,27 @@ export class DevelopmentMethodSelectExecutionStepComponent
);
};
formatter(x: { name: string }) {
formatter(x: { name: string }): string {
return x.name;
}
get moduleControl() {
get moduleControl(): FormControl {
return this.formGroup.get('module') as FormControl;
}
get methodControl() {
get methodControl(): FormControl {
return this.formGroup.get('method') as FormControl;
}
get outputArtifactsControl() {
get outputArtifactsControl(): FormArray {
return this.formGroup.get('outputMappings') as FormArray;
}
get predefinedInputControl() {
get predefinedInputControl(): FormGroup {
return this.formGroup.get('predefinedInput') as FormGroup;
}
get formGroup() {
get formGroup(): FormGroup {
return this.formGroupDirective.control;
}
......
......@@ -42,7 +42,7 @@ export class DevelopmentMethodSelectExecutionStepsComponent
private moduleService: ModuleService
) {}
ngOnInit() {
ngOnInit(): void {
this.changeSubscription = this.executionStepsSelectionForm.valueChanges
.pipe(
debounceTime(300),
......@@ -57,7 +57,7 @@ export class DevelopmentMethodSelectExecutionStepsComponent
.subscribe();
}
ngOnChanges(changes: SimpleChanges) {
ngOnChanges(changes: SimpleChanges): void {
if (changes.developmentMethod) {
const oldDevelopmentMethod: DevelopmentMethod =
changes.developmentMethod.previousValue;
......@@ -75,37 +75,37 @@ export class DevelopmentMethodSelectExecutionStepsComponent
}
}
ngOnDestroy() {
ngOnDestroy(): void {
if (this.changeSubscription) {
this.changeSubscription.unsubscribe();
}
}
addStep() {
addStep(): void {
this.formArray.push(
this.executionStepsFormService.createExecutionStepForm()
);
}
removeStep(index: number) {
removeStep(index: number): void {
this.formArray.removeAt(index);
}
loadForm(executionSteps: ExecutionStep[]) {
loadForm(executionSteps: ExecutionStep[]): void {
this.executionStepsSelectionForm.setControl(
'steps',
this.executionStepsFormService.createForm(executionSteps)
);
}
submitForm() {
submitForm(): void {
this.submitExecutionStepsSelectionForm.emit(this.formArray);
}
private equalExecutionSteps(
executionStepsA: ExecutionStep[],
executionStepsB: ExecutionStep[]
) {
): boolean {
if (!equalsList(executionStepsA, executionStepsB)) {
return false;
}
......@@ -128,7 +128,7 @@ export class DevelopmentMethodSelectExecutionStepsComponent
});
}
get formArray() {
get formArray(): FormArray {
return this.executionStepsSelectionForm.get('steps') as FormArray;
}
}
......@@ -43,7 +43,7 @@ export class ArtifactMappingFormService {
}
}
convertMappingForm(mappingForm: FormGroup) {
convertMappingForm(mappingForm: FormGroup): void {
if (mappingForm.get('output').value) {
mappingForm.removeControl('step');
mappingForm.addControl(
......
......@@ -57,7 +57,7 @@ export class ExecutionStepsFormService {
createMappingsForm(
method: ModuleMethod,
outputMappings: ArtifactMapping[][]
) {
): FormArray {
let outputs = [];
if (method) {
outputs = method.output.map((output, index) => {
......
Markdown is supported
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