Skip to content

feat: distance filter input in the configured display unit - #412

Merged
dkastl merged 5 commits into
nextfrom
feat/distance-unit-filter-input
Jul 27, 2026
Merged

feat: distance filter input in the configured display unit#412
dkastl merged 5 commits into
nextfrom
feat/distance-unit-filter-input

Conversation

@dkastl

@dkastl dkastl commented Jul 27, 2026

Copy link
Copy Markdown
Member

Part 2 of 3 for #10, stacked on #411 (diff shrinks to the frontend commit once it merges).

The distance filter row now works in the configured display unit:

  • values arriving from the server (meters) are converted for display (metersToUnitValue, float-noise trimmed so a 25 km round trip shows 25, not 24.999999997), with the unit label rendered next to both bound inputs (incl. the between operator's upper bound)
  • a submit hook on #query_form converts the visible values back to integer meters, so the wire format, saved queries, permalinks and the API all stay metric — the server sees exactly what it always saw
  • the hook binds via jQuery when available: core submits the query form with $('#query_form').submit(), which triggers jQuery-bound handlers but bypasses native addEventListener listeners
  • the unit reaches the frontend through the existing #gtt-defaults plugin_settings payload — no new plumbing

Verified E2E in a browser with distance_unit=km: wire value 500000 displays as 500 km; typing 100 and applying produces v[distance][]=100000 in the URL, correct (empty) result set, and the restored input shows 100 again. Unit tests: 4 new Vitest cases (unit table parity with the Ruby side, conversions, float-noise trimming, passthrough).

dkastl added 2 commits July 27, 2026 20:39
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.
Second part of #10. The distance filter row displays and accepts its
bounds in the configured unit: values coming from the server (meters)
convert for display, and a submit hook on #query_form converts back to
integer meters, so the wire format, saved queries and the API stay
metric. The unit label renders next to the inputs.

The hook binds via jQuery when present because core submits the form
with $('#query_form').submit(), which bypasses native listeners.

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 end-to-end support for entering and displaying the distance query filter in the configured distance unit while keeping the server/API contract in meters, completing the “filter input” portion of the multi-unit distance feature (#10) that started in #411.

Changes:

  • Frontend: convert distance filter values from meters → configured unit for display, and convert back on #query_form submit.
  • Backend: introduce RedmineGtt::DistanceUnit and use it to render distance column/list + CSV in the configured unit.
  • Settings/i18n/tests: add distance unit settings UI, translations, and unit tests for conversion/parity.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/gtt-client/redmine/filters.ts Converts distance filter inputs between meters (wire) and configured display units; adds submit hook.
src/components/gtt-client/redmine/filters.test.ts Adds Vitest coverage for unit table parity and display conversion trimming.
lib/redmine_gtt/distance_unit.rb Adds server-side conversion utilities and unit tables.
lib/redmine_gtt/patches/queries_helper_patch.rb Renders distance column and CSV values in the configured unit.
lib/redmine_gtt/patches/issue_query_patch.rb Updates distance column caption to include the configured unit.
lib/redmine_gtt.rb Applies the new QueriesHelper patch during setup.
init.rb Adds default plugin settings for distance_unit and api_distance_unit.
app/views/settings/gtt/_general.html.erb Adds settings UI for distance unit selection (display + reserved API unit).
config/locales/en.yml Adds English strings for distance unit settings and options.
config/locales/de.yml Adds German strings for distance unit settings and options.
config/locales/ja.yml Adds Japanese strings for distance unit settings and options.
test/unit/distance_unit_test.rb Adds unit tests for server-side conversion and unit selection behavior.
test/unit/queries_helper_patch_test.rb Adds helper tests for column/CSV rendering under the configured unit.

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

Comment thread src/components/gtt-client/redmine/filters.ts
Comment thread test/unit/queries_helper_patch_test.rb
dkastl added 3 commits July 27, 2026 20:53
- 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 dcaa6be into next Jul 27, 2026
8 checks passed
@dkastl
dkastl deleted the feat/distance-unit-filter-input branch July 27, 2026 11:57
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