diff --git a/app/assets/javascripts/custom_form_builder.coffee b/app/assets/javascripts/custom_form_builder.coffee
index 60acc0a5f5..45d56bfa5a 100644
--- a/app/assets/javascripts/custom_form_builder.coffee
+++ b/app/assets/javascripts/custom_form_builder.coffee
@@ -12,12 +12,13 @@ class CIF.CustomFormBuilder
separateLine: (fieldData) ->
{ field: '
' }
- eventParagraphOption: ->
+ eventParagraphOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.subtype-wrap, .className-wrap, .access-wrap').hide()
self.handleCheckingForm()
self.preventClickEnterOrTab(fld)
+ self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
$('.subtype-wrap, .className-wrap, .access-wrap').hide()
self.handleCheckingForm()
@@ -130,12 +131,13 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50
- eventTextAreaOption: ->
+ eventTextAreaOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.rows-wrap, .subtype-wrap, .className-wrap, .value-wrap, .access-wrap, .maxlength-wrap, .description-wrap, .name-wrap').hide()
self.handleCheckingForm()
self.preventClickEnterOrTab(fld)
+ self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
@@ -270,6 +272,7 @@ class CIF.CustomFormBuilder
localLabel = "Local Label"
if fields[index - 1]
localLabel = if fields[index - 1][localLabelName] then fields[index - 1][localLabelName] else localLabel
- localLabelBlock = ""
+ frmHolder = fldElement.find('.frm-holder')
+ localLabelBlock = ""
localLabelBlockElement = $.parseHTML(localLabelBlock)
frmHolder.find('.label-wrap').after(localLabelBlockElement)
diff --git a/app/assets/javascripts/multiple_form/form.coffee b/app/assets/javascripts/multiple_form/form.coffee
index bbfd1fccbc..11aec2ce40 100644
--- a/app/assets/javascripts/multiple_form/form.coffee
+++ b/app/assets/javascripts/multiple_form/form.coffee
@@ -11,6 +11,8 @@ CIF.Client_trackingsNew = CIF.Client_trackingsCreate = CIF.Client_custom_fieldsN
_preventCreateDatePickerClientEnrollment()
_setAnotherLanguageFieldValue()
_hideAnotherLanguageField()
+ _copyInputTextToLocalLanguage()
+ _copyTextAreaTextToLocalLanguage()
_initICheckBox = ->
$('.i-checks').iCheck
@@ -52,6 +54,16 @@ CIF.Client_trackingsNew = CIF.Client_trackingsCreate = CIF.Client_custom_fieldsN
_hideAnotherLanguageField = ->
$('.client-enrollment').find('.d-none').parent().addClass('hide')
+ _copyInputTextToLocalLanguage = ->
+ $('input[type="text"]').on 'keyup', (e) ->
+ el = $(@)
+ el.parent().next().find('#' + el.data('local-input')).val(el.val())
+
+ _copyTextAreaTextToLocalLanguage = ->
+ $('textarea').on 'keyup', (e) ->
+ el = $(@)
+ el.parent().next().find('#' + el.data('local-textarea')).val(el.val())
+
_preventRequireFields = ->
preventFileUploader()
preventRequireFieldInput()
diff --git a/app/assets/javascripts/program_streams/form.coffee b/app/assets/javascripts/program_streams/form.coffee
index 0a311d54db..c196782070 100644
--- a/app/assets/javascripts/program_streams/form.coffee
+++ b/app/assets/javascripts/program_streams/form.coffee
@@ -292,10 +292,10 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
number: builderOption.eventNumberOption()
'radio-group': builderOption.eventRadioOption()
select: builderOption.eventSelectOption(fields)
- text: builderOption.eventTextFieldOption()
- textarea: builderOption.eventTextAreaOption()
+ text: builderOption.eventTextFieldOption(fields)
+ textarea: builderOption.eventTextAreaOption(fields)
separateLine: builderOption.eventSeparateLineOption()
- paragraph: builderOption.eventParagraphOption()
+ paragraph: builderOption.eventParagraphOption(fields)
}
onAddOption: (optionTemplate, optionIndex) ->
index = optionIndex.index + 1
diff --git a/app/views/client_enrolled_programs/show.haml b/app/views/client_enrolled_programs/show.haml
index 93b0264a7a..aa7246abce 100644
--- a/app/views/client_enrolled_programs/show.haml
+++ b/app/views/client_enrolled_programs/show.haml
@@ -17,15 +17,15 @@
.table-responsive
%table.table.table-bordered
- @program_stream.enrollment.map{|properties| [properties['type'], properties['label'], properties["local_label"]]}.each do |type, key, translated_key|
+ - label = I18n.locale.to_s === I18n.default_locale.to_s ? key.html_safe : translated_key.html_safe
- unless type == 'separateLine'
- if type == 'paragraph'
%tr
%td.align-justify{colspan: '2'}
- = key.html_safe
+ = label
- else
%tr
%td.align-justify
- - label = I18n.locale.to_s === I18n.default_locale.to_s ? key.html_safe : translated_key
= label
%td.align-justify
- key = convert_bracket(label, @client_enrollment.properties)
diff --git a/app/views/shared/fields/_paragraph.haml b/app/views/shared/fields/_paragraph.haml
index 34224f083a..4d9362ea62 100644
--- a/app/views/shared/fields/_paragraph.haml
+++ b/app/views/shared/fields/_paragraph.haml
@@ -1 +1,2 @@
-%p= field_props['label'].html_safe
+- label = field_label(field_props)
+%p= label.html_safe
diff --git a/app/views/shared/fields/_text.haml b/app/views/shared/fields/_text.haml
index 101e23ee5b..c06543d826 100644
--- a/app/views/shared/fields/_text.haml
+++ b/app/views/shared/fields/_text.haml
@@ -1,7 +1,9 @@
+- label = field_label(field_props)
%div{ class: "form-group #{field_with(field_props['label'],errors)}" }
%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'], required: (field_props['required'] || false), input_html: { class: field_props['className'], placeholder: format_placeholder(field_props['placeholder']), title: field_props['description'], name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", type: field_props['subtype'] , id: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize}, label: false
+ = label.html_safe
+ = f.input field_props['label'], required: (field_props['required'] || false), input_html: { class: field_props['className'], placeholder: format_placeholder(field_props['placeholder']), title: field_props['description'], name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", type: field_props['subtype'] , id: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize, 'data-local-input': "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }, label: false
+ = 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 }
%span.help-block
= field_message(field_props['label'], errors)
diff --git a/app/views/shared/fields/_textarea.haml b/app/views/shared/fields/_textarea.haml
index c380a038f1..59371541af 100644
--- a/app/views/shared/fields/_textarea.haml
+++ b/app/views/shared/fields/_textarea.haml
@@ -1,7 +1,9 @@
+- label = field_label(field_props)
%div{ class: "form-group #{field_with(field_props['label'],errors)}" }
%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: :text, required: (field_props['required'] || false), input_html: { class: field_props['className'], placeholder: format_placeholder(field_props['placeholder']), name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]" }, label: false
+ = label.html_safe
+ = f.input field_props['label'], as: :text, required: (field_props['required'] || false), input_html: { class: field_props['className'], placeholder: format_placeholder(field_props['placeholder']), name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", 'data-local-textarea': "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }, label: false
+ = 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 }
%span.help-block
= field_message(field_props['label'], errors)