<%- @T('With form you can add a form to your web page which directly generates a ticket for you.') %>
+diff --git a/app/assets/javascripts/app/controllers/_channel/form.coffee b/app/assets/javascripts/app/controllers/_channel/form.coffee index d9697b132..6955b3b60 100644 --- a/app/assets/javascripts/app/controllers/_channel/form.coffee +++ b/app/assets/javascripts/app/controllers/_channel/form.coffee @@ -3,12 +3,14 @@ class App.ChannelForm extends App.ControllerSubContent requiredPermission: 'admin.channel_formular' header: 'Form' events: - 'change form.js-params': 'updateParams' - 'keyup form.js-params': 'updateParams' + 'change form.js-paramsDesigner': 'updateParamsDesigner' + 'keyup form.js-paramsDesigner': 'updateParamsDesigner' 'change .js-formSetting input': 'toggleFormSetting' + 'change .js-paramsSetting select': 'updateGroup' elements: '.js-paramsBlock': 'paramsBlock' + '.js-paramsSetting': 'paramsSetting' '.js-formSetting input': 'formSetting' constructor: -> @@ -20,22 +22,38 @@ class App.ChannelForm extends App.ControllerSubContent render: => setting = App.Setting.get('form_ticket_create') - @html App.view('channel/form')( + + element = $(App.view('channel/form')( baseurl: window.location.origin formSetting: setting + )) + + group_id = App.Setting.get('form_ticket_create_group_id') + selection = App.UiElement.select.render( + name: 'group_id' + multiple: false + null: false + relation: 'Group' + nulloption: false + value: group_id + #class: 'form-control--small' ) + console.log('s', element.find('.js-groupSelector'), selection) + element.find('.js-groupSelector').html(selection) + + @html element @paramsBlock.each (i, block) -> hljs.highlightBlock block - @updateParams() + @updateParamsDesigner() - updateParams: -> + updateParamsDesigner: -> quote = (string) -> string = string.replace('\'', '\\\'') .replace(/\/g, '>') - params = @formParam(@$('.js-params')) + params = @formParam(@$('.js-paramsDesigner')) paramString = '' for key, value of params if value != '' @@ -63,4 +81,8 @@ class App.ChannelForm extends App.ControllerSubContent value = @formSetting.prop('checked') App.Setting.set('form_ticket_create', value) + updateGroup: => + value = @paramsSetting.find('[name=group_id]').val() + App.Setting.set('form_ticket_create_group_id', value) + App.Config.set('Form', { prio: 2000, name: 'Form', parent: '#channels', target: '#channels/form', controller: App.ChannelForm, permission: ['admin.formular'] }, 'NavBarAdmin') diff --git a/app/assets/javascripts/app/views/channel/form.jst.eco b/app/assets/javascripts/app/views/channel/form.jst.eco index 6f6e891f7..f0e412a8f 100644 --- a/app/assets/javascripts/app/views/channel/form.jst.eco +++ b/app/assets/javascripts/app/views/channel/form.jst.eco @@ -10,8 +10,20 @@
<%- @T('With form you can add a form to your web page which directly generates a ticket for you.') %>
+