Skip to content

View polish: inline scripts to assets, form-state helper, label associations - #149

Merged
dkastl merged 1 commit into
mainfrom
fix/145-view-polish
Aug 5, 2026
Merged

View polish: inline scripts to assets, form-state helper, label associations#149
dkastl merged 1 commit into
mainfrom
fix/145-view-polish

Conversation

@dkastl

@dkastl dkastl commented Aug 5, 2026

Copy link
Copy Markdown
Member

Closes #145. Deferred from the 2026-08 maintainer review.

Inline scripts move to assets (Vitest-covered)

  • gtt_fiware_list.js takes over the rails-ujs handlers from _list.html.erb. Two behavior fixes come with the move:
    • The handlers now attach whenever the list exists. Previously they only rendered when a browser-token connection was on the page, so for stored-auth connections a server-side publish/unpublish succeeded invisibly: no row refresh, no outcome message. Verified live on the dev instance (all-stored): a rejected publish now swaps the rows and shows the X-Redmine-Message outcome.
    • HTML and JS responses are told apart by Content-Type instead of excluding one link class. The old class-based exclusion covered copy but not sync, so a sync response could be written into the table body as raw JS source.
  • gtt_fiware_connection_form.js takes over the NGSI standard toggle from broker_connections/_form.html.erb (same js-ngsi-*-only convention as the template form).

Form-state helper

The logic-heavy ERB prologues of _form_filters, _form_basics and _form_issue_details move into SubscriptionTemplateFormHelper: geo area mode, project boundary availability, watched-attributes formatting, entity/attachment picker state, and issue geometry mode. The partials keep markup only, and the branching is now unit-tested (15 runs). The helper is declared on the controller because Redmine only auto-includes the helper matching the controller name.

Label associations

Labels with a single control get for= (watched attributes, status, priority, category, version, notification user, browser token box), following the pattern the custom-field rows already used. The entity/attachment picker row inputs and the match-kind select get aria-labels; five new locale keys added to en/ja/de. Grouped radio/checkbox rows keep plain labels, matching core convention.

Tests

  • Ruby: 355 → 370 runs, 0 failures (full plugin suite in the container).
  • Vitest: 64 → 73 tests (new list_actions.test.js, connection_form.test.js).
  • Live verification on the dev instance: stored-auth publish feedback, copy JS response leaving the list intact, connection standard toggle, label click focusing its input, boundary geo mode derived from a real stored triple.

…iations (#145)

Inline scripts move to assets where the Vitest suite covers them:

- gtt_fiware_list.js takes over the rails-ujs handlers from _list.html.erb.
  The handlers now attach whenever the list exists (previously only when a
  browser-token connection was on the page), so server-side publish and
  unpublish finally refresh the rows and show their X-Redmine-Message
  outcome for stored-auth connections too. HTML and JS responses are told
  apart by Content-Type instead of a link class, which also stops a JS
  response from ever being written into the table body.
- gtt_fiware_connection_form.js takes over the standard toggle from
  broker_connections/_form.html.erb.

The logic-heavy ERB prologues of the form partials move into
SubscriptionTemplateFormHelper (geo mode, boundary availability, watched
attributes formatting, entity/attachment picker state, geometry mode),
declared on the controller because Redmine only auto-includes the helper
matching the controller name.

Labels with a single control get for= associations; the picker row inputs
and the match-kind select get aria-labels (five new locale keys, en/ja/de).

370 Ruby runs and 73 JS tests green; list refresh, connection toggle and
label focus verified live on the dev instance.

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

This PR addresses view-layer polish for the subscription templates and broker connection forms by moving inline JavaScript into asset files (to enable Vitest coverage), extracting complex ERB state derivations into a dedicated helper, and improving accessibility via proper label associations and aria-labels.

Changes:

  • Moved subscription template list and broker connection form inline scripts into assets/javascripts/* with new Vitest coverage.
  • Introduced SubscriptionTemplateFormHelper to encapsulate form-state derivations previously embedded in ERB prologues, with new unit tests.
  • Improved label/input associations and added missing accessibility labels with new i18n keys (en/ja/de).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/unit/subscription_template_form_helper_test.rb Adds unit coverage for the new form-state helper derivations.
test/javascripts/list_actions.test.js Adds Vitest coverage for list rails-ujs handlers (HTML-vs-JS response handling, header injection).
test/javascripts/connection_form.test.js Adds Vitest coverage for broker standard-based field toggling.
config/locales/ja.yml Adds new label keys for accessibility labels (entity/attachment picker).
config/locales/en.yml Adds new label keys for accessibility labels (entity/attachment picker).
config/locales/de.yml Adds new label keys for accessibility labels (entity/attachment picker).
assets/javascripts/gtt_fiware_list.js New asset implementing list ajax handlers and notification/header behavior.
assets/javascripts/gtt_fiware_connection_form.js New asset implementing standard-based field visibility toggling.
app/views/subscription_templates/_list.html.erb Uses asset JS, fixes label for=, removes inline script.
app/views/subscription_templates/_form_issue_details.html.erb Replaces ERB prologue logic with helper calls; adds for= label associations.
app/views/subscription_templates/_form_filters.html.erb Replaces ERB prologue logic with helper calls; adds label association for watched attrs.
app/views/subscription_templates/_form_basics.html.erb Replaces entity picker ERB logic with helper-derived picker state.
app/views/subscription_templates/_entity_row.html.erb Adds aria-labels for entity picker inputs/select.
app/views/subscription_templates/_attachment_row.html.erb Adds aria-labels for attachment picker inputs.
app/views/broker_connections/_form.html.erb Replaces inline standard toggle script with asset include.
app/helpers/subscription_template_form_helper.rb New helper encapsulating form-state derivations for templates.
app/controllers/subscription_templates_controller.rb Explicitly includes the new helper for the controller’s views.

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

@dkastl
dkastl merged commit 2182a18 into main Aug 5, 2026
12 checks passed
@dkastl
dkastl deleted the fix/145-view-polish branch August 5, 2026 13:26
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.

View polish: inline scripts into assets, form helpers, label associations

2 participants