View polish: inline scripts to assets, form-state helper, label associations - #149
Merged
Conversation
…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.
There was a problem hiding this comment.
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
SubscriptionTemplateFormHelperto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #145. Deferred from the 2026-08 maintainer review.
Inline scripts move to assets (Vitest-covered)
gtt_fiware_list.jstakes over the rails-ujs handlers from_list.html.erb. Two behavior fixes come with the move:Content-Typeinstead 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.jstakes over the NGSI standard toggle frombroker_connections/_form.html.erb(samejs-ngsi-*-onlyconvention as the template form).Form-state helper
The logic-heavy ERB prologues of
_form_filters,_form_basicsand_form_issue_detailsmove intoSubscriptionTemplateFormHelper: 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 getaria-labels; five new locale keys added to en/ja/de. Grouped radio/checkbox rows keep plain labels, matching core convention.Tests
list_actions.test.js,connection_form.test.js).