Option for unit preference#1467
Conversation
There was a problem hiding this comment.
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.jsand 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.
|
@mzur The preferred unit can be set using a dropdown in the settings tab, where |
| if (measurement === 0) { | ||
| return multipliers.length - 1; | ||
| } | ||
|
|
||
| if (UnitNames.indexOf(this.preferredUnit) !== -1) { | ||
| return UnitNames.indexOf(this.preferredUnit); | ||
| } |
There was a problem hiding this comment.
If there is a preferred unit it should be used even if the measurement is 0.
| } | ||
|
|
||
| return this.formatMeasurement(length, unit); | ||
| return this.formatMeasurement(length, unit, 1); |
There was a problem hiding this comment.
Maybe we should change the number of decimals to 3 too? What do you think?
| @@ -593,6 +594,9 @@ export default { | |||
| case 'draftAnnotationUsesLabelColor': | |||
| this.draftAnnotationUsesLabelColor = value; | |||
| break; | |||
| case 'preferredUnit': | |||
| this.preferredUnit = value; | |||
| break; | |||
There was a problem hiding this comment.
This is never used. The components read the value directly from the settings instead. Either pass this as a prop (or use prop drilling) or remove it here and keep using Settings directly.
Closes #784