Implemented issue #1206 - Feedback Form Channel - Ability to set a target group for incoming tickets.
This commit is contained in:
parent
1d4ce42c67
commit
c734a52240
5 changed files with 244 additions and 9 deletions
|
@ -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, '<')
|
||||
.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')
|
||||
|
|
|
@ -10,8 +10,20 @@
|
|||
<div class="page-content">
|
||||
<p><%- @T('With form you can add a form to your web page which directly generates a ticket for you.') %></p>
|
||||
|
||||
<h2><%- @T('Settings') %></h2>
|
||||
<form class="js-paramsSetting">
|
||||
<fieldset>
|
||||
<div class="input form-group formGroup--halfSize">
|
||||
<div class="formGroup-label">
|
||||
<label for="form-group"><%- @T('Group selection for Ticket creation') %></label>
|
||||
</div>
|
||||
<div class="controls js-groupSelector" id="from-group"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<h2><%- @T('Designer') %></h2>
|
||||
<form class="js-params">
|
||||
<form class="js-paramsDesigner">
|
||||
|
||||
<fieldset>
|
||||
<div class="input form-group formGroup--halfSize">
|
||||
|
|
|
@ -99,9 +99,12 @@ class FormController < ApplicationController
|
|||
# set current user
|
||||
UserInfo.current_user_id = customer.id
|
||||
|
||||
group = Group.where(active: true).first
|
||||
group = Group.find_by(id: Setting.get('form_ticket_create_group_id'))
|
||||
if !group
|
||||
group = Group.first
|
||||
group = Group.where(active: true).first
|
||||
if !group
|
||||
group = Group.first
|
||||
end
|
||||
end
|
||||
ticket = Ticket.create!(
|
||||
group_id: group.id,
|
||||
|
|
103
db/migrate/20170628000001_form_group_selection.rb
Normal file
103
db/migrate/20170628000001_form_group_selection.rb
Normal file
|
@ -0,0 +1,103 @@
|
|||
class FormGroupSelection < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
# return if it's a new setup
|
||||
return if !Setting.find_by(name: 'system_init_done')
|
||||
|
||||
group = Group.where(active: true).first
|
||||
if !group
|
||||
group = Group.first
|
||||
end
|
||||
group_id = 1
|
||||
if group
|
||||
group_id = group.id
|
||||
end
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Group selection for Ticket creation',
|
||||
name: 'form_ticket_create_group_id',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines if group of created tickets via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_group_id',
|
||||
tag: 'select',
|
||||
relation: 'Group',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: group_id,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets by ip per hour',
|
||||
name: 'form_ticket_create_by_ip_per_hour',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets by ip per hour via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_by_ip_per_hour',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 20,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets by ip per day',
|
||||
name: 'form_ticket_create_by_ip_per_day',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets by ip per day via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_by_ip_per_day',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 240,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets per day',
|
||||
name: 'form_ticket_create_per_day',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets per day via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_per_day',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 5000,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
|
||||
end
|
||||
end
|
|
@ -1489,6 +1489,101 @@ Setting.create_if_not_exists(
|
|||
frontend: false,
|
||||
)
|
||||
|
||||
group = Group.where(active: true).first
|
||||
if !group
|
||||
group = Group.first
|
||||
end
|
||||
group_id = 1
|
||||
if group
|
||||
group_id = group.id
|
||||
end
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Group selection for Ticket creation',
|
||||
name: 'form_ticket_create_group_id',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines if group of created tickets via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_group_id',
|
||||
tag: 'select',
|
||||
relation: 'Group',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: group_id,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets by ip per hour',
|
||||
name: 'form_ticket_create_by_ip_per_hour',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets by ip per hour via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_by_ip_per_hour',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 20,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets by ip per day',
|
||||
name: 'form_ticket_create_by_ip_per_day',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets by ip per day via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_by_ip_per_day',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 240,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Limit tickets per day',
|
||||
name: 'form_ticket_create_per_day',
|
||||
area: 'Form::Base',
|
||||
description: 'Defines limit of tickets per day via web form.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'form_ticket_create_per_day',
|
||||
tag: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 5000,
|
||||
preferences: {
|
||||
permission: ['admin.channel_formular'],
|
||||
},
|
||||
frontend: false,
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Ticket Subject Size',
|
||||
name: 'ticket_subject_size',
|
||||
|
|
Loading…
Reference in a new issue