1
0

added tests and typedoc

This commit is contained in:
lotte
2020-03-25 13:18:46 +01:00
committed by Art Lowel
parent e38aec831f
commit ef3a235178
36 changed files with 701 additions and 46 deletions

View File

@@ -3,27 +3,54 @@ import { Script } from '../../scripts/script.model';
import { ProcessParameter } from '../../processes/process-parameter.model';
import { hasValue } from '../../../shared/empty.util';
/**
* Component that represents the selected list of parameters for a script
*/
@Component({
selector: 'ds-process-parameters',
templateUrl: './process-parameters.component.html',
styleUrls: ['./process-parameters.component.scss']
})
export class ProcessParametersComponent implements OnChanges {
/**
* The currently selected script
*/
@Input() script: Script;
/**
* Emits the parameter values when they're updated
*/
@Output() updateParameters: EventEmitter<ProcessParameter[]> = new EventEmitter();
/**
* The current parameter values
*/
parameterValues: ProcessParameter[];
/**
* Makes sure the parameters are reset when the script changes
* @param changes
*/
ngOnChanges(changes: SimpleChanges): void {
if (changes.script) {
this.initParameters()
}
}
/**
* Empties the parameter values
* Initializes the first parameter value
*/
initParameters() {
this.parameterValues = [];
this.addParameter();
}
/**
* Updates a single parameter value using its new value and index
* Adds a new parameter when the last of the parameter values is changed
* @param processParameter The new value of the parameter
* @param index The index of the parameter
*/
updateParameter(processParameter: ProcessParameter, index: number) {
this.parameterValues[index] = processParameter;
if (index === this.parameterValues.length - 1) {
@@ -32,10 +59,17 @@ export class ProcessParametersComponent implements OnChanges {
this.updateParameters.emit(this.parameterValues.filter((param: ProcessParameter) => hasValue(param.name)));
}
/**
* Removes a parameter value from the list
* @param index The index of the parameter to remove
*/
removeParameter(index: number) {
this.parameterValues = this.parameterValues.filter((value, i) => i !== index);
}
/**
* Adds an empty parameter value to the end of the list
*/
addParameter() {
this.parameterValues = [...this.parameterValues, new ProcessParameter()];
}