Skip to content

Commit

Permalink
[FEATURE] Translate Radio group field
Browse files Browse the repository at this point in the history
refs OSC-17
  • Loading branch information
Bunhok committed Sep 22, 2022
1 parent 8b0ed4a commit 8fe0ae4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/custom_form_builder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50

eventRadioOption: ->
eventRadioOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.other-wrap, .inline-wrap, .className-wrap, .access-wrap, .description-wrap, .name-wrap').hide()
Expand All @@ -89,6 +89,7 @@ class CIF.CustomFormBuilder
self.addOptionCallback(fld)
self.generateValueForSelectOption(fld)
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/multiple_form/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CIF.Client_trackingsNew = CIF.Client_trackingsCreate = CIF.Client_custom_fieldsN

_toggleCheckingRadioButton = ->
$('input[type="radio"]').on 'ifChecked', (e) ->
el = $(@)
el.parents('.radio_buttons').next().children('#' + el.data('option')).val(el.data('value'))
$(@).parents('span.radio').siblings('.radio').find('.iradio_square-green').removeClass('checked')

_initSelect2 = ->
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/program_streams/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
date: builderOption.eventDateOption(fields)
file: builderOption.eventFileOption()
number: builderOption.eventNumberOption(fields)
'radio-group': builderOption.eventRadioOption()
'radio-group': builderOption.eventRadioOption(fields)
select: builderOption.eventSelectOption(fields)
text: builderOption.eventTextFieldOption(fields)
textarea: builderOption.eventTextAreaOption(fields)
Expand Down
11 changes: 9 additions & 2 deletions app/views/shared/fields/_radio_group.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
- label = field_label(field_props)
%div{ class: "i-checks form-group #{field_with(field_props['label'],errors)} #{required?(field_props['required'] || false)}" }
%label.control-label{ class: required?(field_props['required'] || false) }
%abbr{ title: 'required' }= '*' if field_props['required'] || false
= field_props['label'].html_safe
= f.input field_props['label'], as: :radio_buttons, collection: field_props['values'].map { |f| [format_placeholder(f['label']), f['label'], id: "custom_field_property_properties_#{field_props['label'].gsub('"', '&qoute;').html_safe}_#{f['label'].html_safe}"] }, label: false, input_html: { title: field_props['description'], name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]" }
= label.html_safe
- if I18n.locale.to_s == I18n.default_locale.to_s
= f.input field_props['label'].gsub(' ', '_'), as: :radio_buttons, collection: field_props['values'].map { |f| [format_placeholder(f['label']), f['label'], id: "custom_field_property_properties_#{field_props['label'].gsub('"', '&qoute;').html_safe}_#{f['label'].html_safe}", 'data-value': f['local_label']] }, label: false, input_html: { id: field_props['label'].gsub(' ', '_').gsub("'", ""), title: field_props['description'], name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", class: "#{I18n.locale.to_s != I18n.default_locale.to_s ? 'd-none1' : ''}", 'data-option': "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }
= f.input field_props['local_label'], :as => :hidden, input_html: { name: "#{f.object_name}[Local_label #{remove_local_field_prop_unicode(field_props)}]", id: "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }
- else
= f.input field_props['local_label'].gsub(' ', '_'), as: :radio_buttons, collection: field_props['values'].map { |f| [format_placeholder(f['local_label']), f['local_label'], id: "custom_field_property_properties_#{field_props['local_label'].gsub('"', '&qoute;').html_safe}_#{f['local_label'].html_safe}", 'data-value': f['label']] }, label: false, input_html: { id: field_props['local_label'].gsub(' ', '_').gsub("'", ""), title: field_props['description'], name: "#{f.object_name}[Local_label #{remove_local_field_prop_unicode(field_props)}]", class: "#{I18n.locale.to_s == I18n.default_locale.to_s ? 'd-none1' : ''}", 'data-option': "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize }
= f.input field_props['label'], :as => :hidden, input_html: { name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", id: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize }

%span.help-block
= field_message(field_props['label'], errors)

0 comments on commit 8fe0ae4

Please sign in to comment.