From 8fe0ae4d04c0cbe407a0a9305d7a2982be082f5b Mon Sep 17 00:00:00 2001 From: bunhok Date: Wed, 21 Sep 2022 17:30:35 +0700 Subject: [PATCH] [FEATURE] Translate Radio group field refs OSC-17 --- app/assets/javascripts/custom_form_builder.coffee | 3 ++- app/assets/javascripts/multiple_form/form.coffee | 2 ++ app/assets/javascripts/program_streams/form.coffee | 2 +- app/views/shared/fields/_radio_group.haml | 11 +++++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/custom_form_builder.coffee b/app/assets/javascripts/custom_form_builder.coffee index a5ebc4db03..53f4bc1ada 100644 --- a/app/assets/javascripts/custom_form_builder.coffee +++ b/app/assets/javascripts/custom_form_builder.coffee @@ -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() @@ -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() diff --git a/app/assets/javascripts/multiple_form/form.coffee b/app/assets/javascripts/multiple_form/form.coffee index cbb2c36323..36663d19e1 100644 --- a/app/assets/javascripts/multiple_form/form.coffee +++ b/app/assets/javascripts/multiple_form/form.coffee @@ -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 = -> diff --git a/app/assets/javascripts/program_streams/form.coffee b/app/assets/javascripts/program_streams/form.coffee index d48f1460ff..349b3c6991 100644 --- a/app/assets/javascripts/program_streams/form.coffee +++ b/app/assets/javascripts/program_streams/form.coffee @@ -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) diff --git a/app/views/shared/fields/_radio_group.haml b/app/views/shared/fields/_radio_group.haml index 5b9dfb0ffd..84810a70ac 100644 --- a/app/views/shared/fields/_radio_group.haml +++ b/app/views/shared/fields/_radio_group.haml @@ -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)