inline_forms 8.1.79 → 8.1.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5e23dce20574f758b57ab81d8a344f0d74b8e969c13e305ab426b6270623b9d
4
- data.tar.gz: 49eba2b2136e79bd27dbc51c258681c98cbcf718679d22ceced338e0f252bd3d
3
+ metadata.gz: 50bb6fa49e77c07b640995f0385e6c4194ac115a99c81b622983171ae8cb68e9
4
+ data.tar.gz: e4496274fbf81968e133425f365d0cd5b3cd93921f00f98dc034111184e4d3f1
5
5
  SHA512:
6
- metadata.gz: 8d40d0a5af35ef3889706d15b667cffd1eb12165b5a87f397a200cdd044a9ac28ecaadcb0639632b317b837a85d8eade09fe0545e28848334d1bc88e30f88721
7
- data.tar.gz: 239613687ee6ee98a42b9a0997c63af81b0c9e28f326c152363e2edb6cb918b9b0ac430894d0f2c1d440d93e98e23ec23df8129e8754220a371ed06a32ac0287
6
+ metadata.gz: 530bd5a53c304dbea6c620d331de5bdf5ca7bf37f46ec5c05e75b90ef46b294f2c9ae6128f2ecf001bf70676a597a4fabe684bcd8c8a3e278cd651b83a19e71e
7
+ data.tar.gz: 26b3c77195556e13c3de8ceada7322c9dd8bad3373903a17752e074f0d40319918e598a9a8784e1287d9a34d75f59dcd8a50305e1e1b7f80d29990f4838ed922
data/CHANGELOG.md CHANGED
@@ -8,6 +8,22 @@ All notable changes to this project are documented in this file.
8
8
 
9
9
  - Known issues, parked (local note `stuff/2026-10-31-dropdown-rule-3-parked.md`) with dropdown order rule 3: `includes`, `group` or `select` in `inline_forms_list` make `dropdown` and `dropdown_with_other` raise while `/index` works, so 8.1.65's fix for a list order on a joined table holds only for `joins`, `left_joins` and `eager_load`; a has_many join gives duplicate options. Present since 8.1.60. No host's list scope has these today. Parked; not changed.
10
10
 
11
+ ## [8.1.80] - 2026-11-24
12
+
13
+ From the notes of the apps' move to 8.1.79's suggestions.
14
+
15
+ ### Changed
16
+
17
+ - **`match: :word` also starts a word after a hyphen or an apostrophe** (`'` and `’`), not only after a space: "marc" finds Jean-Marc, "brien" O'Brien, "abreu" D’Abreu. Still not inside a word ("marc" does not find Lamarck). Apps that pin the old space-only behaviour in a spec (Scouting's `members_autocomplete_spec.rb`) see that spec fail on the upgrade, on purpose.
18
+
19
+ ### Added
20
+
21
+ - **`inline_forms_suggestion_request?`** (concern `SuggestionRequestConcern`), in `InlineFormsController` and in `InlineFormsApplicationController`, so a generated app's `ApplicationController` has it for every controller, and in views: true when the request is the search box's suggestions (`index` with `?suggest=1`), which answer JSON and are not a list view; false outside the inline_forms lists. For an app's own callbacks, e.g. statistics that count list views only: `skip_after_action :track_action, if: :inline_forms_suggestion_request?`.
22
+
23
+ ### Fixed
24
+
25
+ - **The generic search box has accessible names.** The form has `role="search"`, the field an `aria-label` (new key `inline_forms.search.label`: "search", "zoeken"; without it, the placeholder text), the reset link an `aria-label` as well as its `title`, and its `fi-x` icon `aria-hidden="true"`.
26
+
11
27
  ## [8.1.79] - 2026-11-23
12
28
 
13
29
  ### Added
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # `inline_forms_suggestion_request?`: true when this request is an
4
+ # inline_forms list's search-box suggestions (index with ?suggest=1&term=…,
5
+ # which answers a JSON array), not a list view. For an app's own callbacks,
6
+ # e.g. statistics that count list views only:
7
+ #
8
+ # skip_after_action :track_action, if: :inline_forms_suggestion_request?
9
+ #
10
+ # Included in InlineFormsController and in InlineFormsApplicationController,
11
+ # so an ApplicationController that inherits from the latter has it for every
12
+ # controller (false outside the inline_forms lists).
13
+ module SuggestionRequestConcern
14
+ extend ActiveSupport::Concern
15
+
16
+ included do
17
+ helper_method :inline_forms_suggestion_request?
18
+ end
19
+
20
+ protected
21
+
22
+ def inline_forms_suggestion_request?
23
+ is_a?(InlineFormsController) && action_name == "index" &&
24
+ params.key?(:suggest) && params[:parent_class].blank?
25
+ end
26
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  class InlineFormsApplicationController < ActionController::Base
4
4
  protect_from_forgery
5
+ include SuggestionRequestConcern
5
6
  # `layout 'devise' if :devise_controller?` was wrong: `:devise_controller?` is a
6
7
  # Symbol (always truthy), so every controller used the Devise layout. Use a
7
8
  # callable so only Devise controllers get `layouts/devise`; everything else
