Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Apply translation form #2039

Open
wants to merge 28 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c0ef371
[TASK] Apply translation form
rayuth-you Jun 1, 2022
b0eb1c4
[FEATURE] Upgrade form builder to 3.8.2
Bunhok Aug 19, 2022
5e76c27
[FEATURE] Translate form builder
Bunhok Aug 22, 2022
474361c
[FEATURE] Translate input element
Bunhok Sep 20, 2022
8b0ed4a
[FEATURE] Translate Date & Number field
Bunhok Sep 21, 2022
8fe0ae4
[FEATURE] Translate Radio group field
Bunhok Sep 21, 2022
27bc860
[FEATURE] Translate Checkbox group field
Bunhok Sep 22, 2022
4fa056f
[FEATURE] Translate File element
Bunhok Sep 30, 2022
250dc2c
Fixed NoMethod error. in app/helpers/custom_field_properties_helper.rb
kirykr Oct 5, 2022
36a091d
[IMP] Fix issue Tracking frm not saving
Bunhok Oct 6, 2022
4f43039
Merge branch 'stable-after-caching' into OSC-17
kirykr Oct 31, 2022
78b2e9f
Migrate local fields to custom fields
kirykr Nov 4, 2022
f5e3c92
refactored #remove_local_field_prop_unicode, and app/views/shared/fie…
kirykr Nov 11, 2022
9b92ccf
Merge branch 'stable' into OSC-17
kirykr Dec 11, 2023
e26becd
Update client enrollment field properties checkboxes functionality
kirykr Dec 12, 2023
44dea3c
Finished checkbox check/uncheck update enrollment form
kirykr Dec 14, 2023
92c185c
Done with the program stream enrollment
kirykr Dec 19, 2023
3ec5a16
updated custom_property_key_label_to_name.rake
kirykr Dec 21, 2023
0f290f7
working on updating tracking report builder field label
kirykr Dec 22, 2023
6b8a9a9
updated tracking report builder
kirykr Jan 2, 2024
e6441af
Finished exit program. and working on custom form
kirykr Jan 2, 2024
7acf265
update update field properties script
kirykr Jan 5, 2024
7e3432a
Merge branch 'stable' into OSC-17
kirykr Jan 17, 2024
9c87432
Merge branch 'stable' into OSC-17
kirykr Jan 24, 2024
8ffd860
Fixed custom_property_key_label_to_name.rake logic
kirykr Jan 24, 2024
bb64b10
Updated custom_property_key_label_to_name.rake
kirykr Jan 26, 2024
654e6d1
Merge branch 'OSC-17' of github.com:Children-in-Families/oscar-web in…
kirykr Jan 26, 2024
4b15ca8
Merge branch 'stable' into OSC-17
kirykr Jun 5, 2024
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ group :test do
end

gem "sentry-raven", "~> 2.13"
gem 'terser', '~> 1.1', '>= 1.1.12'

gem "redis-rails", "~> 5.0"

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@ GEM
sysrandom (1.0.5)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
terser (1.1.12)
execjs (>= 0.3.0, < 3)
text (1.3.1)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
Expand Down Expand Up @@ -1003,6 +1005,7 @@ DEPENDENCIES
sorbet-rails
spreadsheet (~> 1.1.3)
sysrandom (~> 1.0, >= 1.0.5)
terser (~> 1.1, >= 1.1.12)
text (~> 1.3, >= 1.3.1)
thin (~> 1.7)
thredded (~> 0.6.1)
Expand Down
56 changes: 54 additions & 2 deletions app/assets/javascripts/client_enrollment_trackings/form.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
CIF.Client_enrollment_trackingsNew = CIF.Client_enrollment_trackingsCreate = CIF.Client_enrollment_trackingsEdit = CIF.Client_enrollment_trackingsUpdate = CIF.Client_enrolled_program_trackingsUpdate =
CIF.Client_enrolled_program_trackingsNew = CIF.Client_enrolled_program_trackingsCreate = CIF.Client_enrolled_program_trackingsEdit = do ->

checkedItems = []
_init = ->
_initSelect2()
_initFileInput()
_preventRequireFileUploader()
_toggleCheckingRadioButton()
_initICheckBox()
_setAnotherLanguageFieldValue()
_hideAnotherLanguageField()
_checkCheckbox()
_uncheckCheckbox()
_copyNumberToLocalLanguage()
_copyInputTextToLocalLanguage()
_copyTextAreaTextToLocalLanguage()

