glib-web 6.3.1 → 6.3.2

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: 8378cb302a462be1ed8ee965c9ace54b77c4eb29f7d1cc9d83a469c89d0f6d93
4
- data.tar.gz: 91f29270361f13067e3bc513cd01091e82b09d7a89a40eadb4dab893b59f7a66
3
+ metadata.gz: 4f55e891cbc4a9325dbf8fe235dcb593982686ec8e36f62d86b6aea853e83f22
4
+ data.tar.gz: 6299bcaf264a60d4a604dc6dc7f44f45f2671f2827b8a6fe26f266979d82dbf5
5
5
  SHA512:
6
- metadata.gz: 62c1600d052a52e8fb020662ca4db7455518945e298c6e5ea5663e4960955d9d29129252b0780107b138bd4d585a4463f4bef253dc26460203acee362b083af8
7
- data.tar.gz: 4d816f8451f71efbbb96fbcbe64fe1586211b3e328c42ec89580d711abe9f5d62033ff645f1622b855fa31e86eee5a383ed2ff6732d0a817ba6462bea6e23821
6
+ metadata.gz: 368a1c82a9ee9f539b38d4e3396b0fa14cf449fef03d50862239b549d3d9593a19b8961f41e521d8a627bf58530b63b5ac6f1a89310bebe1d0b5a5e61d811361
7
+ data.tar.gz: b8fe1cd9c3256ad9d3d7ea1cafb5adef1ec80e984ec7678edfd5e6aaec585babdc96aaddcef189003269ab9a33b89b00aae5fe5ac1c4988458de0ec3fa33fec4
@@ -0,0 +1,73 @@
1
+ module Glib
2
+ module FormStepper
3
+ # A session-backed multi-step wizard: per-step answers accumulate in the
4
+ # session and nothing is persisted until the final step commits. Fits
5
+ # pre-account flows and any wizard where an abandoned run should simply
6
+ # disappear.
7
+ #
8
+ # The including controller declares the flow and its session bucket:
9
+ #
10
+ # class ApplyController < ApplicationController
11
+ # include Glib::FormStepper::Controller
12
+ #
13
+ # STEPS = [
14
+ # Glib::FormStepper::Step.new(key: :program, title: "Program", position: 1),
15
+ # Glib::FormStepper::Step.new(key: :auditor, title: "Auditor", position: 2)
16
+ # ].freeze
17
+ # SESSION_KEY = "apply_application".freeze
18
+ # end
19
+ #
20
+ # The current step is resolved from `params[:id]`, defaulting to the first step.
21
+ module Controller
22
+ extend ActiveSupport::Concern
23
+
24
+ included do
25
+ helper_method :current_step, :next_step, :prev_step, :step_data, :steps
26
+ end
27
+
28
+ def steps
29
+ self.class::STEPS
30
+ end
31
+
32
+ def current_step
33
+ @current_step ||= find_step(params[:id] || steps.first.key)
34
+ end
35
+
36
+ def next_step
37
+ idx = steps.index(current_step)
38
+ idx && steps[idx + 1]
39
+ end
40
+
41
+ def prev_step
42
+ idx = steps.index(current_step)
43
+ idx&.positive? ? steps[idx - 1] : nil
44
+ end
45
+
46
+ # Every answer gathered so far, one hash per step key.
47
+ def session_data
48
+ session[self.class::SESSION_KEY] ||= {}
49
+ end
50
+
51
+ # The current step's answers — what its form reads to prefill itself.
52
+ def step_data
53
+ session_data[current_step.key.to_s] || {}
54
+ end
55
+
56
+ # Merge (not replace) so re-submitting a step updates rather than clobbers.
57
+ def save_step_data(data)
58
+ key = current_step.key.to_s
59
+ session_data[key] = (session_data[key] || {}).merge(data)
60
+ end
61
+
62
+ def clear_session_data
63
+ session.delete(self.class::SESSION_KEY)
64
+ end
65
+
66
+ private
67
+ def find_step(key)
68
+ steps.find { |step| step.key == key.to_sym } ||
69
+ raise(ArgumentError, "Unknown step: #{key}")
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,12 @@
1
+ module Glib
2
+ module FormStepper
3
+ # One step in a session-backed wizard: just its identity and label. `key` is
4
+ # coerced to a symbol so a step declared with either a symbol or string, and a
5
+ # `params[:id]` that always arrives as a string, resolve to the same step.
6
+ Step = Data.define(:key, :title, :position) do
7
+ def initialize(key:, title:, position:)
8
+ super(key: key.to_sym, title: title, position: position)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'countries' # ISO 3166 data (ISO3166::Country)
2
+
3
+ module Glib
4
+ # ISO 3166 country data for country dropdowns.
5
+ #
6
+ # Backed entirely by the `countries` gem, so there is no table to migrate or
7
+ # seed, and renames (Türkiye, Czechia) arrive with a `bundle update`. Store
8
+ # the alpha-2 code rather than the name, so a rename never invalidates
9
+ # existing data.
10
+ module CountryList
11
+ class << self
12
+ # `common_name` is what people actually call the place ("South Korea",
13
+ # "United Kingdom") rather than the formal ISO name ("Korea (Republic of)").
14
+ def options
15
+ @options ||= ISO3166::Country.all
16
+ .map { |country| { value: country.alpha2, text: country.common_name || country.iso_short_name } }
17
+ .sort_by { |option| option[:text] }
18
+ .freeze
19
+ end
20
+
21
+ def codes
22
+ @codes ||= options.pluck(:value).freeze
23
+ end
24
+
25
+ def name_for(code)
26
+ return if code.blank?
27
+
28
+ country = ISO3166::Country[code]
29
+ country && (country.common_name || country.iso_short_name)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ require 'countries' # ISO 3166-2 subdivision data (ISO3166::Country)
2
+
3
+ module Glib
4
+ # ISO 3166-2 subdivision (state/province/territory) data for state dropdowns.
5
+ #
6
+ # The companion to Glib::CountryList: backed entirely by the `countries` gem,
7
+ # so there is no table to migrate or seed, and renames arrive with a
8
+ # `bundle update`. Store the subdivision code (e.g. "NSW") rather than the
9
+ # name, so a rename never invalidates existing data. The code is only unique
10
+ # within a country, so always store it alongside the country code.
11
+ #
12
+ # Not every country has subdivisions in the ISO data (e.g. Vatican City); for
13
+ # those `options_for` returns `[]` and the UI should fall back to a plain text
14
+ # field or omit the state input entirely.
15
+ module StateList
16
+ class << self
17
+ # Options for a single country's state dropdown, sorted by display name.
18
+ # `country_code` is an alpha-2 code, matching what Glib::CountryList stores.
19
+ def options_for(country_code)
20
+ return [] if country_code.blank?
21
+
22
+ (@options_by_country ||= {})[country_code.to_s.upcase] ||= build_options(country_code)
23
+ end
24
+
25
+ def codes_for(country_code)
26
+ options_for(country_code).pluck(:value)
27
+ end
28
+
29
+ def name_for(country_code, state_code)
30
+ return if country_code.blank? || state_code.blank?
31
+
32
+ country = ISO3166::Country[country_code]
33
+ subdivision = country&.subdivisions&.dig(state_code.to_s.upcase)
34
+ subdivision&.name
35
+ end
36
+
37
+ private
38
+ def build_options(country_code)
39
+ country = ISO3166::Country[country_code]
40
+ return [] if country.nil?
41
+
42
+ country.subdivisions
43
+ .map { |code, subdivision| { value: code, text: subdivision.name } }
44
+ .sort_by { |option| option[:text] }
45
+ .freeze
46
+ end
47
+ end
48
+ end
49
+ end
@@ -24,7 +24,11 @@ markdown = '## Emphasis' + "\n" +
24
24
  It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
