Skip to content

feat: configurable distance display unit - #411

Merged
dkastl merged 2 commits into
nextfrom
feat/distance-unit-setting
Jul 27, 2026
Merged

feat: configurable distance display unit#411
dkastl merged 2 commits into
nextfrom
feat/distance-unit-setting

Conversation

@dkastl

@dkastl dkastl commented Jul 27, 2026

Copy link
Copy Markdown
Member

Part 1 of 3 for #10 (closes via a release PR once all parts are in).

Adds a distance_unit plugin setting — m, km, ft, mi, nm (degrees/radians from the issue's list dropped as not meaningful for UI) — applied so far to the distance column: the header becomes e.g. "Distance (km)" (caption proc) and list/CSV cells render converted, via a QueriesHelper prepend.

Meters stay the internal contract everywhere: storage, SQL, the filter wire format, and the REST API are untouched (the API behavior documented in #410 does not change). Per discussion, a second api_distance_unit setting is reserved with meters as its only allowed value — the reader clamps to m — so a later version can widen the API options without a settings migration.

Still to come in follow-up PRs: the distance filter input (entered in the display unit, converted client-side) and the nearby-watch radius field from #14 (storage moving to meters while unreleased).

Verified: full plugin suite in the local Redmine 7.0 mirror — 98 runs, 533 assertions, 0 failures (12 new tests: conversion table, setting fallbacks, API-unit clamp, caption unit, column/CSV rendering).

First part of #10: a distance_unit plugin setting (m, km, ft, mi, nm)
that drives what users see. Meters remain the internal unit everywhere
(storage, SQL, filter wire format, REST API).

- RedmineGtt::DistanceUnit: unit table, current/api_unit readers with
  fallback, to/from-meters conversion
- distance column: header carries the unit (caption proc), list and
  CSV cells render converted via a QueriesHelper prepend
- api_distance_unit setting reserved with meters as the only option,
  so the API contract can widen later without a settings migration
- settings UI selects + en/ja/de locales

The distance filter input and the nearby-watch radius field follow in
separate PRs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds configurable distance display units to the Redmine GTT plugin (part 1/3 of #10), keeping meters as the internal/storage/API contract while converting only the distance column header and rendered values.

Changes:

  • Introduces a distance_unit (and reserved api_distance_unit) plugin setting plus a RedmineGtt::DistanceUnit conversion helper.
  • Updates the distance query column caption to include the configured unit, and converts list/CSV cell rendering via a QueriesHelper prepend.
  • Adds unit tests covering conversions, defaults/fallbacks, caption unit, and column/CSV rendering.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/unit/queries_helper_patch_test.rb Adds coverage for distance column rendering and CSV formatting.
test/unit/distance_unit_test.rb Adds coverage for unit defaults, fallbacks, conversion table, API clamp, and caption unit.
lib/redmine_gtt/patches/queries_helper_patch.rb Prepends QueriesHelper to render distance values in the configured unit for list/CSV.
lib/redmine_gtt/patches/issue_query_patch.rb Appends the configured unit to the distance column header caption.
lib/redmine_gtt/distance_unit.rb Implements unit conversion logic and settings readers.
lib/redmine_gtt.rb Applies the new QueriesHelper patch during setup.
init.rb Adds default plugin settings for distance_unit and api_distance_unit.
config/locales/ja.yml Adds i18n strings for the new settings and unit labels.
config/locales/en.yml Adds i18n strings for the new settings and unit labels.
config/locales/de.yml Adds i18n strings for the new settings and unit labels.
app/views/settings/gtt/_general.html.erb Adds settings UI for selecting display/API distance units.

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

Comment thread lib/redmine_gtt/distance_unit.rb
Comment thread config/locales/en.yml
Comment thread config/locales/de.yml
Comment thread config/locales/ja.yml
- unknown units fall back to meters instead of raising KeyError (the
  setting can be hand-edited, callers may pass user-supplied strings)
- the CSV separator test derives its expectation from the locale
  instead of hardcoding '.'
@dkastl
dkastl merged commit 5a019b7 into next Jul 27, 2026
8 checks passed
@dkastl
dkastl deleted the feat/distance-unit-setting branch July 27, 2026 11:56
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.

2 participants