Added Cc support for email tickets.

This commit is contained in:
Martin Edenhofer 2016-03-03 14:39:10 +01:00
parent 66800ba455
commit a9baf7acdc
4 changed files with 133 additions and 70 deletions

View file

@ -42,29 +42,32 @@ class App.TicketCreate extends App.Controller
@buildScreen(params)
@bindId = App.TicketCreateCollection.one(load)
changeFormType: (e) =>
type = $(e.target).data('type')
currentChannel: =>
if !type
type = $(e.target).parent().data('type')
type = @$('.type-tabs .tab.active').data('type')
if !type
type = @default_type
type
changeFormType: (e) =>
type = $(e.currentTarget).data('type')
@setFormTypeInUi(type)
setFormTypeInUi: (type) =>
# detect current form type
if !type
type = @el.find('.type-tabs .tab.active').data('type')
if !type
type = @default_type
type = @currentChannel()
# reset all tabs
tabs = @el.find('.type-tabs .tab')
tabs = @$('.type-tabs .tab')
tabs.removeClass('active')
tabIcons = @el.find('.type-tabs .tab .icon')
tabIcons = @$('.type-tabs .tab .icon')
tabIcons.addClass('gray')
tabIcons.removeClass('white')
# set active tab
selectedTab = @el.find(".type-tabs .tab[data-type='#{type}']")
selectedTab = @$(".type-tabs .tab[data-type='#{type}']")
selectedTab.addClass('active')
# set form type attributes
@ -87,16 +90,22 @@ class App.TicketCreate extends App.Controller
@articleAttributes = articleSenderTypeMap[type]
# update form
@el.find('[name="formSenderType"]').val(type)
@$('[name="formSenderType"]').val(type)
# force changing signature
@el.find('[name="group_id"]').trigger('change')
@$('[name="group_id"]').trigger('change')
# show cc
if type is 'email-out'
@$('[name="cc"]').closest('.form-group').removeClass('hide')
else
@$('[name="cc"]').closest('.form-group').addClass('hide')
meta: =>
text = ''
if @articleAttributes
text = App.i18n.translateInline(@articleAttributes['title'])
title = @el.find('[name=title]').val()
title = @$('[name=title]').val()
if title
text = "#{text}: #{title}"
meta =
@ -107,20 +116,20 @@ class App.TicketCreate extends App.Controller
iconClass: 'pen'
url: =>
'#ticket/create/id/' + @id
"#ticket/create/id/#{@id}"
show: =>
@navupdate '#'
changed: =>
formCurrent = @formParam( @el.find('.ticket-create') )
formCurrent = @formParam( @$('.ticket-create') )
diff = difference(@formDefault, formCurrent)
return false if !diff || _.isEmpty(diff)
return true
autosave: =>
update = =>
data = @formParam( @el.find('.ticket-create') )
data = @formParam(@$('.ticket-create'))
diff = difference(@autosaveLast, data)
if !@autosaveLast || (diff && !_.isEmpty(diff))
@autosaveLast = data
@ -226,7 +235,7 @@ class App.TicketCreate extends App.Controller
@$('[data-name="body"]').find('[data-signature=true]').remove()
new App.ControllerForm(
el: @el.find('.ticket-form-top')
el: @$('.ticket-form-top')
form_id: @form_id
model: App.Ticket
screen: 'create_top'
@ -242,14 +251,14 @@ class App.TicketCreate extends App.Controller
)
new App.ControllerForm(
el: @el.find('.article-form-top')
el: @$('.article-form-top')
form_id: @form_id
model: App.TicketArticle
screen: 'create_top'
params: params
)
new App.ControllerForm(
el: @el.find('.ticket-form-middle')
el: @$('.ticket-form-middle')
form_id: @form_id
model: App.Ticket
screen: 'create_middle'
@ -264,7 +273,7 @@ class App.TicketCreate extends App.Controller
noFieldset: true
)
new App.ControllerForm(
el: @el.find('.ticket-form-bottom')
el: @$('.ticket-form-bottom')
form_id: @form_id
model: App.Ticket
screen: 'create_bottom'
@ -282,11 +291,11 @@ class App.TicketCreate extends App.Controller
@setFormTypeInUi( params['formSenderType'] )
# remember form params of init load
@formDefault = @formParam( @el.find('.ticket-create') )
@formDefault = @formParam( @$('.ticket-create') )
# show text module UI
@textModule = new App.WidgetTextModule(
el: @el.find('[data-name="body"]').parent()
el: @$('[data-name="body"]').parent()
)
new Sidebar(
@ -337,6 +346,10 @@ class App.TicketCreate extends App.Controller
if params.group_id
group = App.Group.find(params.group_id)
# allow cc only on email tickets
if @currentChannel() isnt 'email-out'
delete params.cc
# create article
if sender.name is 'Customer'
params['article'] = {
@ -569,7 +582,7 @@ class Router extends App.ControllerPermanent
id: params.id
App.TaskManager.execute(
key: 'TicketCreateScreen-' + params['id']
key: "TicketCreateScreen-#{params['id']}"
controller: 'TicketCreate'
params: clean_params
show: true

View file

@ -0,0 +1,32 @@
class EmailTicketCc < ActiveRecord::Migration
def up
ObjectManager::Attribute.add(
object: 'Ticket',
name: 'cc',
display: 'Cc',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {
Agent: {
null: true,
},
},
create_middle: {},
edit: {}
},
pending_migration: false,
position: 11,
created_by_id: 1,
updated_by_id: 1,
)
end
end

View file

@ -2113,7 +2113,30 @@ ObjectManager::Attribute.add(
pending_migration: false,
position: 10,
)
ObjectManager::Attribute.add(
object: 'Ticket',
name: 'cc',
display: 'Cc',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {
Agent: {
null: true,
},
},
create_middle: {},
edit: {}
},
pending_migration: false,
position: 11,
)
ObjectManager::Attribute.add(
object: 'Ticket',
name: 'type',
@ -2440,13 +2463,7 @@ ObjectManager::Attribute.add(
editable: false,
active: true,
screens: {
create_phone_in: {},
create_phone_out: {},
create_email_out: {
'-all-' => {
null: true,
}
},
create_top: {},
create_middle: {},
edit: {
Agent: {

View file

@ -1256,6 +1256,7 @@ wait untill text in selector disabppears
data = params[:data]
instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 0.2
instance.find_elements(css: 'a[href="#manage/overviews"]')[0].click
sleep 0.2
instance.find_elements(css: '#content a[data-type="new"]')[0].click