Added feature to create a ticket without existing customer, just enter email address in customer search field.
This commit is contained in:
parent
b7c0ddb90f
commit
e2eef259b4
4 changed files with 67 additions and 0 deletions
|
@ -63,6 +63,15 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
@userSelect.focus() if not @formControl.hasClass 'focus'
|
@userSelect.focus() if not @formControl.hasClass 'focus'
|
||||||
|
|
||||||
onBlur: =>
|
onBlur: =>
|
||||||
|
selectUser = @userSelect.val()
|
||||||
|
if _.isEmpty(selectUser)
|
||||||
|
@userId.val('')
|
||||||
|
return
|
||||||
|
if @attribute.guess is true
|
||||||
|
currentUserId = @userId.val()
|
||||||
|
if _.isEmpty(currentUserId) || currentUserId.match(/^guess:/)
|
||||||
|
if !_.isEmpty(selectUser)
|
||||||
|
@userId.val("guess:#{selectUser}")
|
||||||
@formControl.removeClass 'focus'
|
@formControl.removeClass 'focus'
|
||||||
|
|
||||||
onUserClick: (e) =>
|
onUserClick: (e) =>
|
||||||
|
|
|
@ -73,6 +73,29 @@ class TicketsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
clean_params = Ticket.param_association_lookup(params)
|
clean_params = Ticket.param_association_lookup(params)
|
||||||
clean_params = Ticket.param_cleanup(clean_params, true)
|
clean_params = Ticket.param_cleanup(clean_params, true)
|
||||||
|
|
||||||
|
# try to create customer if needed
|
||||||
|
if clean_params[:customer_id] && clean_params[:customer_id] =~ /^guess:(.+?)$/
|
||||||
|
email = $1
|
||||||
|
if email !~ /@/ || email =~ /(>|<|\||\!|"|§|'|\$|%|&|\(|\)|\?|\s)/
|
||||||
|
render json: { error: 'Invalid email' }, status: :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
customer = User.find_by(email: email)
|
||||||
|
if !customer
|
||||||
|
role_ids = Role.signup_role_ids
|
||||||
|
customer = User.create(
|
||||||
|
firstname: '',
|
||||||
|
lastname: '',
|
||||||
|
email: email,
|
||||||
|
password: '',
|
||||||
|
active: true,
|
||||||
|
role_ids: role_ids,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
clean_params[:customer_id] = customer.id
|
||||||
|
end
|
||||||
|
|
||||||
ticket = Ticket.new(clean_params)
|
ticket = Ticket.new(clean_params)
|
||||||
|
|
||||||
# check if article is given
|
# check if article is given
|
||||||
|
|
|
@ -11,5 +11,39 @@ class UpdateSettingPostmasterFilter2 < ActiveRecord::Migration
|
||||||
state: 'Channel::Filter::SenderIsSystemAddress',
|
state: 'Channel::Filter::SenderIsSystemAddress',
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
ObjectManager::Attribute.add(
|
||||||
|
force: true,
|
||||||
|
object: 'Ticket',
|
||||||
|
name: 'customer_id',
|
||||||
|
display: 'Customer',
|
||||||
|
data_type: 'user_autocompletion',
|
||||||
|
data_option: {
|
||||||
|
relation: 'User',
|
||||||
|
autocapitalize: false,
|
||||||
|
multiple: false,
|
||||||
|
guess: true,
|
||||||
|
null: false,
|
||||||
|
limit: 200,
|
||||||
|
placeholder: 'Enter Person or Organization/Company',
|
||||||
|
minLengt: 2,
|
||||||
|
translate: false,
|
||||||
|
},
|
||||||
|
editable: false,
|
||||||
|
active: true,
|
||||||
|
screens: {
|
||||||
|
create_top: {
|
||||||
|
Agent: {
|
||||||
|
null: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
edit: {},
|
||||||
|
},
|
||||||
|
to_create: false,
|
||||||
|
to_migrate: false,
|
||||||
|
to_delete: false,
|
||||||
|
position: 10,
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3296,6 +3296,7 @@ ObjectManager::Attribute.add(
|
||||||
relation: 'User',
|
relation: 'User',
|
||||||
autocapitalize: false,
|
autocapitalize: false,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
|
guess: true,
|
||||||
null: false,
|
null: false,
|
||||||
limit: 200,
|
limit: 200,
|
||||||
placeholder: 'Enter Person or Organization/Company',
|
placeholder: 'Enter Person or Organization/Company',
|
||||||
|
|
Loading…
Reference in a new issue