Skip to content

Option for unit preference#1467

Open
yannik131 wants to merge 4 commits into
masterfrom
784-option-for-unit-preference
Open

Option for unit preference#1467
yannik131 wants to merge 4 commits into
masterfrom
784-option-for-unit-preference

Conversation

@yannik131
Copy link
Copy Markdown
Contributor

Closes #784

@yannik131 yannik131 requested a review from Copilot May 21, 2026 13:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “Preferred unit” annotator setting intended to let users force measurement displays (length/area) to a chosen unit instead of automatic selection.

Changes:

  • Adds a Preferred unit selector to the annotator settings UI.
  • Centralizes available unit names/multipliers in annotations/utils.js and updates measurement/scale-line rendering to use them.
  • Wires the new setting through the settings store and into measurement-related components.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
resources/views/annotations/show/tabs/settings.blade.php Adds a <select> control for choosing a preferred unit in the settings sidebar.
resources/assets/js/annotations/utils.js Introduces exported UnitNames/UnitMultipliers; updates ScaleLineProperties to optionally use a fixed unit and formats values via Intl.NumberFormat.
resources/assets/js/annotations/stores/settings.js Adds a default value for the new unit preference setting.
resources/assets/js/annotations/mixins/measureComponent.vue Removes local unit arrays (now centralized in utils.js).
resources/assets/js/annotations/components/settingsTab.vue Provides unit list to the template and persists the selected preferred unit via the settings store.
resources/assets/js/annotations/components/screenshotButton.vue Passes preferred unit into ScaleLineProperties when drawing the scale line in screenshots.
resources/assets/js/annotations/components/scaleLineIndicator.vue Passes preferred unit into ScaleLineProperties for the on-canvas scale line indicator.
resources/assets/js/annotations/components/measureTooltip.vue Uses centralized units, reads preferred unit from settings, and updates formatting/unit selection logic.
resources/assets/js/annotations/annotatorContainer.vue Adds handling for preferredUnit changes emitted from the settings tab.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread resources/assets/js/annotations/stores/settings.js Outdated
Comment thread resources/assets/js/annotations/components/settingsTab.vue
Comment thread resources/assets/js/annotations/annotatorContainer.vue
Comment thread resources/assets/js/annotations/components/measureTooltip.vue
Comment thread resources/assets/js/annotations/components/measureTooltip.vue Outdated
Comment thread resources/assets/js/annotations/components/scaleLineIndicator.vue
@yannik131
Copy link
Copy Markdown
Contributor Author

@mzur The preferred unit can be set using a dropdown in the settings tab, where auto is the default value at the top of the list (previous behaviour). Let me know if you prefer a switch to disable a preferred unit instead, I didn't really know where to put it (maybe to the left of the dropdown, disable/enable the dropdown accordingly?).
To accomodate large/small numbers I switched from the Math.round logic to Intl.NumberFormat("en-US", { maximumSignificantDigits: ... }) which will display leading zeros in small numbers and group digits of larger numbers using commas (388000.02 mm² -> 388,000.02 px²).
Both the scale line and measure tooltips already do a decent job of displaying larger numbers, so I didn't change anything there.

@yannik131 yannik131 marked this pull request as ready for review May 21, 2026 14:50
@yannik131 yannik131 requested a review from mzur May 21, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings option for unit preference

2 participants