diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /lib/gitlab/form_builders | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'lib/gitlab/form_builders')
-rw-r--r-- | lib/gitlab/form_builders/gitlab_ui_form_builder.rb | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/lib/gitlab/form_builders/gitlab_ui_form_builder.rb b/lib/gitlab/form_builders/gitlab_ui_form_builder.rb index a5290508e42..3f9053d4e0c 100644 --- a/lib/gitlab/form_builders/gitlab_ui_form_builder.rb +++ b/lib/gitlab/form_builders/gitlab_ui_form_builder.rb @@ -22,29 +22,53 @@ module Gitlab format_options(checkbox_options, ['custom-control-input']), checked_value, unchecked_value - ) + - @template.label( - @object_name, method, format_options(label_options, ['custom-control-label']) - ) do - if help_text - @template.content_tag( - :span, - label - ) + - @template.content_tag( - :p, - help_text, - class: 'help-text' - ) - else - label - end - end + ) + generic_label(method, label, label_options, help_text: help_text) + end + end + + def gitlab_ui_radio_component( + method, + value, + label, + help_text: nil, + radio_options: {}, + label_options: {} + ) + @template.content_tag( + :div, + class: 'gl-form-radio custom-control custom-radio' + ) do + @template.radio_button( + @object_name, + method, + value, + format_options(radio_options, ['custom-control-input']) + ) + generic_label(method, label, label_options, help_text: help_text, value: value) end end private + def generic_label(method, label, label_options, help_text: nil, value: nil) + @template.label( + @object_name, method, format_options(label_options.merge({ value: value }), ['custom-control-label']) + ) do + if help_text + @template.content_tag( + :span, + label + ) + + @template.content_tag( + :p, + help_text, + class: 'help-text' + ) + else + label + end + end + end + def format_options(options, classes) classes << options[:class] |