Added support of signature.

This commit is contained in:
Martin Edenhofer 2012-10-02 07:46:08 +02:00
parent abe409ad94
commit c3e6c4028a
3 changed files with 66 additions and 37 deletions

View file

@ -22,6 +22,8 @@ class Index extends App.Controller
@edit_form = undefined
@ticket_id = params.ticket_id
@article_id = params.article_id
@signature = undefined
@signature_used = undefined
@key = 'ticket::' + @ticket_id
cache = App.Store.get( @key )
@ -53,6 +55,9 @@ class Index extends App.Controller
# get edit form attributes
@edit_form = data.edit_form
# get signature
@signature = data.signature
# load user collection
App.Collection.load( type: 'User', data: data.users )
@ -133,6 +138,9 @@ class Index extends App.Controller
model: {
configure_attributes: @configure_attributes_article,
},
# params: {
# body: @signature.body,
# }
form_data: @edit_form,
)
@ -258,6 +266,16 @@ class Index extends App.Controller
@el.find('[name="cc"]').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) =>
e.preventDefault()
article_id = $(e.target).parents('[data-id]').data('id')
@ -306,7 +324,7 @@ class Index extends App.Controller
selection = window.Session['UISelection'].trim()
selection = selection.replace /^(.*)$/mg, (match) =>
'> ' + match
body = body + selection
body = selection + "\n" + body
@el.find('[name="body"]').val(body)
# update textarea size

View file

@ -87,15 +87,13 @@ class TicketsController < ApplicationController
head :ok
end
# GET /ticket_customer
# GET /tickets_customer
def ticket_customer
# get closed/open states
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_type_id => Ticket::StateType.where( :name => ['closed'] )
@ -269,6 +267,18 @@ class TicketsController < ApplicationController
# log object as viewed
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
ticket = ticket.attributes
ticket[:article_ids] = []
@ -322,6 +332,7 @@ class TicketsController < ApplicationController
render :json => {
:ticket => ticket,
:articles => articles_used,
:signature => signature,
:users => users,
:edit_form => {
:group_id__owner_id => groups_users,