Skip to content

Commit 58e16b3

Browse files
author
DanielSteger
committed
[IT-2812] Set http request parameter for result selection only if available #2
1 parent 91a10b2 commit 58e16b3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

frontend/src/app/modules/result-selection/services/result-selection.service.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,29 @@ export class ResultSelectionService {
1111
}
1212

1313
fetchResultSelectionData<T>(resultSelectionCommand: ResultSelectionCommand, url: URL): Observable<T> {
14-
const params = this.createParamsFromResultSelectionCommand(resultSelectionCommand);
15-
return this.http.get<T>(url, {params: params}).pipe(
16-
this.handleError()
17-
)
14+
if (resultSelectionCommand.from && resultSelectionCommand.to) {
15+
const params = this.createParamsFromResultSelectionCommand(resultSelectionCommand);
16+
return this.http.get<T>(url, {params: params}).pipe(
17+
this.handleError()
18+
)
19+
}
20+
return new Observable<T>();
1821
}
1922

2023
private createParamsFromResultSelectionCommand(resultSelectionCommand: ResultSelectionCommand) {
21-
let params = new HttpParams();
24+
let params = new HttpParams()
25+
.set('from', resultSelectionCommand.from.toISOString())
26+
.set('to', resultSelectionCommand.to.toISOString())
27+
.set('caller', Caller[resultSelectionCommand.caller]);
2228

2329
Object.keys(resultSelectionCommand).forEach(key => {
30+
if (key === 'from' || key === 'to' || key === 'caller') {
31+
return;
32+
}
2433
if (resultSelectionCommand[key].length > 0) {
25-
if (key === 'from' || key === 'to') {
26-
params.append(key, resultSelectionCommand[key].toISOString())
27-
} else if (key === 'caller') {
28-
params.append(key, Caller[resultSelectionCommand[key]])
29-
} else {
30-
resultSelectionCommand[key].forEach(id => {
31-
params = params.append(key, id.toString())
32-
});
33-
}
34+
resultSelectionCommand[key].forEach(id => {
35+
params = params.append(key, id.toString())
36+
});
3437
}
3538
});
3639

0 commit comments

Comments
 (0)