Skip to content

Commit

Permalink
[FEATURE] Translate Date & Number field
Browse files Browse the repository at this point in the history
refs OSC-17
  • Loading branch information
Bunhok committed Sep 21, 2022
1 parent 474361c commit 8b0ed4a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
6 changes: 4 additions & 2 deletions app/assets/javascripts/custom_form_builder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50

eventDateOption: ->
eventDateOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.date-field').find('.className-wrap, .placeholder-wrap, .value-wrap, .access-wrap, .description-wrap, .name-wrap, .toggle-wrap, .inline-wrap').hide()
self.handleCheckingForm()
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand All @@ -66,12 +67,13 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50

eventNumberOption: ->
eventNumberOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.number-field').find('.className-wrap, .placeholder-wrap, .value-wrap, .step-wrap, .access-wrap, .description-wrap, .name-wrap').hide()
self.handleCheckingForm()
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand Down
17 changes: 16 additions & 1 deletion app/assets/javascripts/multiple_form/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ CIF.Client_trackingsNew = CIF.Client_trackingsCreate = CIF.Client_custom_fieldsN
_hideAnotherLanguageField()
_copyInputTextToLocalLanguage()
_copyTextAreaTextToLocalLanguage()
_copyNumberToLocalLanguage()
_copyDateToLocalLanguage()

_initICheckBox = ->
$('.i-checks').iCheck
Expand Down Expand Up @@ -57,13 +59,26 @@ CIF.Client_trackingsNew = CIF.Client_trackingsCreate = CIF.Client_custom_fieldsN
_copyInputTextToLocalLanguage = ->
$('input[type="text"]').on 'keyup', (e) ->
el = $(@)
el.parent().next().find('#' + el.data('local-input')).val(el.val())
if el.hasClass('date-picker')
console.log('ddddaaaattteee')
else
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())

_copyNumberToLocalLanguage = ->
$('input[type="number"]').on 'keyup mouseup', (e) ->
el = $(@)
el.parent().next().find('#' + el.data('local-number')).val(el.val())

_copyDateToLocalLanguage = ->
$('input.form-builder-date').on 'changeDate', (e) ->
el = $(@)
el.next('#' + el.data('local-date')).val(el.val())

_preventRequireFields = ->
preventFileUploader()
preventRequireFieldInput()
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/program_streams/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
}
typeUserEvents: {
'checkbox-group': builderOption.eventCheckboxOption()
date: builderOption.eventDateOption()
date: builderOption.eventDateOption(fields)
file: builderOption.eventFileOption()
number: builderOption.eventNumberOption()
number: builderOption.eventNumberOption(fields)
'radio-group': builderOption.eventRadioOption()
select: builderOption.eventSelectOption(fields)
text: builderOption.eventTextFieldOption(fields)
Expand Down
6 changes: 4 additions & 2 deletions app/views/shared/fields/_date.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
- 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
= label.html_safe
%div{ class: "date input-group #{required?(field_props['required'])}" }
= f.text_field field_props['label'], class: "date optional form-control date-picker #{field_props['className']} #{required?((field_props['required'] || false))}", type: 'text', name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]"
= f.text_field field_props['label'], class: "form-builder-date date optional form-control date-picker #{field_props['className']} #{required?((field_props['required'] || false))}", type: 'text', name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", 'data-local-date': "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize
= f.text_field field_props['local_label'], type: 'hidden', 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.input-group-addon
%i.fa.fa-calendar-check-o
%span.help-block
Expand Down
6 changes: 4 additions & 2 deletions app/views/shared/fields/_number.haml
Original file line number Diff line number Diff line change
@@ -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: :integer, required: (field_props['required'] || false), input_html: { class: field_props['className'], name: "#{f.object_name}[#{field_props['label'].gsub('&amp;', '&').gsub('&lt;', '<').gsub('&gt;', '>')}]" }, label: false
= label.html_safe
= f.input field_props['label'], as: :integer, required: (field_props['required'] || false), input_html: { class: field_props['className'], name: "#{f.object_name}[#{field_props['label'].gsub('&amp;', '&').gsub('&lt;', '<').gsub('&gt;', '>')}]", 'data-local-number': "#{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)

0 comments on commit 8b0ed4a

Please sign in to comment.