Added support of signature.
This commit is contained in:
parent
abe409ad94
commit
c3e6c4028a
3 changed files with 66 additions and 37 deletions
|
@ -22,6 +22,8 @@ class Index extends App.Controller
|
||||||
@edit_form = undefined
|
@edit_form = undefined
|
||||||
@ticket_id = params.ticket_id
|
@ticket_id = params.ticket_id
|
||||||
@article_id = params.article_id
|
@article_id = params.article_id
|
||||||
|
@signature = undefined
|
||||||
|
@signature_used = undefined
|
||||||
|
|
||||||
@key = 'ticket::' + @ticket_id
|
@key = 'ticket::' + @ticket_id
|
||||||
cache = App.Store.get( @key )
|
cache = App.Store.get( @key )
|
||||||
|
@ -49,10 +51,13 @@ class Index extends App.Controller
|
||||||
# reset old indexes
|
# reset old indexes
|
||||||
@ticket = undefined
|
@ticket = undefined
|
||||||
@articles = undefined
|
@articles = undefined
|
||||||
|
|
||||||
# get edit form attributes
|
# get edit form attributes
|
||||||
@edit_form = data.edit_form
|
@edit_form = data.edit_form
|
||||||
|
|
||||||
|
# get signature
|
||||||
|
@signature = data.signature
|
||||||
|
|
||||||
# load user collection
|
# load user collection
|
||||||
App.Collection.load( type: 'User', data: data.users )
|
App.Collection.load( type: 'User', data: data.users )
|
||||||
|
|
||||||
|
@ -133,6 +138,9 @@ class Index extends App.Controller
|
||||||
model: {
|
model: {
|
||||||
configure_attributes: @configure_attributes_article,
|
configure_attributes: @configure_attributes_article,
|
||||||
},
|
},
|
||||||
|
# params: {
|
||||||
|
# body: @signature.body,
|
||||||
|
# }
|
||||||
form_data: @edit_form,
|
form_data: @edit_form,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -205,13 +213,13 @@ class Index extends App.Controller
|
||||||
public_internal: (e) ->
|
public_internal: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
article_id = $(e.target).parents('[data-id]').data('id')
|
article_id = $(e.target).parents('[data-id]').data('id')
|
||||||
|
|
||||||
# storage update
|
# storage update
|
||||||
article = App.TicketArticle.find(article_id)
|
article = App.TicketArticle.find(article_id)
|
||||||
internal = true
|
internal = true
|
||||||
if article.internal == true
|
if article.internal == true
|
||||||
internal = false
|
internal = false
|
||||||
|
|
||||||
article.updateAttributes(
|
article.updateAttributes(
|
||||||
internal: internal
|
internal: internal
|
||||||
)
|
)
|
||||||
|
@ -258,6 +266,16 @@ class Index extends App.Controller
|
||||||
@el.find('[name="cc"]').parents('.control-group').removeClass('hide')
|
@el.find('[name="cc"]').parents('.control-group').removeClass('hide')
|
||||||
# @el.find('[name="subject"]').parents('.control-group').removeClass('hide')
|
# @el.find('[name="subject"]').parents('.control-group').removeClass('hide')
|
||||||
|
|
||||||
|
# add signature
|
||||||
|
if !@signature_used && @signature && @signature.body
|
||||||
|
@signature_used = true
|
||||||
|
body = @el.find('[name="body"]').val() || ''
|
||||||
|
body = body + "\n" + @signature.body
|
||||||
|
@el.find('[name="body"]').val( body )
|
||||||
|
|
||||||
|
# update textarea size
|
||||||
|
@el.find('[name="body"]').trigger('change')
|
||||||
|
|
||||||
reply: (e) =>
|
reply: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
article_id = $(e.target).parents('[data-id]').data('id')
|
article_id = $(e.target).parents('[data-id]').data('id')
|
||||||
|
@ -279,7 +297,7 @@ class Index extends App.Controller
|
||||||
@el.find('[name="cc"]').val('')
|
@el.find('[name="cc"]').val('')
|
||||||
@el.find('[name="subject"]').val('')
|
@el.find('[name="subject"]').val('')
|
||||||
@el.find('[name="in_reply_to"]').val('')
|
@el.find('[name="in_reply_to"]').val('')
|
||||||
|
|
||||||
if article.message_id
|
if article.message_id
|
||||||
@el.find('[name="in_reply_to"]').val(article.message_id)
|
@el.find('[name="in_reply_to"]').val(article.message_id)
|
||||||
|
|
||||||
|
@ -289,9 +307,9 @@ class Index extends App.Controller
|
||||||
to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
||||||
@log 'c', customer
|
@log 'c', customer
|
||||||
@el.find('[name="body"]').val('@' + to)
|
@el.find('[name="body"]').val('@' + to)
|
||||||
|
|
||||||
else if article_type.name is 'twitter direct-message'
|
else if article_type.name is 'twitter direct-message'
|
||||||
|
|
||||||
# show to
|
# show to
|
||||||
to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
||||||
@el.find('[name="to"]').val(to)
|
@el.find('[name="to"]').val(to)
|
||||||
|
@ -306,7 +324,7 @@ class Index extends App.Controller
|
||||||
selection = window.Session['UISelection'].trim()
|
selection = window.Session['UISelection'].trim()
|
||||||
selection = selection.replace /^(.*)$/mg, (match) =>
|
selection = selection.replace /^(.*)$/mg, (match) =>
|
||||||
'> ' + match
|
'> ' + match
|
||||||
body = body + selection
|
body = selection + "\n" + body
|
||||||
@el.find('[name="body"]').val(body)
|
@el.find('[name="body"]').val(body)
|
||||||
|
|
||||||
# update textarea size
|
# update textarea size
|
||||||
|
|
|
@ -34,13 +34,13 @@ class TicketsController < ApplicationController
|
||||||
render :json => @ticket.errors, :status => :unprocessable_entity
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# create article if given
|
# create article if given
|
||||||
if params[:article]
|
if params[:article]
|
||||||
@article = Ticket::Article.new(params[:article])
|
@article = Ticket::Article.new(params[:article])
|
||||||
@article.created_by_id = params[:article][:created_by_id] || current_user.id
|
@article.created_by_id = params[:article][:created_by_id] || current_user.id
|
||||||
@article.ticket_id = @ticket.id
|
@article.ticket_id = @ticket.id
|
||||||
|
|
||||||
# find attachments in upload cache
|
# find attachments in upload cache
|
||||||
@article['attachments'] = Store.list(
|
@article['attachments'] = Store.list(
|
||||||
:object => 'UploadCache::TicketZoom::' + current_user.id.to_s,
|
:object => 'UploadCache::TicketZoom::' + current_user.id.to_s,
|
||||||
|
@ -87,18 +87,16 @@ class TicketsController < ApplicationController
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# GET /ticket_customer
|
# GET /ticket_customer
|
||||||
# GET /tickets_customer
|
# GET /tickets_customer
|
||||||
def ticket_customer
|
def ticket_customer
|
||||||
|
|
||||||
# get closed/open states
|
# get closed/open states
|
||||||
ticket_state_list_open = Ticket::State.where(
|
ticket_state_list_open = Ticket::State.where(
|
||||||
:ticket_state_type_id => Ticket::StateType.where(:name => ['new','open', 'pending remidner', 'pending action'])
|
:ticket_state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action'] )
|
||||||
)
|
)
|
||||||
ticket_state_list_closed = Ticket::State.where(
|
ticket_state_list_closed = Ticket::State.where(
|
||||||
:ticket_state_type_id => Ticket::StateType.where(:name => ['closed'] )
|
:ticket_state_type_id => Ticket::StateType.where( :name => ['closed'] )
|
||||||
)
|
)
|
||||||
|
|
||||||
# get tickets
|
# get tickets
|
||||||
|
@ -150,10 +148,10 @@ class TicketsController < ApplicationController
|
||||||
def ticket_history
|
def ticket_history
|
||||||
|
|
||||||
# get ticket data
|
# get ticket data
|
||||||
ticket = Ticket.find(params[:id])
|
ticket = Ticket.find( params[:id] )
|
||||||
|
|
||||||
# permissin check
|
# permissin check
|
||||||
return if !ticket_permission(ticket)
|
return if !ticket_permission( ticket )
|
||||||
|
|
||||||
# get history of ticket
|
# get history of ticket
|
||||||
history = History.history_list( 'Ticket', params[:id], 'Ticket::Article' )
|
history = History.history_list( 'Ticket', params[:id], 'Ticket::Article' )
|
||||||
|
@ -212,7 +210,7 @@ class TicketsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# permissin check
|
# permissin check
|
||||||
return if !ticket_permission(ticket_slave)
|
return if !ticket_permission( ticket_slave )
|
||||||
|
|
||||||
# check diffetent ticket ids
|
# check diffetent ticket ids
|
||||||
if ticket_slave.id == ticket_master.id
|
if ticket_slave.id == ticket_master.id
|
||||||
|
@ -243,31 +241,43 @@ class TicketsController < ApplicationController
|
||||||
def ticket_full
|
def ticket_full
|
||||||
|
|
||||||
# permission check
|
# permission check
|
||||||
ticket = Ticket.find(params[:id])
|
ticket = Ticket.find( params[:id] )
|
||||||
return if !ticket_permission(ticket)
|
return if !ticket_permission( ticket )
|
||||||
|
|
||||||
# get related users
|
# get related users
|
||||||
users = {}
|
users = {}
|
||||||
if !users[ticket.owner_id]
|
if !users[ticket.owner_id]
|
||||||
users[ticket.owner_id] = User.user_data_full(ticket.owner_id)
|
users[ticket.owner_id] = User.user_data_full( ticket.owner_id )
|
||||||
end
|
end
|
||||||
if !users[ticket.customer_id]
|
if !users[ticket.customer_id]
|
||||||
users[ticket.customer_id] = User.user_data_full(ticket.customer_id)
|
users[ticket.customer_id] = User.user_data_full( ticket.customer_id )
|
||||||
end
|
end
|
||||||
if !users[ticket.created_by_id]
|
if !users[ticket.created_by_id]
|
||||||
users[ticket.created_by_id] = User.user_data_full(ticket.created_by_id)
|
users[ticket.created_by_id] = User.user_data_full( ticket.created_by_id )
|
||||||
end
|
end
|
||||||
|
|
||||||
owner_ids = []
|
owner_ids = []
|
||||||
ticket.agent_of_group.each { |user|
|
ticket.agent_of_group.each { |user|
|
||||||
owner_ids.push user.id
|
owner_ids.push user.id
|
||||||
if !users[user.id]
|
if !users[user.id]
|
||||||
users[user.id] = User.user_data_full(user.id)
|
users[user.id] = User.user_data_full( user.id )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
# log object as viewed
|
# log object as viewed
|
||||||
log_view(ticket)
|
log_view( ticket )
|
||||||
|
|
||||||
|
# get signature
|
||||||
|
signature = ticket.group.signature.attributes
|
||||||
|
|
||||||
|
# replace tags
|
||||||
|
signature['body'] = NotificationFactory.build(
|
||||||
|
:string => signature['body'],
|
||||||
|
:objects => {
|
||||||
|
:ticket => ticket,
|
||||||
|
:user => current_user,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# get related articles
|
# get related articles
|
||||||
ticket = ticket.attributes
|
ticket = ticket.attributes
|
||||||
|
@ -293,7 +303,7 @@ class TicketsController < ApplicationController
|
||||||
|
|
||||||
# load users
|
# load users
|
||||||
if !users[article.created_by_id]
|
if !users[article.created_by_id]
|
||||||
users[article.created_by_id] = User.user_data_full(article.created_by_id)
|
users[article.created_by_id] = User.user_data_full( article.created_by_id )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,16 +323,17 @@ class TicketsController < ApplicationController
|
||||||
next if !agents[ user.id ]
|
next if !agents[ user.id ]
|
||||||
groups_users[ group_id ].push user.id
|
groups_users[ group_id ].push user.id
|
||||||
if !users[user.id]
|
if !users[user.id]
|
||||||
users[user.id] = User.user_data_full(user.id)
|
users[user.id] = User.user_data_full( user.id )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => {
|
render :json => {
|
||||||
:ticket => ticket,
|
:ticket => ticket,
|
||||||
:articles => articles_used,
|
:articles => articles_used,
|
||||||
:users => users,
|
:signature => signature,
|
||||||
|
:users => users,
|
||||||
:edit_form => {
|
:edit_form => {
|
||||||
:group_id__owner_id => groups_users,
|
:group_id__owner_id => groups_users,
|
||||||
:owner_id => owner_ids,
|
:owner_id => owner_ids,
|
||||||
|
@ -347,20 +358,20 @@ class TicketsController < ApplicationController
|
||||||
|
|
||||||
# get related users
|
# get related users
|
||||||
if !users[ticket.owner_id]
|
if !users[ticket.owner_id]
|
||||||
users[ticket.owner_id] = User.user_data_full(ticket.owner_id)
|
users[ticket.owner_id] = User.user_data_full( ticket.owner_id )
|
||||||
end
|
end
|
||||||
if !users[ticket.customer_id]
|
if !users[ticket.customer_id]
|
||||||
users[ticket.customer_id] = User.user_data_full(ticket.customer_id)
|
users[ticket.customer_id] = User.user_data_full( ticket.customer_id )
|
||||||
end
|
end
|
||||||
if !users[ticket.created_by_id]
|
if !users[ticket.created_by_id]
|
||||||
users[ticket.created_by_id] = User.user_data_full(ticket.created_by_id)
|
users[ticket.created_by_id] = User.user_data_full( ticket.created_by_id )
|
||||||
end
|
end
|
||||||
|
|
||||||
owner_ids = []
|
owner_ids = []
|
||||||
ticket.agent_of_group.each { |user|
|
ticket.agent_of_group.each { |user|
|
||||||
owner_ids.push user.id
|
owner_ids.push user.id
|
||||||
if !users[user.id]
|
if !users[user.id]
|
||||||
users[user.id] = User.user_data_full(user.id)
|
users[user.id] = User.user_data_full( user.id )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,13 +385,13 @@ class TicketsController < ApplicationController
|
||||||
|
|
||||||
# load users
|
# load users
|
||||||
if !users[article.created_by_id]
|
if !users[article.created_by_id]
|
||||||
users[article.created_by_id] = User.user_data_full(article.created_by_id)
|
users[article.created_by_id] = User.user_data_full( article.created_by_id )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create_attributes[:owner_id].each {|user_id|
|
create_attributes[:owner_id].each {|user_id|
|
||||||
if !users[user_id]
|
if !users[user_id]
|
||||||
users[user_id] = User.user_data_full(user_id)
|
users[user_id] = User.user_data_full( user_id )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ end
|
||||||
module NotificationFactory
|
module NotificationFactory
|
||||||
def self.build(data)
|
def self.build(data)
|
||||||
data[:string].gsub!( /\#\{(.+?)\}/ ) { |s|
|
data[:string].gsub!( /\#\{(.+?)\}/ ) { |s|
|
||||||
|
|
||||||
# use quoted text
|
# use quoted text
|
||||||
callback = $1
|
callback = $1
|
||||||
callback.gsub!( /\.body$/ ) { |item|
|
callback.gsub!( /\.body$/ ) { |item|
|
||||||
|
@ -55,7 +55,7 @@ module NotificationFactory
|
||||||
}
|
}
|
||||||
return data[:string]
|
return data[:string]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.send(data)
|
def self.send(data)
|
||||||
sender = Setting.get('notification_sender')
|
sender = Setting.get('notification_sender')
|
||||||
a = Channel::IMAP.new
|
a = Channel::IMAP.new
|
||||||
|
|
Loading…
Reference in a new issue