|
@@ -68,6 +68,7 @@ class CustomerTicketCreate extends App.ControllerAppContent
|
|
|
events:
|
|
|
'fileUploadStart .richtext': => @submitDisable()
|
|
|
'fileUploadStop .richtext': => @submitEnable()
|
|
|
+ articleParamsCallback: @articleParams
|
|
|
)
|
|
|
|
|
|
@$('[name="group_id"], [name="organization_id"]').bind('change', =>
|
|
@@ -86,6 +87,26 @@ class CustomerTicketCreate extends App.ControllerAppContent
|
|
|
params: =>
|
|
|
params = @formParam(@$('.main form'))
|
|
|
|
|
|
+ articleParams: =>
|
|
|
+ params = @params()
|
|
|
+ if params.group_id
|
|
|
+ group = App.Group.find( params.group_id )
|
|
|
+
|
|
|
+ # find sender_id
|
|
|
+ sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' )
|
|
|
+ type = App.TicketArticleType.findByAttribute( 'name', 'web' )
|
|
|
+
|
|
|
+ {
|
|
|
+ from: "#{ @Session.get().displayName() }"
|
|
|
+ to: (group && group.name) || ''
|
|
|
+ subject: params.subject
|
|
|
+ body: params.body
|
|
|
+ type_id: type.id
|
|
|
+ sender_id: sender.id
|
|
|
+ form_id: @form_id
|
|
|
+ content_type: 'text/html'
|
|
|
+ }
|
|
|
+
|
|
|
submit: (e) ->
|
|
|
e.preventDefault()
|
|
|
|
|
@@ -108,23 +129,8 @@ class CustomerTicketCreate extends App.ControllerAppContent
|
|
|
ticket = new App.Ticket
|
|
|
@log 'CustomerTicketCreate', 'notice', 'updateAttributes', params
|
|
|
|
|
|
- # find sender_id
|
|
|
- sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' )
|
|
|
- type = App.TicketArticleType.findByAttribute( 'name', 'web' )
|
|
|
- if params.group_id
|
|
|
- group = App.Group.find( params.group_id )
|
|
|
-
|
|
|
# create article
|
|
|
- params['article'] = {
|
|
|
- from: "#{ @Session.get().displayName() }"
|
|
|
- to: (group && group.name) || ''
|
|
|
- subject: params.subject
|
|
|
- body: params.body
|
|
|
- type_id: type.id
|
|
|
- sender_id: sender.id
|
|
|
- form_id: @form_id
|
|
|
- content_type: 'text/html'
|
|
|
- }
|
|
|
+ params['article'] = @articleParams()
|
|
|
|
|
|
ticket.load(params)
|
|
|
|