Skip to content
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

Get scale_bar from locale #1068

Merged
merged 6 commits into from
Jan 22, 2024
Merged

Conversation

RobAndrewHurst
Copy link
Contributor

Pull Request: Get scale_bar from locale 🌐📏

Description

This pull request addresses the need to retrieve the scale_bar information from the locale. The changes aim to improve the localization of the scale bar in our application, enhancing the user experience by dynamically obtaining this information based on the user's locale.

Changes Made

  • Updated the scale_bar property in the default mapview to take the scaleBar property from the locales configuration. 🗺️🔄

Testing Done

  • Tested against a workspace with multiple locales. One with 'imperial', 'Metric' and default (no scaleBar). ✔️🌍

@RobAndrewHurst RobAndrewHurst added the Code Issues related to the code structure and performance. label Jan 19, 2024
Copy link
Contributor

@simon-leech simon-leech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RobAndrewHurst Tested this and it works all good when you provide either metric or imperial.
However, I tested this using a bogus term test and it fails with an error on Invalid Units. I wonder if this should be using a ternary or checking that the scaleBar value is either metric or imperial to guard against this.

Please could you also update the Config Docs to explain this is a new option available? Thanks! 🙂

@RobAndrewHurst
Copy link
Contributor Author

@simon-leech I have made the changes!

@RobAndrewHurst
Copy link
Contributor Author

Copy link
Contributor

@AlexanderGeere AlexanderGeere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on my end

@simon-leech
Copy link
Contributor

Thanks @RobAndrewHurst - good with me!

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scalebar line can be completely removed from the default view script.

The scalebar should not be there by default but only if configured in the locale.

Please check if you are happy with the changes.

@RobAndrewHurst
Copy link
Contributor Author

The scalebar line can be completely removed from the default view script.

The scalebar should not be there by default but only if configured in the locale.

Please check if you are happy with the changes.

I still think we need a check if the config has a bogus unit provided. ie something not 'metric' or 'imperial'

@RobAndrewHurst
Copy link
Contributor Author

RobAndrewHurst commented Jan 22, 2024

  mapview.locale.scalebar && mapview.Map.addControl(new ol.control.ScaleLine({
    units: mapview.locale.scalebar === 'imperial' ? 'imperial' : 'metric',
  }))

@dbauszus-glx Also should scalebar not be scaleBar to keep in consistency with other properties that we use like minZoom and maxZoom?

@dbauszus-glx
Copy link
Member

That's all good points. If changing the name I would probably opt for matching the OL dictionary, ie. ScaleLine

I think there is only the options for imperial or metric. A check if ScaleLine === 'imperial' ? 'imperial' : 'metric' could work.

@RobAndrewHurst
Copy link
Contributor Author

Ok cool! I am happy to change to ScaleLine.

I have already added in that check! 👍

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@RobAndrewHurst
Copy link
Contributor Author

@RobAndrewHurst RobAndrewHurst merged commit df5650d into GEOLYTIX:main Jan 22, 2024
5 checks passed
@RobAndrewHurst RobAndrewHurst deleted the scale_bar branch January 25, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Issues related to the code structure and performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants