debian-mirror-gitlab/lib/gitlab/form_builders/gitlab_ui_form_builder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.9 KiB
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Gitlab
module FormBuilders
class GitlabUiFormBuilder < ActionView::Helpers::FormBuilder
2022-08-27 11:52:29 +05:30
def submit(value = nil, options = {})
if options[:pajamas_button]
@template.render Pajamas::ButtonComponent.new(
variant: :confirm,
type: :submit,
button_options: options.except(:pajamas_button)
) do
value
end
else
super
end
end
2021-10-27 15:23:28 +05:30
def gitlab_ui_checkbox_component(
method,
2022-07-23 23:45:48 +05:30
label = nil,
2021-10-27 15:23:28 +05:30
help_text: nil,
checkbox_options: {},
checked_value: '1',
unchecked_value: '0',
2022-07-23 23:45:48 +05:30
label_options: {},
&block
2021-10-27 15:23:28 +05:30
)
2022-07-23 23:45:48 +05:30
Pajamas::CheckboxComponent.new(
form: self,
method: method,
label: label,
help_text: help_text,
checkbox_options: format_options(checkbox_options),
checked_value: checked_value,
unchecked_value: unchecked_value,
label_options: format_options(label_options)
).render_in(@template, &block)
2021-11-18 22:05:49 +05:30
end
def gitlab_ui_radio_component(
method,
value,
2022-07-23 23:45:48 +05:30
label = nil,
2021-11-18 22:05:49 +05:30
help_text: nil,
radio_options: {},
2022-07-23 23:45:48 +05:30
label_options: {},
&block
2021-11-18 22:05:49 +05:30
)
2022-07-23 23:45:48 +05:30
Pajamas::RadioComponent.new(
form: self,
method: method,
value: value,
label: label,
help_text: help_text,
radio_options: format_options(radio_options),
label_options: format_options(label_options)
).render_in(@template, &block)
2021-10-27 15:23:28 +05:30
end
2022-08-27 11:52:29 +05:30
def gitlab_ui_datepicker(method, options = {})
@template.text_field @object_name, method, options.merge(class: "datepicker form-control gl-form-input")
end
2021-10-27 15:23:28 +05:30
private
2022-07-23 23:45:48 +05:30
def format_options(options)
objectify_options(options)
2021-10-27 15:23:28 +05:30
end
end
end
end