_initICheckBox = ->
$('.i-checks').iCheck
checkboxClass: 'icheckbox_square-green'
radioClass: 'iradio_square-green'

_toggleCheckingRadioButton = ->
$('input[type="radio"]').on 'ifChecked', (e) ->
$(@).parents('span.radio').siblings('.radio').find('.iradio_square-green').removeClass('checked')
$('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 = ->
$('select').select2()
Expand All @@ -32,4 +42,46 @@ CIF.Client_enrolled_program_trackingsNew = CIF.Client_enrolled_program_trackings
prevent = new CIF.PreventRequiredFileUploader()
prevent.preventFileUploader()

_setAnotherLanguageFieldValue = ->
$('select').on 'select2-selecting', (e) ->
$('#' + $(e.target).data('label')).val($(e.choice.element).data('value')).trigger("change")
return

_hideAnotherLanguageField = ->
$('.client-enrolled-program-tracking').find('.d-none').parent().addClass('hide')

_checkCheckbox = ->
$('input[type="checkbox"]').on 'ifChecked', (e) ->
el = $(@)
checkedItems.push(el.data('value'))
el.parents('.check_boxes').next().children('#' + el.data('checkbox')).val(checkedItems).trigger('change')

_uncheckCheckbox = ->
$('input[type="checkbox"]').on 'ifUnchecked', (e) ->
el = $(@)
checkedItems.splice(checkedItems.indexOf(el.data('value')), 1)
el.parents('.check_boxes').next().children('#' + el.data('checkbox')).val(checkedItems).trigger('change')

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

_copyInputTextToLocalLanguage = ->
$('input[type="text"]').on 'keyup', (e) ->
el = $(@)
if el.hasClass('date-picker')
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())

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

{ init: _init }
56 changes: 56 additions & 0 deletions app/assets/javascripts/client_enrollments/form.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CIF.Client_enrollmentsNew = CIF.Client_enrollmentsCreate = CIF.Client_enrollmentsEdit = CIF.Client_enrollmentsUpdate =
CIF.Client_enrolled_programsNew = CIF.Client_enrolled_programsCreate = CIF.Client_enrolled_programsEdit = CIF.Client_enrolled_programsUpdate = do ->
checkedItems = []
_init = ->
_initSelect2()
_initFileInput()
Expand All @@ -8,6 +9,14 @@ CIF.Client_enrolled_programsNew = CIF.Client_enrolled_programsCreate = CIF.Clien
_initICheckBox()
_initDatePicker()
_preventEditDatepickerClientEnrollment()
_setAnotherLanguageFieldValue()
_hideAnotherLanguageField()
_copyInputTextToLocalLanguage()
_copyTextAreaTextToLocalLanguage()
_copyNumberToLocalLanguage()
_copyDateToLocalLanguage()
_checkCheckbox()
_uncheckCheckbox()

_initICheckBox = ->
$('.i-checks').iCheck
Expand Down Expand Up @@ -64,8 +73,25 @@ CIF.Client_enrolled_programsNew = CIF.Client_enrolled_programsCreate = CIF.Clien

_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')

_checkCheckbox = ->
$('input[type="checkbox"]').on 'ifChecked', (e) ->
el = @
elementID = el.id
relatedInput = $(el).closest('.form-group.check_boxes').siblings('div.hidden').find("input##{elementID}")
relatedInput.attr('checked', 'checked') if relatedInput
return

_uncheckCheckbox = ->
$('input[type="checkbox"]').on 'ifUnchecked', (e) ->
el = @
elementID = el.id
relatedInput = $(el).closest('.form-group.check_boxes').siblings('div.hidden').find("input##{elementID}")
relatedInput.removeAttr('checked') if relatedInput

_initSelect2 = ->
$('select').select2()

Expand All @@ -81,4 +107,34 @@ CIF.Client_enrolled_programsNew = CIF.Client_enrolled_programsCreate = CIF.Clien
prevent = new CIF.PreventRequiredFileUploader()
prevent.preventFileUploader()

