about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-12 10:09:27 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-12 11:30:35 +0100
commit6a96b17a2de3fe6d7e24014d1dcc1ad5f54050d8 (patch)
treea66ac6f6eb5440e235ddef670e8c42052657db18 /config/initializers
parentc813df2ebb0483236d95797d1bb840b48b95d290 (diff)
Add “Glitch-only” label to glitch-specific settings
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/simple_form.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index 92cffc5a2..d167a1600 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -19,8 +19,17 @@ module RecommendedComponent
   end
 end
 
+module GlitchOnlyComponent
+  def glitch_only(_wrapper_options = nil)
+    return unless options[:glitch_only]
+    options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t('simple_form.glitch_only'), class: 'glitch_only')]) }
+    nil
+  end
+end
+
 SimpleForm.include_component(AppendComponent)
 SimpleForm.include_component(RecommendedComponent)
+SimpleForm.include_component(GlitchOnlyComponent)
 
 SimpleForm.setup do |config|
   # Wrappers are used by the form builder to generate a
@@ -78,6 +87,7 @@ SimpleForm.setup do |config|
 
     b.wrapper tag: :div, class: :label_input do |ba|
       ba.optional :recommended
+      ba.optional :glitch_only
       ba.use :label
 
       ba.wrapper tag: :div, class: :label_input__wrapper do |bb|