mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1489 from atmire/Process-empty-parameters-fix
Scripts & Processes without parameters fix
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user