Merge pull request #1489 from atmire/Process-empty-parameters-fix

Scripts & Processes without parameters fix
This commit is contained in:
Tim Donohue
2022-01-13 16:15:49 -06:00
committed by GitHub
2 changed files with 16 additions and 1 deletions

View File

@@ -87,4 +87,15 @@ describe('ProcessFormComponent', () => {
component.submitForm({ controls: {} } as any);
expect(scriptService.invoke).toHaveBeenCalled();
});
describe('when undefined parameters are provided', () => {
beforeEach(() => {
component.parameters = undefined;
});
it('should invoke the script with an empty array of parameters', () => {
component.submitForm({ controls: {} } as any);
expect(scriptService.invoke).toHaveBeenCalledWith(script.id, [], jasmine.anything());
});
});
});

View File

@@ -12,6 +12,7 @@ import { Router } from '@angular/router';
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
import { RemoteData } from '../../core/data/remote-data';
import { getProcessListRoute } from '../process-page-routing.paths';
import { isEmpty } from '../../shared/empty.util';
/**
* Component to create a new script
@@ -35,7 +36,7 @@ export class ProcessFormComponent implements OnInit {
/**
* The parameter values to use to start the process
*/
@Input() public parameters: ProcessParameter[];
@Input() public parameters: ProcessParameter[] = [];
/**
* Optional files that are used as parameter values
@@ -69,6 +70,9 @@ export class ProcessFormComponent implements OnInit {
* @param form
*/
submitForm(form: NgForm) {
if (isEmpty(this.parameters)) {
this.parameters = [];
}
if (!this.validateForm(form) || this.isRequiredMissing()) {
return;
}