Skip to content

Commit

Permalink
[IMP] Fix issue Tracking frm not saving
Browse files Browse the repository at this point in the history
refs OSC-17
  • Loading branch information
Bunhok committed Oct 27, 2022
1 parent 250dc2c commit b94b2b8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
26 changes: 24 additions & 2 deletions app/assets/javascripts/client_enrollment_trackings/form.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
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()
_hideAnotherLanguageField()
_checkCheckbox()
_uncheckCheckbox()

_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 = $(@)
console.log(el.parents('.radio_buttons').next().children('#' + el.data('option')), 'ddddffff')
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 +39,19 @@ CIF.Client_enrolled_program_trackingsNew = CIF.Client_enrolled_program_trackings
prevent = new CIF.PreventRequiredFileUploader()
prevent.preventFileUploader()

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

{ init: _init }
8 changes: 6 additions & 2 deletions app/assets/javascripts/program_streams/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,18 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
$('.links a').trigger('click')

_handleInitProgramFields = ->
trackings = $('.tracking-builder')
elements = ['#enrollment', '#exit-program']
$.merge(elements, trackings)
_initMultipleFormBuilder(0, elements)
for element in elements
if element.id == 'enrollment' and $('#program_stream_id').val() != ''
_preventRemoveField(ENROLLMENT_URL, '#enrollment')
else if element.id == 'exit-program' and $('#program_stream_id').val() != ''
_preventRemoveField(EXIT_PROGRAM_URL, '#exit-program')

trackings = $('.tracking-builder')
_initMultipleFormBuilder(0, trackings)
# trackings = $('.tracking-builder')
# _initMultipleFormBuilder(0, trackings)
_preventRemoveField(TRACKING_URL, '') if $('#program_stream_id').val() != ''

_initButtonSave = ->
Expand All @@ -521,7 +523,9 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
$('#program_stream_rules').val(_handleStringfyRules(rules))

_handleSetValueToField = ->
console.log(@formBuilder)
for formBuilder in @formBuilder
console.log(formBuilder.actions.save())
element = formBuilder.element
specialCharacters = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&qoute;" }
format = new CIF.FormatSpecialCharacters()
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/update_field_labels_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module UpdateFieldLabelsFormBuilder
def labels_update(new_fields, old_fields, objects)
labels_changed = []
field_labels_changed = []
old_fields = [] if old_fields.empty?
fields_changed = new_fields - old_fields
fields_changed.each do |field_changed|
old_fields.each do |entity|
Expand Down

0 comments on commit b94b2b8

Please sign in to comment.