@@ -28,6 +28,7 @@ class InlineFormsController < ApplicationController
28
28
  include VersionsConcern
29
29
  include FileSlotsConcern
30
30
  include SuggestionsConcern
31
+ include SuggestionRequestConcern
31
32
 
32
33
  before_action :getKlass
33
34
 
@@ -1,15 +1,16 @@
1
- <%= form_tag request.path, method: :get do %>
1
+ <% search_label = t("inline_forms.search.label", default: t("inline_forms.search.placeholder")) %>
2
+ <%= form_tag request.path, method: :get, role: "search" do %>
2
3
  <div class="row collapse">
3
4
  <div class="large-1 small-1 columns">
4
- <%= link_to tag.i(class: "fi-x"), request.path, title: t("inline_forms.search.reset"), class: "button expanded inline_forms_model_top_bar_buttons" %>
5
+ <%= link_to tag.i(class: "fi-x", "aria-hidden": "true"), request.path, title: t("inline_forms.search.reset"), "aria-label": t("inline_forms.search.reset"), class: "button expanded inline_forms_model_top_bar_buttons" %>
5
6
  </div>
6
7
  <div class="large-6 small-6 columns">
7
8
  <%# With `inline_forms_search_on …, suggest: …` the list itself answers %>
8
9
  <%# the suggestions (index with ?suggest=1&term=…). %>
9
10
  <% if @Klass.respond_to?(:inline_forms_suggestions) && @Klass.inline_forms_suggestions %>
10
- <%= suggest_field_tag :search, params[:search], "#{request.path}?suggest=1", placeholder: t("inline_forms.search.placeholder"), id: "input_search", list: "input_search_suggestions" %>
11
+ <%= suggest_field_tag :search, params[:search], "#{request.path}?suggest=1", placeholder: t("inline_forms.search.placeholder"), "aria-label": search_label, id: "input_search", list: "input_search_suggestions" %>
11
12
  <% else %>
12
- <%= text_field_tag :search, params[:search], placeholder: t("inline_forms.search.placeholder"), id: "input_search" %>
13
+ <%= text_field_tag :search, params[:search], placeholder: t("inline_forms.search.placeholder"), "aria-label": search_label, id: "input_search" %>
13
14
  <% end %>
14
15
  </div>
15
16
  <div class="large-3 small-3 columns">
@@ -12,13 +12,17 @@ module InlineForms
12
12
  #
13
13
  # :contains anywhere in the value ("ma" finds Martina, Tinamart, Tima)
14
14
  # :start at the start of the value ("ma" finds Martina only)
15
- # :word at the start of any word ("ma" finds Martina, Anna Maria)
15
+ # :word at the start of any word ("ma" finds Martina, Anna Maria);
16
+ # a word starts after a space, a hyphen or an apostrophe
17
+ # ("marc" finds Jean-Marc, "brien" O'Brien and O’Brien)
16
18
  #
17
19
  # The answer: at most `limit` values, each once (compared stripped and in any
18
20
  # case, the first in A-Z order kept), in case-insensitive A-Z order. An empty
19
21
  # term gives [].
20
22
  module Suggestions
21
23
  MATCHES = %i[contains start word].freeze
24
+ # What starts a word for match: :word, besides the start of the value.
25
+ WORD_STARTS = [ " ", "-", "'", "’" ].freeze
22
26
  LIMIT = 12
23
27
 
24
28
  module_function
@@ -77,7 +81,7 @@ module InlineForms
77
81
  case match
78
82
  when :contains then [ "%#{escaped}%" ]
79
83
  when :start then [ "#{escaped}%" ]
80
- when :word then [ "#{escaped}%", "% #{escaped}%" ]
84
+ when :word then [ "#{escaped}%", *WORD_STARTS.map { |start| "%#{start}#{escaped}%" } ]
81
85
  end
82
86
  end
83
87
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module InlineForms
4
- VERSION = "8.1.79"
4
+ VERSION = "8.1.80"
5
5
  end
@@ -4,6 +4,7 @@ en:
4
4
  # models that declare inline_forms_search_on.
5
5
  search:
6
6
  placeholder: "search..."
7
+ label: search
7
8
  submit: search
8
9
  reset: reset
9
10
  # general.application_title, devise.title_for_devise and devise.welcome
@@ -4,6 +4,7 @@ nl:
4
4
  # models that declare inline_forms_search_on.
5
5
  search:
6
6
  placeholder: "zoeken..."
7
+ label: zoeken
7
8
  submit: zoek
8
9
  reset: wissen
9
10
  # general.application_title, devise.title_for_devise and devise.welcome
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.79
4
+ version: 8.1.80
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -113,6 +113,7 @@ files:
113
113
  - app/assets/stylesheets/inline_forms_fonts.css.erb
114
114
  - app/controllers/concerns/cancan_concern.rb
115
115
  - app/controllers/concerns/file_slots_concern.rb
116
+ - app/controllers/concerns/suggestion_request_concern.rb
116
117
  - app/controllers/concerns/suggestions_concern.rb
117
118
  - app/controllers/concerns/versions_concern.rb
118
119
  - app/controllers/inline_forms/file_trash_controller.rb