25
25
  It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
26
26
  and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
27
- "
27
+ ".gsub("\n", " \n")
28
+ # The gsub turns each bare newline into a markdown hard break: the renderer
29
+ # uses standard (breaks: false) semantics, under which these hand-wrapped
30
+ # lines would otherwise reflow into one block — and this dialog exists to
31
+ # demonstrate scrolling, so it needs its ~20 visible lines.
28
32
 
29
33
 
30
34
  options = {}
@@ -367,5 +367,8 @@ page.body childViews: ->(body) do
367
367
  # end
368
368
  # )
369
369
  # end
370
+ #
371
+
372
+ res.button text: 'windows/reload', onClick: ->(action) { action.windows_reload }
370
373
  end
371
374
  end
data/lib/glib-web.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'ostruct'
2
+
1
3
  if defined?(::Rails)
2
4
  require 'glib/engine'
3
5
  require 'glib/snapshot'
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.1
4
+ version: 6.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
10
  date: 2026-07-24 00:00:00.000000000 Z
@@ -122,6 +121,34 @@ dependencies:
122
121
  - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: ostruct
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ - !ruby/object:Gem::Dependency
139
+ name: countries
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '7.1'
145
+ type: :runtime
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '7.1'
125
152
  - !ruby/object:Gem::Dependency
126
153
  name: rubocop
127
154
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +177,6 @@ dependencies:
150
177
  - - ">="
151
178
  - !ruby/object:Gem::Version
152
179
  version: '0'
153
- description:
154
180
  email: ''
155
181
  executables: []
156
182
  extensions: []
@@ -163,6 +189,8 @@ files:
163
189
  - app/controllers/concerns/glib/analytics/funnel.rb
164
190
  - app/controllers/concerns/glib/auth/policy.rb
165
191
  - app/controllers/concerns/glib/auth/response.rb
192
+ - app/controllers/concerns/glib/form_stepper/controller.rb
193
+ - app/controllers/concerns/glib/form_stepper/step.rb
166
194
  - app/controllers/concerns/glib/json/dynamic_text.rb
167
195
  - app/controllers/concerns/glib/json/libs.rb
168
196
  - app/controllers/concerns/glib/json/new_dynamic_text.rb
@@ -228,8 +256,10 @@ files:
228
256
  - app/models/glib/active_storage/attachment.rb
229
257
  - app/models/glib/active_storage/blob.rb
230
258
  - app/models/glib/application_record.rb
259
+ - app/models/glib/country_list.rb
231
260
  - app/models/glib/dummy_job_application.rb
232
261
  - app/models/glib/dynamic_text_record.rb
262
+ - app/models/glib/state_list.rb
233
263
  - app/models/glib/text.rb
234
264
  - app/policies/glib/application_policy.rb
235
265
  - app/validators/email_typo_validator.rb
@@ -541,10 +571,8 @@ files:
541
571
  - lib/glib/time_returning_mailer.rb
542
572
  - lib/glib/value.rb
543
573
  - lib/tasks/db.rake
544
- homepage:
545
574
  licenses: []
546
575
  metadata: {}
547
- post_install_message:
548
576
  rdoc_options: []
549
577
  require_paths:
550
578
  - lib
@@ -559,8 +587,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
559
587
  - !ruby/object:Gem::Version
560
588
  version: '0'
561
589
  requirements: []
562
- rubygems_version: 3.4.6
563
- signing_key:
590
+ rubygems_version: 4.0.6
564
591
  specification_version: 4
565
592
  summary: ''
566
593
  test_files: []