Skip to content

Commit ddce6d7

Browse files
committed
fix(traffic-result-limit.components.ts): updates the offsetvalue to be greaterthan or equal to zero since the component is tied to the no records found module
1 parent a6c32c9 commit ddce6d7

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed
Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { Location, NgIf } from '@angular/common';
3-
4-
@Component({
5-
selector: 'custom-traffic-result-limit',
6-
standalone: true,
7-
imports: [NgIf],
8-
templateUrl: './traffic-result-limit.component.html',
9-
styleUrl: './traffic-result-limit.component.scss',
10-
})
11-
export class TrafficResultLimitComponent implements OnInit {
12-
showComponent: boolean = false;
13-
offsetValue: number | null = null;
14-
15-
constructor(private location: Location) {}
16-
17-
ngOnInit(): void {
18-
this.checkOffset();
19-
}
20-
21-
checkOffset(): void {
22-
const url = this.location.path();
23-
const queryString = url.includes('?') ? url.split('?')[1] : '';
24-
25-
if (!queryString) {
26-
this.showComponent = false;
27-
return;
28-
}
29-
30-
const urlParams = new URLSearchParams(queryString);
31-
const offsetParam = urlParams.get('offset');
32-
33-
if (offsetParam) {
34-
const offsetValue = parseInt(offsetParam, 10);
35-
if (!isNaN(offsetValue) && offsetValue > 500) {
36-
this.showComponent = true;
37-
} else {
38-
this.showComponent = false;
39-
}
40-
} else {
41-
this.showComponent = false;
42-
}
43-
}
44-
}
1+
import { Component, OnInit } from '@angular/core';
2+
import { Location, NgIf } from '@angular/common';
3+
4+
@Component({
5+
selector: 'custom-traffic-result-limit',
6+
standalone: true,
7+
imports: [NgIf],
8+
templateUrl: './traffic-result-limit.component.html',
9+
styleUrl: './traffic-result-limit.component.scss',
10+
})
11+
export class TrafficResultLimitComponent implements OnInit {
12+
showComponent: boolean = false;
13+
offsetValue: number | null = null;
14+
15+
constructor(private location: Location) {}
16+
17+
ngOnInit(): void {
18+
this.checkOffset();
19+
}
20+
21+
checkOffset(): void {
22+
const url = this.location.path();
23+
const queryString = url.includes('?') ? url.split('?')[1] : '';
24+
25+
if (!queryString) {
26+
this.showComponent = false;
27+
return;
28+
}
29+
30+
const urlParams = new URLSearchParams(queryString);
31+
const offsetParam = urlParams.get('offset');
32+
33+
if (offsetParam) {
34+
const offsetValue = parseInt(offsetParam, 10);
35+
// if the user uses the navigation button, this will display with the offset is `550`. If `500` is mannually added to the `offset` parameter within the browser url box, this will not dispaly if the the below function is set to `offsetValue > 500`. Think about making this change within production before going live.
36+
if (!isNaN(offsetValue) && offsetValue >= 0) {
37+
this.showComponent = true;
38+
} else {
39+
this.showComponent = false;
40+
}
41+
} else {
42+
this.showComponent = false;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)