Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/resource_registry/helpers/view_controls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def input_import_control(setting, _form)
tag.span('Upload', class: "input-group-text", id: id)
end +
tag.div(class: "custom-file") do
tag.input(nil, type: "file", id: id, name: id + "[value]", class: "custom-file-input", aria: { describedby: aria_describedby }) +
tag.input(type: "file", id: id, name: id + "[value]", class: "custom-file-input", aria: { describedby: aria_describedby }) +
tag.label('Choose File', for: id, value: label, class: "custom-file-label")
end
end
Expand All @@ -90,8 +90,8 @@ def input_radio_control(setting, form)
meta.enum.collect do |choice|
choice = send(choice) if choice.is_a?(String)
input_group do
tag.div(tag.div(tag.input(nil, type: "radio", name: element_name, value: choice.first[0], checked: input_value.to_s == choice.first[0].to_s, required: true), class: "input-group-text"), class: "input-group-prepend") +
tag.input(nil, type: "text", placeholder: choice.first[1], class: "form-control", aria: {label: aria_label })
tag.div(tag.div(tag.input(type: "radio", name: element_name, value: choice.first[0], checked: input_value.to_s == choice.first[0].to_s, required: true), class: "input-group-text"), class: "input-group-prepend") +
tag.input(type: "text", placeholder: choice.first[1], class: "form-control", aria: {label: aria_label })
end
end.join('').html_safe
end
Expand All @@ -104,8 +104,8 @@ def input_checkbox_control(setting, form)
choice = send(choice) if choice.is_a?(String)
val = choice.first[0]
input_group do
tag.div(tag.div(tag.input(nil, type: 'checkbox', name: "#{input_name_for(setting, form)}[]", value: val, checked: input_value.include?(val.to_s), required: false), class: 'input-group-text'), class: 'input-group-prepend') +
tag.input(nil, type: 'text', placeholder: choice.first[1], class: 'form-control', aria: {label: aria_label })
tag.div(tag.div(tag.input(type: 'checkbox', name: "#{input_name_for(setting, form)}[]", value: val, checked: input_value.include?(val.to_s), required: false), class: 'input-group-text'), class: 'input-group-prepend') +
tag.input(type: 'text', placeholder: choice.first[1], class: 'form-control', aria: {label: aria_label })
end
end.join('').html_safe
end
Expand All @@ -128,7 +128,7 @@ def input_file_control(setting, form)
tag.span('Upload', class: "input-group-text", id: id)
end +
tag.div(class: "custom-file") do
tag.input(nil, type: "file", id: id, name: form&.object_name.to_s + "[#{setting.key}]", class: "custom-file-input", aria: { describedby: aria_describedby }) +
tag.input(type: "file", id: id, name: form&.object_name.to_s + "[#{setting.key}]", class: "custom-file-input", aria: { describedby: aria_describedby }) +
tag.label('Choose File', for: id, value: label, class: "custom-file-label")
end

Expand Down Expand Up @@ -176,9 +176,9 @@ def input_text_control(setting, form)
is_required = meta&.is_required == false ? meta.is_required : true
placeholder = "Enter #{meta[:label]}".gsub('*', '') if meta[:description].blank?
# if meta[:attribute]
# tag.input(nil, type: "text", value: input_value, id: id, name: form&.object_name.to_s + "[#{id}]",class: "form-control", required: true)
# tag.input(type: "text", value: input_value, id: id, name: form&.object_name.to_s + "[#{id}]",class: "form-control", required: true)
# else
tag.input(nil, type: "text", value: input_value, id: id, name: input_name_for(setting, form), placeholder: placeholder, class: "form-control", required: is_required)
tag.input(type: "text", value: input_value, id: id, name: input_name_for(setting, form), placeholder: placeholder, class: "form-control", required: is_required)
# end
end

Expand All @@ -195,7 +195,7 @@ def input_date_control(setting, form)

is_required = meta&.is_required == false ? meta.is_required : true

tag.input(nil, type: "date", value: input_value, id: id, name: input_name_for(setting, form), placeholder: "mm/dd/yyyy", class: "form-control", required: is_required)
tag.input(type: "date", value: input_value, id: id, name: input_name_for(setting, form), placeholder: "mm/dd/yyyy", class: "form-control", required: is_required)
end

def input_number_control(setting, form)
Expand All @@ -207,9 +207,9 @@ def input_number_control(setting, form)
placeholder = "Enter #{meta[:label]}".gsub('*', '') if meta[:description].blank?

# if setting[:attribute]
tag.input(nil, type: "number", step: "any", value: input_value, id: id, name: input_name_for(setting, form), placeholder: placeholder, class: "form-control", required: true, oninput: "check(this)")
tag.input(type: "number", step: "any", value: input_value, id: id, name: input_name_for(setting, form), placeholder: placeholder, class: "form-control", required: true, oninput: "check(this)")
# else
# tag.input(nil, type: "number", step:"any", value: input_value, id: id, name: form&.object_name.to_s + "[value]",class: "form-control", required: true, oninput: "check(this)")
# tag.input(type: "number", step:"any", value: input_value, id: id, name: form&.object_name.to_s + "[value]",class: "form-control", required: true, oninput: "check(this)")
# end
end

Expand All @@ -221,17 +221,17 @@ def input_email_control(setting, form)
# aria_describedby = id

# if setting[:attribute]
tag.input(nil, type: "email", step: "any", value: input_value, id: id, name: input_name_for(setting, form), class: "form-control", required: true, oninput: "check(this)")
tag.input(type: "email", step: "any", value: input_value, id: id, name: input_name_for(setting, form), class: "form-control", required: true, oninput: "check(this)")
# else
# tag.input(nil, type: "email", step:"any", value: input_value, id: id, name: form&.object_name.to_s + "[value]",class: "form-control", required: true, oninput: "check(this)")
# tag.input(type: "email", step:"any", value: input_value, id: id, name: form&.object_name.to_s + "[value]",class: "form-control", required: true, oninput: "check(this)")
# end
end

def input_color_control(setting)
id = setting[:key].to_s
input_value = setting[:value] || setting[:default]

tag.input(nil, type: "color", value: input_value, id: id)
tag.input(type: "color", value: input_value, id: id)
end

def input_swatch_control(setting, form)
Expand All @@ -241,7 +241,7 @@ def input_swatch_control(setting, form)
meta = setting[:meta]
color = meta.value || meta.default

tag.input(nil, type: "text", value: color, id: id, name: form&.object_name.to_s + "[value]", class: "js-color-swatch form-control") +
tag.input(type: "text", value: color, id: id, name: form&.object_name.to_s + "[value]", class: "js-color-swatch form-control") +
tag.div(tag.button(type: "button", id: id, class: "btn", value: "", style: "background-color: #{color}"), class: "input-group-append")
end

Expand All @@ -255,7 +255,7 @@ def input_currency_control(setting, form)
aria_map = { label: "Amount (to the nearest dollar)"}

tag.div(tag.span('$', class: "input-group-text"), class: "input-group-prepend") +
tag.input(nil, type: "text", value: input_value, id: id, name: input_name_for(setting, form), class: "form-control", aria: { map: aria_map }) +
tag.input(type: "text", value: input_value, id: id, name: input_name_for(setting, form), class: "form-control", aria: { map: aria_map }) +
tag.div(tag.span('.00', class: "input-group-text"), class: "input-group-append")
end

Expand Down
Loading