-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WFNEWS-2419 route back to map page from full details #2167
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8d27497
WFNEWS-2419 route back to map page from full details
ssylver93 d286550
Update comments
ssylver93 b3bf266
Fix typo
ssylver93 123f36f
Update comments
ssylver93 0bdccd9
Route back to previous zoom level for bans, evacs, area restrictions …
ssylver93 8ff3d99
Make backToMap logic more readable
ssylver93 92f5ae9
Add same functionality for fire danger and handle navigation detectio…
ssylver93 d1a5323
Update isCurrentlyNavigatedOn function to be more clear
ssylver93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,21 +15,21 @@ export class FullDetailsComponent implements OnInit, OnDestroy { | |||||||||||||
private router: Router, | ||||||||||||||
private route: ActivatedRoute, | ||||||||||||||
private agolService: AGOLService, | ||||||||||||||
) {} | ||||||||||||||
) { } | ||||||||||||||
|
||||||||||||||
ngOnInit(): void { | ||||||||||||||
this.route.queryParams.subscribe((params: ParamMap) => { | ||||||||||||||
this.params = params; | ||||||||||||||
}); | ||||||||||||||
if (document.getElementById('mobile-navigation-bar')) { | ||||||||||||||
document.getElementById('mobile-navigation-bar').style.display = 'none'; | ||||||||||||||
} | ||||||||||||||
document.getElementById('mobile-navigation-bar').style.display = 'none'; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
ngOnDestroy(): void { | ||||||||||||||
if (document.getElementById('mobile-navigation-bar')) { | ||||||||||||||
document.getElementById('mobile-navigation-bar').style.display = 'block'; | ||||||||||||||
} | ||||||||||||||
document.getElementById('mobile-navigation-bar').style.display = 'block'; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
getTitle() { | ||||||||||||||
|
@@ -48,8 +48,13 @@ document.getElementById('mobile-navigation-bar').style.display = 'block'; | |||||||||||||
|
||||||||||||||
back() { | ||||||||||||||
try { | ||||||||||||||
if (this.params && this.params['source']) { | ||||||||||||||
if ( | ||||||||||||||
if (this.params?.['source']) { | ||||||||||||||
// If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, | ||||||||||||||
// fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, | ||||||||||||||
// along with the appropriate coordinates for that type. | ||||||||||||||
if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { | ||||||||||||||
this.backToMap(); | ||||||||||||||
} else if ( | ||||||||||||||
this.params['source'] === 'saved-location' && | ||||||||||||||
this.params['sourceName'] && | ||||||||||||||
this.params['sourceLongitude'] && | ||||||||||||||
|
@@ -75,18 +80,78 @@ document.getElementById('mobile-navigation-bar').style.display = 'block'; | |||||||||||||
}, | ||||||||||||||
}); | ||||||||||||||
} else { | ||||||||||||||
this.router.navigate(this.params['source']); | ||||||||||||||
} | ||||||||||||||
this.router.navigate(this.params['source']); | ||||||||||||||
} | ||||||||||||||
} else { | ||||||||||||||
throw new Error('No previous screen to route too'); | ||||||||||||||
} | ||||||||||||||
throw new Error('No previous screen to route to'); | ||||||||||||||
} | ||||||||||||||
} catch (err) { | ||||||||||||||
console.error(err); | ||||||||||||||
this.router.navigate([ResourcesRoutes.DASHBOARD]); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async exit() { | ||||||||||||||
this.router.navigate([ResourcesRoutes.DASHBOARD]); | ||||||||||||||
exit() { | ||||||||||||||
// If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, | ||||||||||||||
// fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, | ||||||||||||||
// along with the appropriate coordinates for that type | ||||||||||||||
if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { | ||||||||||||||
this.backToMap(); | ||||||||||||||
} else { | ||||||||||||||
this.router.navigate([ResourcesRoutes.DASHBOARD]); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
navigatedfromMapPage() { | ||||||||||||||
if (this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') { | ||||||||||||||
return true; | ||||||||||||||
} else { | ||||||||||||||
return false; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
isCurrentlyNavigatedOn() { | ||||||||||||||
const fullDetailPageTypes = ['area-restriction', 'bans-prohibitions', 'evac-orders', 'evac-alerts', 'danger-rating']; | ||||||||||||||
if(fullDetailPageTypes.includes(this.params?.['type'])){ | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||
return true; | ||||||||||||||
} else { | ||||||||||||||
return false; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// use query params to determine the layer, coordinates and zoom level for routing back to the map | ||||||||||||||
backToMap() { | ||||||||||||||
const navigateToMap = (longitude: number, latitude: number, zoom: string, queryParamKey: string) => { | ||||||||||||||
setTimeout(() => { | ||||||||||||||
this.router.navigate([ResourcesRoutes.ACTIVEWILDFIREMAP], { | ||||||||||||||
queryParams: { | ||||||||||||||
longitude, | ||||||||||||||
latitude, | ||||||||||||||
zoom, | ||||||||||||||
[queryParamKey]: true | ||||||||||||||
}, | ||||||||||||||
}); | ||||||||||||||
}, 100); | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
if (this.params['type'] && this.params['sourceLongitude'] && this.params['sourceLatitude'] && this.params['sourceZoom']) { | ||||||||||||||
switch (this.params['type']) { | ||||||||||||||
case 'area-restriction': | ||||||||||||||
navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'areaRestriction'); | ||||||||||||||
break; | ||||||||||||||
case 'bans-prohibitions': | ||||||||||||||
navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'bansProhibitions'); | ||||||||||||||
break; | ||||||||||||||
case 'danger-rating': | ||||||||||||||
navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'dangerRating'); | ||||||||||||||
break; | ||||||||||||||
case 'evac-alert': | ||||||||||||||
case 'evac-order': | ||||||||||||||
navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'evacuationAlert'); | ||||||||||||||
break; | ||||||||||||||
} | ||||||||||||||
} else { | ||||||||||||||
throw new Error('Error occurred while routing back to map'); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done