_setAnotherLanguageFieldValue = ->
$('select').on 'select2-selecting', (e) ->
$('#' + $(e.target).data('label')).val($(e.choice.element).data('value')).trigger("change")
return

_hideAnotherLanguageField = ->
$('.client-enrollment').find('.d-none').parent().addClass('hide')

_copyInputTextToLocalLanguage = ->
$('input[type="text"]').on 'keyup', (e) ->
el = $(@)
if el.hasClass('date-picker')
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())

{ init: _init }
3 changes: 3 additions & 0 deletions app/assets/javascripts/common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ CIF.Common =
setTimeout(->
if self.type == 'radio' && confirm('Clear selection/លុបចោលការជ្រើសរើស?')
$(self).closest('.radio_buttons.form-group').find('input').removeAttr('checked').iCheck('update');
localOptionElement = $(self).closest('.radio_buttons.form-group').next()
if localOptionElement
localOptionElement.children('input').val('')
else
return
, 0)
Expand Down
40 changes: 31 additions & 9 deletions app/assets/javascripts/custom_form_builder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ class CIF.CustomFormBuilder
separateLine: (fieldData) ->
{ field: '<hr/>' }

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()
self.preventClickEnterOrTab(fld)

eventCheckboxOption: ->
eventCheckboxOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.other-wrap, .className-wrap, .access-wrap, .description-wrap, .name-wrap, .toggle-wrap, .inline-wrap').hide()
Expand All @@ -32,6 +33,7 @@ class CIF.CustomFormBuilder
self.addOptionCallback(fld)
self.generateValueForSelectOption(fld)
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand All @@ -41,43 +43,46 @@ 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()
self.preventClickEnterOrTab(fld)
),50

eventFileOption: ->
eventFileOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.file-field').find('.className-wrap, .placeholder-wrap, .subtype-wrap, .value-wrap, .access-wrap, .description-wrap, .name-wrap').hide()
self.handleCheckingForm()
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
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()
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 @@ -86,6 +91,7 @@ class CIF.CustomFormBuilder
self.addOptionCallback(fld)
self.generateValueForSelectOption(fld)
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand All @@ -95,7 +101,7 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50

eventSelectOption: ->
eventSelectOption: (fields = [])->
self = @
onadd: (fld) ->
$('.className-wrap, .access-wrap, .description-wrap, .name-wrap').hide()
Expand All @@ -104,6 +110,7 @@ class CIF.CustomFormBuilder
self.addOptionCallback(fld)
self.generateValueForSelectOption(fld)
self.preventClickEnterOrTab(fld)
self.handleAddTranslateLabelField(fld, fields)
onclone: (fld) ->
setTimeout ( ->
self.handleCheckingForm()
Expand All @@ -113,7 +120,7 @@ class CIF.CustomFormBuilder
self.preventClickEnterOrTab(fld)
),50

eventTextFieldOption: ->
eventTextFieldOption: (fields = []) ->
self = @
onadd: (fld) ->
$('.fld-subtype ').find('option:contains(color)').remove()
Expand All @@ -122,18 +129,20 @@ class CIF.CustomFormBuilder
$('.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()
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()
Expand Down Expand Up @@ -259,3 +268,16 @@ class CIF.CustomFormBuilder
event.preventDefault()
key = if event.which == 13 then 'Enter key' else 'Semi-colon'
alert("#{key} is not allowed!")

handleAddTranslateLabelField: (fld, fields) ->
fldElement = $(fld)
fldId = fldElement.attr('id')
index = fldId.substr(fldId.lastIndexOf('-') + 1)
localLabelName = "local_label"
localLabel = "Local Label"
if fields[index - 1]
localLabel = if fields[index - 1][localLabelName] then fields[index - 1][localLabelName] else localLabel
frmHolder = fldElement.find('.frm-holder')
localLabelBlock = "<div class='form-group local-label-wrap' style='display: block'><label for='#{localLabelName}'>Local Label</label><div class='input-wrap'><div name='#{localLabelName}' placeholder='Local Label' class='fld-label-#{fldId} form-control' id='local-label-#{fldId}' contenteditable='true'>#{localLabel}</div></div></div>"
localLabelBlockElement = $.parseHTML(localLabelBlock)
frmHolder.find('.label-wrap').after(localLabelBlockElement)
Loading