debian-mirror-gitlab/app/views/shared/_field.html.haml

30 lines
1.4 KiB
Text
Raw Normal View History

2015-09-11 14:41:01 +05:30
- name = field[:name]
- title = field[:title] || name.humanize
- value = @service.send(name)
- type = field[:type]
- placeholder = field[:placeholder]
2017-09-10 17:25:29 +05:30
- required = field[:required]
2015-09-11 14:41:01 +05:30
- choices = field[:choices]
- default_choice = field[:default_choice]
- help = field[:help]
2018-03-17 18:26:18 +05:30
- disabled = disable_fields_service?(@service)
2015-09-11 14:41:01 +05:30
2018-11-08 19:23:39 +05:30
.form-group.row
2015-10-24 18:46:33 +05:30
- if type == "password" && value.present?
2018-11-08 19:23:39 +05:30
= form.label name, "Enter new #{title.downcase}", class: "col-form-label col-sm-2"
2015-10-24 18:46:33 +05:30
- else
2018-11-08 19:23:39 +05:30
= form.label name, title, class: "col-form-label col-sm-2"
2015-09-11 14:41:01 +05:30
.col-sm-10
- if type == 'text'
2019-12-26 22:10:19 +05:30
= form.text_field name, class: "form-control", placeholder: placeholder, required: required, disabled: disabled, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" }
2015-09-11 14:41:01 +05:30
- elsif type == 'textarea'
2018-03-17 18:26:18 +05:30
= form.text_area name, rows: 5, class: "form-control", placeholder: placeholder, required: required, disabled: disabled
2015-09-11 14:41:01 +05:30
- elsif type == 'checkbox'
2018-03-17 18:26:18 +05:30
= form.check_box name, disabled: disabled
2015-09-11 14:41:01 +05:30
- elsif type == 'select'
2018-03-17 18:26:18 +05:30
= form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control", disabled: disabled}
2015-09-11 14:41:01 +05:30
- elsif type == 'password'
2019-12-26 22:10:19 +05:30
= form.password_field name, autocomplete: "new-password", placeholder: placeholder, class: "form-control", required: value.blank? && required, disabled: disabled, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" }
2015-09-11 14:41:01 +05:30
- if help
2018-11-08 19:23:39 +05:30
%span.form-text.text-muted= help