diff --git a/app/assets/javascripts/program_streams/form.coffee b/app/assets/javascripts/program_streams/form.coffee
index 9dd308f636..623dc25072 100644
--- a/app/assets/javascripts/program_streams/form.coffee
+++ b/app/assets/javascripts/program_streams/form.coffee
@@ -42,6 +42,8 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
_filterSelecting()
_selectServiceTypeTableResult()
_handleTimeOfFrequencyInput()
+ elements = ['#enrollment', '#exit-program']
+ _initMultipleFormBuilder(0, elements)
_initDataTable = ->
$('.custom-field-table').each ->
@@ -249,7 +251,7 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
$('#trackings').on 'cocoon:after-insert', (e, element) ->
trackingBuilder = $(element).find('.tracking-builder')
$(element).attr('id', Date.now())
- _initProgramBuilder(trackingBuilder, [])
+ # _initProgramBuilder(trackingBuilder, [])
_editTrackingFormName()
_handleRemoveCocoon()
_initSelect2TimeOfFrequency()
@@ -259,6 +261,58 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
_custom_field_list()
_initCheckbox()
+ _initMultipleFormBuilder = (startIndex, elements) ->
+ if startIndex < elements.length
+ dataElement = JSON.parse($(elements[startIndex]).children('span').text())
+ builderOption = new CIF.CustomFormBuilder()
+ specialCharacters = { '&': '&', '<': '<', '>': '>', "&qoute;": '"' }
+ format = new CIF.FormatSpecialCharacters()
+ fields = format.formatSpecialCharacters((dataElement || []), specialCharacters)
+
+ $(elements[startIndex]).formBuilder(
+ templates: separateLine: (fieldData) ->
+ { field: '
' }
+ fields: builderOption.thematicBreak()
+ dataType: 'json'
+ formData: JSON.stringify(fields)
+ disableFields: ['autocomplete', 'header', 'hidden', 'button', 'checkbox']
+ showActionButtons: false
+ messages: {
+ cannotBeEmpty: 'name_separated_with_underscore'
+ }
+ stickyControls: {
+ enable: true
+ offset:
+ width: '17%'
+ right: 78
+ left: 'auto'
+ }
+ typeUserEvents: {
+ 'checkbox-group': builderOption.eventCheckboxOption()
+ date: builderOption.eventDateOption()
+ file: builderOption.eventFileOption()
+ number: builderOption.eventNumberOption()
+ 'radio-group': builderOption.eventRadioOption()
+ select: builderOption.eventSelectOption()
+ text: builderOption.eventTextFieldOption()
+ textarea: builderOption.eventTextAreaOption()
+ separateLine: builderOption.eventSeparateLineOption()
+ paragraph: builderOption.eventParagraphOption()
+ }
+ onAddOption: (optionTemplate, optionIndex) ->
+ index = optionIndex.index + 1
+ optionTemplate.local_label = "Local option #{index}"
+ optionTemplate.local_value = "local-option-#{index}"
+ return optionTemplate
+ onOpenFieldEdit: (editPanel) ->
+ $(editPanel).find('.option-local_value').hide()
+ ).promise.then((form) ->
+ form.element = elements[startIndex]
+ @formBuilder.push form
+ startIndex++
+ _initMultipleFormBuilder(startIndex, elements)
+ )
+
_initProgramBuilder = (element, data) ->
builderOption = new CIF.CustomFormBuilder()
specialCharacters = { '&': '&', '<': '<', '>': '>', "&qoute;": '"' }
@@ -294,9 +348,18 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
textarea: builderOption.eventTextAreaOption()
separateLine: builderOption.eventSeparateLineOption()
paragraph: builderOption.eventParagraphOption()
- })
- formBuilder.element = element
- @formBuilder.push formBuilder
+ }
+ onAddOption: (optionTemplate, optionIndex) ->
+ index = optionIndex.index + 1
+ optionTemplate.local_label = "Local option #{index}"
+ optionTemplate.local_value = "local-option-#{index}"
+ return optionTemplate
+ onOpenFieldEdit: (editPanel) ->
+ $(editPanel).find('.option-local_value').hide()
+ ).promise
+
+ form.element = element
+ @formBuilder.push form
_editTrackingFormName = ->
inputNames = $(".program_stream_trackings_name input[type='text']")
@@ -441,7 +504,7 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
_handleInitProgramFields = ->
for element in $('#enrollment, #exit-program')
dataElement = JSON.parse($(element).children('span').text())
- _initProgramBuilder($(element), (dataElement || []))
+ # _initProgramBuilder($(element), (dataElement || []))
if element.id == 'enrollment' and $('#program_stream_id').val() != ''
_preventRemoveField(ENROLLMENT_URL, '#enrollment')
@@ -451,7 +514,7 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
trackings = $('.tracking-builder')
for tracking in trackings
trackingValue = JSON.parse($(tracking).children('span').text())
- _initProgramBuilder(tracking, (trackingValue || []))
+ # _initProgramBuilder(tracking, (trackingValue || []))
_preventRemoveField(TRACKING_URL, '') if $('#program_stream_id').val() != ''
_initButtonSave = ->
@@ -465,10 +528,11 @@ CIF.Program_streamsNew = CIF.Program_streamsEdit = CIF.Program_streamsCreate = C
_handleSetValueToField = ->
for formBuilder in @formBuilder
+ console.log(formBuilder.actions.save(), 'form builder actions')
element = formBuilder.element
specialCharacters = { "&": "&", "<": "<", ">": ">", '"': "&qoute;" }
format = new CIF.FormatSpecialCharacters()
- fields = format.formatSpecialCharacters(JSON.parse(formBuilder.actions.save()), specialCharacters)
+ fields = format.formatSpecialCharacters(formBuilder.actions.save(), specialCharacters)
fields = JSON.stringify(fields)
if $(element).is('#enrollment')
$('#program_stream_enrollment').val(fields)
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 26716f2f75..3fa31dcc86 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,5 +1,4 @@
Rails.application.configure do
- config.assets.js_compressor = :terser
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on