#1631 Should create an empty form when the process definitions are empty (#1633)

This commit is contained in:
Maurizio Vitale 2017-02-15 11:42:48 +00:00 committed by Vito
parent e3cbff0e35
commit c1493315bf
4 changed files with 29 additions and 0 deletions

View File

@ -139,6 +139,13 @@ export var reportDefParamTask = {
'definition': '{ "parameters" :[{"id":"taskName","name":null,"nameKey":null,"type":"task","value":null,"dependsOn":"processDefinitionId"}]}' 'definition': '{ "parameters" :[{"id":"taskName","name":null,"nameKey":null,"type":"task","value":null,"dependsOn":"processDefinitionId"}]}'
}; };
export var reportNoParameterDefinitions = {
'id': 2006,
'name': 'Fake Task service level agreement',
'created': '2016-10-05T15:39:40.222+0000',
'definition': '{ "parameters" : []}'
};
export var reportDefParamTaskOptions = ['Fake task name 1', 'Fake task name 2']; export var reportDefParamTaskOptions = ['Fake task name 1', 'Fake task name 2'];
export var fieldProcessDef = new ReportParameterDetailsModel( export var fieldProcessDef = new ReportParameterDetailsModel(

View File

@ -81,6 +81,9 @@ export class AnalyticsGeneratorComponent implements OnChanges {
} }
public generateReport(reportId, reportParamQuery) { public generateReport(reportId, reportParamQuery) {
if (reportParamQuery === undefined || reportParamQuery === null) {
reportParamQuery = {};
}
this.analyticsService.getReportsByParams(reportId, reportParamQuery).subscribe( this.analyticsService.getReportsByParams(reportId, reportParamQuery).subscribe(
(res: Chart[]) => { (res: Chart[]) => {
this.reports = res; this.reports = res;

View File

@ -342,6 +342,24 @@ describe('AnalyticsReportParametersComponent', () => {
}); });
it('Should create an empty valid form when there are no parameters definitions', () => {
component.onSuccess.subscribe((res) => {
expect(component.reportForm).toBeDefined();
expect(component.reportForm.valid).toEqual(true);
expect(component.reportForm.controls).toEqual({});
});
let reportId = 1;
let change = new SimpleChange(null, reportId);
component.ngOnChanges({ 'reportId': change });
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportNoParameterDefinitions
});
});
it('Should load the task list when a process definition is selected', () => { it('Should load the task list when a process definition is selected', () => {
component.onSuccessReportParams.subscribe((res) => { component.onSuccessReportParams.subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();

View File

@ -195,6 +195,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
if (this.reportParameters.hasParameters()) { if (this.reportParameters.hasParameters()) {
this.onSuccessReportParams.emit(res); this.onSuccessReportParams.emit(res);
} else { } else {
this.reportForm = this.formBuilder.group({});
this.onSuccess.emit(); this.onSuccess.emit();
} }
}, },