diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee
index 7d33af5a0..c4c681f4d 100644
--- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee
+++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee
@@ -31,7 +31,7 @@ class App.TicketCreate extends App.Controller
@fetch(params)
- # lisen if view need to be rerendert
+ # lisen if view need to be rerendered
@bind 'ticket_create_rerender', (defaults) =>
@log 'notice', 'error', defaults
@render(defaults)
@@ -41,6 +41,10 @@ class App.TicketCreate extends App.Controller
return if !@authenticate(true)
@render()
+ # bind on new ticket_create_attributes updates
+ @bind 'ticket_create_attributes', (data) =>
+ App.SessionStorage.set('ticket_create_attributes', data)
+
changeFormType: (e) =>
type = $(e.target).data('type')
if !type
@@ -134,7 +138,7 @@ class App.TicketCreate extends App.Controller
fetch: (params) ->
# use cache
- cache = App.SessionStorage.get( 'ticket_create_attributes' )
+ cache = App.SessionStorage.get('ticket_create_attributes')
if cache && !params.ticket_id && !params.article_id
@@ -142,7 +146,7 @@ class App.TicketCreate extends App.Controller
@form_meta = cache.form_meta
# load assets
- App.Collection.loadAssets( cache.assets )
+ App.Collection.loadAssets(cache.assets)
@render()
else
@@ -157,13 +161,13 @@ class App.TicketCreate extends App.Controller
success: (data, status, xhr) =>
# cache request
- App.SessionStorage.set( 'ticket_create_attributes', data )
+ App.SessionStorage.set('ticket_create_attributes', data)
# get edit form attributes
@form_meta = data.form_meta
# load assets
- App.Collection.loadAssets( data.assets )
+ App.Collection.loadAssets(data.assets)
# split ticket
if data.split && data.split.ticket_id && data.split.article_id
diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee
index a85cd9d27..9435f202b 100644
--- a/app/assets/javascripts/app/controllers/ticket_overview.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee
@@ -278,13 +278,12 @@ class Table extends App.Controller
)
table = $(table)
table.delegate('[name="bulk_all"]', 'click', (e) ->
- console.log('OOOO', $(e.target).attr('checked') )
if $(e.target).attr('checked')
$(e.target).closest('table').find('[name="bulk"]').attr('checked', true)
else
$(e.target).closest('table').find('[name="bulk"]').attr('checked', false)
)
- @el.find('.table-overview').append(table)
+ @$('.table-overview').append(table)
else
openTicket = (id,e) =>
@@ -316,7 +315,7 @@ class Table extends App.Controller
id: refObject.id
value
callbackCheckbox = (id, checked, e) =>
- if @el.find('table').find('input[name="bulk"]:checked').length == 0
+ if @$('table').find('input[name="bulk"]:checked').length == 0
@bulkForm.hide()
else
@bulkForm.show()
@@ -384,44 +383,39 @@ class Table extends App.Controller
@organizationPopups()
@bulkForm = new BulkForm
- holder: @el
+ holder: @el
+ view: @view
# start bulk action observ
@el.append( @bulkForm.el )
- if @el.find('.table-overview').find('input[name="bulk"]:checked').length isnt 0
+ if @$('.table-overview').find('input[name="bulk"]:checked').length isnt 0
@bulkForm.show()
# show/hide bulk action
- @el.find('.table-overview').delegate('input[name="bulk"], input[name="bulk_all"]', 'click', (e) =>
- console.log('YES')
- if @el.find('.table-overview').find('input[name="bulk"]:checked').length == 0
-
- # hide
+ @$('.table-overview').delegate('input[name="bulk"], input[name="bulk_all"]', 'click', (e) =>
+ if @$('.table-overview').find('input[name="bulk"]:checked').length == 0
@bulkForm.hide()
-
@bulkForm.reset()
else
-
- # show
@bulkForm.show()
)
# deselect bulk_all if one item is uncheck observ
- @el.find('.table-overview').delegate('[name="bulk"]', 'click', (e) ->
+ @$('.table-overview').delegate('[name="bulk"]', 'click', (e) ->
if !$(e.target).attr('checked')
$(e.target).parents().find('[name="bulk_all"]').attr('checked', false)
)
getSelected: ->
@ticketIDs = []
- @el.find('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
+ @$('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
ticket_id = $(element).val()
@ticketIDs.push ticket_id
)
@ticketIDs
setSelected: (ticketIDs) ->
- @el.find('.table-overview').find('[name="bulk"]').each( (index, element) ->
+ @$('.table-overview').find('[name="bulk"]').each( (index, element) ->
ticket_id = $(element).val()
for ticket_id_selected in ticketIDs
if ticket_id_selected is ticket_id
@@ -448,6 +442,7 @@ class BulkForm extends App.Controller
events:
'submit form': 'submit'
+ 'click .js-submit': 'submit'
'click .js-confirm': 'confirm'
'click .js-cancel': 'reset'
@@ -472,19 +467,19 @@ class BulkForm extends App.Controller
@html App.view('agent_ticket_view/bulk')()
new App.ControllerForm(
- el: @el.find('#form-ticket-bulk')
+ el: @$('#form-ticket-bulk')
model:
configure_attributes: @configure_attributes_ticket
className: 'create'
labelClass: 'input-group-addon'
- form_data: @bulk
+ form_data: @bulk
noFieldset: true
)
new App.ControllerForm(
- el: @el.find('#form-ticket-bulk-comment')
+ el: @$('#form-ticket-bulk-comment')
model:
- configure_attributes: [{ name: 'body', display: 'Comment', tag: 'textarea', rows: 4, null: true, upload: false, item_class: 'flex' }]
+ configure_attributes: [{ name: 'body', display: 'Comment', tag: 'textarea', rows: 4, null: true, upload: false, item_class: 'flex' }]
className: 'create'
labelClass: 'input-group-addon'
form_data: @bulk
@@ -492,12 +487,12 @@ class BulkForm extends App.Controller
)
@confirm_attributes = [
- { name: 'type_id', display: 'Type', tag: 'select', multiple: false, null: true, relation: 'TicketArticleType', filter: @articleTypeFilter, default: '9', translate: true, class: 'medium' }
- { name: 'internal', display: 'Visibility', tag: 'select', null: true, options: { true: 'internal', false: 'public' }, class: 'medium', item_class: '', default: false }
+ { name: 'type_id', display: 'Type', tag: 'select', multiple: false, null: true, relation: 'TicketArticleType', filter: @articleTypeFilter, default: '9', translate: true, class: 'medium' }
+ { name: 'internal', display: 'Visibility', tag: 'select', null: true, options: { true: 'internal', false: 'public' }, class: 'medium', item_class: '', default: false }
]
new App.ControllerForm(
- el: @el.find('#form-ticket-bulk-typeVisibility')
+ el: @$('#form-ticket-bulk-typeVisibility')
model:
configure_attributes: @confirm_attributes
className: 'create'
@@ -521,7 +516,7 @@ class BulkForm extends App.Controller
# need a delay because of the click event
setTimeout ( => @$('.textarea.form-group textarea').focus() ), 0
- reset: =>
+ reset: =>
@$('.js-action-step').removeClass('hide')
@$('.js-confirm-step').addClass('hide')
@@ -554,9 +549,9 @@ class BulkForm extends App.Controller
submit: (e) =>
e.preventDefault()
- @bulk_count = @el.find('.table-overview').find('[name="bulk"]:checked').length
+ @bulk_count = @holder.find('.table-overview').find('[name="bulk"]:checked').length
@bulk_count_index = 0
- @el.find('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
+ @holder.find('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
@log 'notice', '@bulk_count_index', @bulk_count, @bulk_count_index
ticket_id = $(element).val()
ticket = App.Ticket.find(ticket_id)
@@ -568,8 +563,6 @@ class BulkForm extends App.Controller
if params[item] != ''
ticket_update[item] = params[item]
-# @log 'notice', 'update', params, ticket_update, ticket
-
# validate article
if params['body']
article = new App.TicketArticle
@@ -577,9 +570,9 @@ class BulkForm extends App.Controller
params.ticket_id = ticket.id
params.form_id = @form_id
- sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' )
- type = App.TicketArticleType.find( params['type_id'] )
- params.sender_id = sender.id
+ sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' )
+ type = App.TicketArticleType.find( params['type_id'] )
+ params.sender_id = sender.id
if !params['internal']
params['internal'] = false
@@ -606,13 +599,14 @@ class BulkForm extends App.Controller
# refresh view after all tickets are proceeded
if @bulk_count_index == @bulk_count
+ @hide()
# fetch overview data again
App.OverviewIndexCollection.fetch()
App.OverviewCollection.fetch(@view)
)
)
- @el.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
+ @holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
App.Event.trigger 'notify', {
type: 'success'
msg: App.i18n.translateContent('Bulk-Action executed!')
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee
index e9a6cb1e1..0e8dda366 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee
@@ -329,10 +329,12 @@ class App.TicketZoom extends App.Controller
new App.TicketZoomArticleNew(
ticket: @ticket
+ ticket_id: @ticket.id
el: @$('.article-new')
form_meta: @form_meta
form_id: @form_id
defaults: @taskGet('article')
+ task_key: @task_key
ui: @
)
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
index 78c349d8b..ec1fc1f1e 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
@@ -95,7 +95,7 @@ class App.TicketZoomArticleNew extends App.Controller
@bind(
'ui::ticket::setArticleType'
(data) =>
- return if data.ticket.id isnt @ticket.id
+ return if data.ticket.id isnt @ticket_id
#@setArticleType(data.type.name)
@openTextarea(null, true)
@@ -113,7 +113,7 @@ class App.TicketZoomArticleNew extends App.Controller
@bind(
'ui::ticket::taskReset'
(data) =>
- return if data.ticket_id isnt @ticket.id
+ return if data.ticket_id isnt @ticket_id
@type = 'note'
@defaults = {}
@render()
@@ -131,7 +131,7 @@ class App.TicketZoomArticleNew extends App.Controller
render: ->
- ticket = App.Ticket.fullLocal( @ticket.id )
+ ticket = App.Ticket.fullLocal( @ticket_id )
@html App.view('ticket_zoom/article_new')(
ticket: ticket
@@ -343,16 +343,31 @@ class App.TicketZoomArticleNew extends App.Controller
for name in articleType.attributes
@$("[name=#{name}]").closest('.form-group').removeClass('hide')
- # check if signature need to be added
- body = @$('[data-name=body]').html() || ''
+ # detect current signature (use current group_id, if not set, use ticket.group_id)
+ ticketCurrent = App.Ticket.find(@ticket_id)
+ group_id = ticketCurrent.group_id
+ task = App.TaskManager.get(@task_key)
+ if task && task.state && task.state.ticket && task.state.ticket.group_id
+ group_id = task.state.ticket.group_id
+ group = App.Group.find(group_id)
signature = undefined
- if @ticket.group.signature_id
- signature = App.Signature.find( @ticket.group.signature_id )
+ if group && group.signature_id
+ signature = App.Signature.find(group.signature_id)
+
+ # add/replace signature
if signature && signature.body && @type is 'email'
+
+ # if signature has changed, remove it
+ signature_id = @$('[data-signature=true]').data('signature-id')
+ if signature_id && signature_id.toString() isnt signature.id.toString()
+ @$('[data-name=body] [data-signature="true"]').remove()
+
+ # apply new signature
signatureFinished = App.Utils.text2html(
- App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: @ticket } )
+ App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: ticketCurrent } )
)
- if App.Utils.signatureCheck( body, signatureFinished )
+ body = @$('[data-name=body]').html() || ''
+ if App.Utils.signatureCheck(body, signatureFinished)
if !App.Utils.lastLineEmpty(body)
body = body + '
'
body = body + "