Added split ticket feature.
This commit is contained in:
parent
f89df1d06b
commit
3b3ecd279d
5 changed files with 108 additions and 21 deletions
|
@ -7,7 +7,7 @@ class Index extends App.Controller
|
||||||
'click .submit': 'submit',
|
'click .submit': 'submit',
|
||||||
'click .cancel': 'cancel',
|
'click .cancel': 'cancel',
|
||||||
|
|
||||||
constructor: ->
|
constructor: (params) ->
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
|
@ -15,8 +15,7 @@ class Index extends App.Controller
|
||||||
|
|
||||||
# set title
|
# set title
|
||||||
@title 'New Ticket'
|
@title 'New Ticket'
|
||||||
# @render()
|
@fetch(params)
|
||||||
@fetch()
|
|
||||||
@navupdate '#ticket_create'
|
@navupdate '#ticket_create'
|
||||||
|
|
||||||
@edit_form = undefined
|
@edit_form = undefined
|
||||||
|
@ -25,18 +24,19 @@ class Index extends App.Controller
|
||||||
Spine.bind 'ticket_create_rerender', (defaults) =>
|
Spine.bind 'ticket_create_rerender', (defaults) =>
|
||||||
@log 'rerender', defaults
|
@log 'rerender', defaults
|
||||||
@render(defaults)
|
@render(defaults)
|
||||||
|
|
||||||
fetch: () ->
|
# get data / in case also ticket data for split
|
||||||
# get data
|
fetch: (params) ->
|
||||||
@ajax = new App.Ajax
|
|
||||||
if @req
|
if @req
|
||||||
@req.abort()
|
@req.abort()
|
||||||
|
@ajax = new App.Ajax
|
||||||
@req = @ajax.ajax(
|
@req = @ajax.ajax(
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/ticket_create',
|
url: '/ticket_create',
|
||||||
data: {
|
data: {
|
||||||
# view: @view
|
ticket_id: params.ticket_id,
|
||||||
}
|
article_id: params.article_id,
|
||||||
|
},
|
||||||
processData: true,
|
processData: true,
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
|
|
||||||
|
@ -47,7 +47,30 @@ class Index extends App.Controller
|
||||||
@loadCollection( type: 'User', data: data.users )
|
@loadCollection( type: 'User', data: data.users )
|
||||||
|
|
||||||
# render page
|
# render page
|
||||||
@render()
|
if !params.ticket_id && !params.article_id
|
||||||
|
@render()
|
||||||
|
else
|
||||||
|
|
||||||
|
# load user collection
|
||||||
|
@loadCollection( type: 'User', data: data.users )
|
||||||
|
|
||||||
|
# load ticket collection
|
||||||
|
@loadCollection( type: 'Ticket', data: [data.ticket] )
|
||||||
|
|
||||||
|
# load article collections
|
||||||
|
@loadCollection( type: 'TicketArticle', data: data.articles || [] )
|
||||||
|
|
||||||
|
# render page
|
||||||
|
t = App.Ticket.find(params.ticket_id).attributes()
|
||||||
|
a = App.TicketArticle.find(params.article_id)
|
||||||
|
|
||||||
|
# reset owner
|
||||||
|
t.owner_id = 0
|
||||||
|
t.customer_id_autocompletion = a.from
|
||||||
|
t.subject = a.subject || t.title
|
||||||
|
t.body = a.body
|
||||||
|
@log '11111', t
|
||||||
|
@render( options: t )
|
||||||
)
|
)
|
||||||
|
|
||||||
render: (template = {}) ->
|
render: (template = {}) ->
|
||||||
|
@ -60,8 +83,12 @@ class Index extends App.Controller
|
||||||
defaults['ticket_priority_id'] = App.TicketPriority.findByAttribute( 'name', '2 normal' )
|
defaults['ticket_priority_id'] = App.TicketPriority.findByAttribute( 'name', '2 normal' )
|
||||||
|
|
||||||
# remember customers
|
# remember customers
|
||||||
defaults['customer_id'] = $('#create_customer_id').val()
|
if $('#create_customer_id').val()
|
||||||
defaults['customer_id_autocompletion'] = $('#create_customer_id_autocompletion').val()
|
defaults['customer_id'] = $('#create_customer_id').val()
|
||||||
|
defaults['customer_id_autocompletion'] = $('#create_customer_id_autocompletion').val()
|
||||||
|
else
|
||||||
|
# defaults['customer_id'] = '2'
|
||||||
|
# defaults['customer_id_autocompletion'] = '12312313'
|
||||||
|
|
||||||
# generate form
|
# generate form
|
||||||
configure_attributes = [
|
configure_attributes = [
|
||||||
|
@ -213,7 +240,6 @@ class UserNew extends App.ControllerModal
|
||||||
ui = @
|
ui = @
|
||||||
user.save(
|
user.save(
|
||||||
success: ->
|
success: ->
|
||||||
console.log('-------', @, ui)
|
|
||||||
ui.modalHide()
|
ui.modalHide()
|
||||||
realname = @.firstname + ' ' + @.lastname
|
realname = @.firstname + ' ' + @.lastname
|
||||||
$('#create_customer_id').val(@.id)
|
$('#create_customer_id').val(@.id)
|
||||||
|
@ -225,4 +251,5 @@ class UserNew extends App.ControllerModal
|
||||||
ui.modalHide()
|
ui.modalHide()
|
||||||
)
|
)
|
||||||
|
|
||||||
Config.Routes['ticket_create'] = Index
|
Config.Routes['ticket_create'] = Index
|
||||||
|
Config.Routes['ticket_create/:ticket_id/:article_id'] = Index
|
||||||
|
|
|
@ -141,11 +141,18 @@ class Index extends App.Controller
|
||||||
actions.push {
|
actions.push {
|
||||||
name: 'reply',
|
name: 'reply',
|
||||||
type: 'reply',
|
type: 'reply',
|
||||||
|
href: '#',
|
||||||
}
|
}
|
||||||
actions.push {
|
actions.push {
|
||||||
name: 'reply all',
|
name: 'reply all',
|
||||||
type: 'reply-all',
|
type: 'reply-all',
|
||||||
|
href: '#',
|
||||||
}
|
}
|
||||||
|
actions.push {
|
||||||
|
name: 'split',
|
||||||
|
type: 'split',
|
||||||
|
href: '#ticket_create/' + article.ticket_id + '/' + article.id,
|
||||||
|
}
|
||||||
article.actions = actions
|
article.actions = actions
|
||||||
|
|
||||||
# set title
|
# set title
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<img class="thumbnail user-data" data-id="<%= article.created_by_id %>" src="<%= article.created_by.image %>" alt="">
|
<img class="thumbnail user-data" data-id="<%= article.created_by_id %>" src="<%= article.created_by.image %>" alt="">
|
||||||
<ul>
|
<ul>
|
||||||
<% if article.article_type.name is 'email': %><li style="font-size: 10px;"><a href="/ticket_article_plain/<%= article.id %>"><%- T('Plain') %></a></li><% end %>
|
<% if article.article_type.name is 'email': %><li style="font-size: 10px;"><a href="/ticket_article_plain/<%= article.id %>"><%- T('Plain') %></a></li><% end %>
|
||||||
|
<li style="font-size: 10px;"><%- T(article.article_type.name) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="span8 well-muted article-message <% if article.internal is true: %> internal<% end %>">
|
<div class="span8 well-muted article-message <% if article.internal is true: %> internal<% end %>">
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
<% if article.actions: %>
|
<% if article.actions: %>
|
||||||
<% for action in article.actions: %>
|
<% for action in article.actions: %>
|
||||||
-
|
-
|
||||||
<a href="#" data-type="<%= action.type %>" class="<% if action.class: %><%= action.class %><% end %>"><%= action.name %></a>
|
<a href="<%= action.href %>" data-type="<%= action.type %>" class="<% if action.class: %><%= action.class %><% end %>"><%= action.name %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
- <%- article.humanTime %> <%- T('ago') %>
|
- <%- article.humanTime %> <%- T('ago') %>
|
||||||
|
|
|
@ -158,10 +158,50 @@ class TicketOverviewsController < ApplicationController
|
||||||
ticket_priority_ids.push priority.id
|
ticket_priority_ids.push priority.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# split data
|
||||||
|
ticket = nil
|
||||||
|
articles = nil
|
||||||
|
if params[:ticket_id] && params[:article_id]
|
||||||
|
ticket = Ticket.find( params[:ticket_id] )
|
||||||
|
|
||||||
|
# get related users
|
||||||
|
users = {}
|
||||||
|
if !users[ticket.owner_id]
|
||||||
|
users[ticket.owner_id] = user_data_full(ticket.owner_id)
|
||||||
|
end
|
||||||
|
if !users[ticket.customer_id]
|
||||||
|
users[ticket.customer_id] = user_data_full(ticket.customer_id)
|
||||||
|
end
|
||||||
|
if !users[ticket.created_by_id]
|
||||||
|
users[ticket.created_by_id] = user_data_full(ticket.created_by_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
owner_ids = []
|
||||||
|
ticket.agent_of_group.each { |user|
|
||||||
|
owner_ids.push user.id
|
||||||
|
if !users[user.id]
|
||||||
|
users[user.id] = user_data_full(user.id)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
# get related articles
|
||||||
|
ticket[:article_ids] = [ params[:article_id] ]
|
||||||
|
|
||||||
|
article = Ticket::Article.find( params[:article_id] )
|
||||||
|
|
||||||
|
# add attachment list to article
|
||||||
|
article['attachments'] = Store.list( :object => 'Ticket::Article', :o_id => article.id )
|
||||||
|
|
||||||
|
# load users
|
||||||
|
if !users[article.created_by_id]
|
||||||
|
users[article.created_by_id] = user_data_full(article.created_by_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => {
|
render :json => {
|
||||||
# :ticket => ticket,
|
:ticket => ticket,
|
||||||
# :articles => articles,
|
:articles => [ article ],
|
||||||
:users => users,
|
:users => users,
|
||||||
:edit_form => {
|
:edit_form => {
|
||||||
:owner_id => {
|
:owner_id => {
|
||||||
|
|
20
db/seeds.rb
20
db/seeds.rb
|
@ -1101,6 +1101,18 @@ user = User.create(
|
||||||
:organizations => organizations,
|
:organizations => organizations,
|
||||||
:created_by_id => 1
|
:created_by_id => 1
|
||||||
)
|
)
|
||||||
|
user_community = User.create(
|
||||||
|
:login => 'nicol.braun@zammad.org',
|
||||||
|
:firstname => 'Nicol',
|
||||||
|
:lastname => 'Braun',
|
||||||
|
:email => 'nicol.braun@zammad.org',
|
||||||
|
:password => '',
|
||||||
|
:active => true,
|
||||||
|
:roles => roles,
|
||||||
|
# :groups => groups,
|
||||||
|
:organizations => organizations,
|
||||||
|
:created_by_id => 1
|
||||||
|
)
|
||||||
|
|
||||||
Link::Type.create( :name => 'normal' )
|
Link::Type.create( :name => 'normal' )
|
||||||
Link::Object.create( :name => 'Ticket' )
|
Link::Object.create( :name => 'Ticket' )
|
||||||
|
@ -1144,17 +1156,17 @@ Ticket::Article::Sender.create( :name => 'System' )
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
:group_id => Group.where( :name => 'Users' ).first.id,
|
:group_id => Group.where( :name => 'Users' ).first.id,
|
||||||
:customer_id => User.where( :login => '-' ).first.id,
|
:customer_id => User.where( :login => 'nicol.braun@zammad.org' ).first.id,
|
||||||
:owner_id => User.where( :login => '-' ).first.id,
|
:owner_id => User.where( :login => '-' ).first.id,
|
||||||
:title => 'Welcome to Zammad!',
|
:title => 'Welcome to Zammad!',
|
||||||
:ticket_state_id => Ticket::State.where( :name => 'new' ).first.id,
|
:ticket_state_id => Ticket::State.where( :name => 'new' ).first.id,
|
||||||
:ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
|
:ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
|
||||||
:created_by_id => User.where( :login => '-' ).first.id
|
:created_by_id => User.where( :login => 'nicol.braun@zammad.org' ).first.id
|
||||||
)
|
)
|
||||||
Ticket::Article.create(
|
Ticket::Article.create(
|
||||||
:created_by_id => User.where(:login => '-').first.id,
|
:created_by_id => User.where( :login => 'nicol.braun@zammad.org' ).first.id,
|
||||||
:ticket_id => ticket.id,
|
:ticket_id => ticket.id,
|
||||||
:ticket_article_type_id => Ticket::Article::Type.where(:name => 'email' ).first.id,
|
:ticket_article_type_id => Ticket::Article::Type.where(:name => 'phone' ).first.id,
|
||||||
:ticket_article_sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id,
|
:ticket_article_sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id,
|
||||||
:from => 'Zammad Feedback <feedback@zammad.org>',
|
:from => 'Zammad Feedback <feedback@zammad.org>',
|
||||||
:body => 'Welcome!
|
:body => 'Welcome!
|
||||||
|
|
Loading…
Reference in a new issue