Added split ticket feature.

This commit is contained in:
Martin Edenhofer 2012-07-07 11:09:09 +02:00
parent f89df1d06b
commit 3b3ecd279d
5 changed files with 108 additions and 21 deletions

View file

@ -7,7 +7,7 @@ class Index extends App.Controller
'click .submit': 'submit',
'click .cancel': 'cancel',
constructor: ->
constructor: (params) ->
super
# check authentication
@ -15,8 +15,7 @@ class Index extends App.Controller
# set title
@title 'New Ticket'
# @render()
@fetch()
@fetch(params)
@navupdate '#ticket_create'
@edit_form = undefined
@ -26,17 +25,18 @@ class Index extends App.Controller
@log 'rerender', defaults
@render(defaults)
fetch: () ->
# get data
@ajax = new App.Ajax
# get data / in case also ticket data for split
fetch: (params) ->
if @req
@req.abort()
@ajax = new App.Ajax
@req = @ajax.ajax(
type: 'GET',
url: '/ticket_create',
data: {
# view: @view
}
ticket_id: params.ticket_id,
article_id: params.article_id,
},
processData: true,
success: (data, status, xhr) =>
@ -47,7 +47,30 @@ class Index extends App.Controller
@loadCollection( type: 'User', data: data.users )
# render page
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 = {}) ->
@ -60,8 +83,12 @@ class Index extends App.Controller
defaults['ticket_priority_id'] = App.TicketPriority.findByAttribute( 'name', '2 normal' )
# remember customers
if $('#create_customer_id').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
configure_attributes = [
@ -213,7 +240,6 @@ class UserNew extends App.ControllerModal
ui = @
user.save(
success: ->
console.log('-------', @, ui)
ui.modalHide()
realname = @.firstname + ' ' + @.lastname
$('#create_customer_id').val(@.id)
@ -226,3 +252,4 @@ class UserNew extends App.ControllerModal
)
Config.Routes['ticket_create'] = Index
Config.Routes['ticket_create/:ticket_id/:article_id'] = Index

View file

@ -141,10 +141,17 @@ class Index extends App.Controller
actions.push {
name: 'reply',
type: 'reply',
href: '#',
}
actions.push {
name: 'reply all',
type: 'reply-all',
href: '#',
}
actions.push {
name: 'split',
type: 'split',
href: '#ticket_create/' + article.ticket_id + '/' + article.id,
}
article.actions = actions

View file

@ -23,6 +23,7 @@
<img class="thumbnail user-data" data-id="<%= article.created_by_id %>" src="<%= article.created_by.image %>" alt="">
<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 %>
<li style="font-size: 10px;"><%- T(article.article_type.name) %></li>
</ul>
</div>
<div class="span8 well-muted article-message <% if article.internal is true: %> internal<% end %>">
@ -32,7 +33,7 @@
<% if 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 %>
- <%- article.humanTime %> <%- T('ago') %>

View file

@ -158,10 +158,50 @@ class TicketOverviewsController < ApplicationController
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
render :json => {
# :ticket => ticket,
# :articles => articles,
:ticket => ticket,
:articles => [ article ],
:users => users,
:edit_form => {
:owner_id => {

View file

@ -1101,6 +1101,18 @@ user = User.create(
:organizations => organizations,
: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::Object.create( :name => 'Ticket' )
@ -1144,17 +1156,17 @@ Ticket::Article::Sender.create( :name => 'System' )
ticket = Ticket.create(
: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,
:title => 'Welcome to Zammad!',
:ticket_state_id => Ticket::State.where( :name => 'new' ).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(
: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_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,
:from => 'Zammad Feedback <feedback@zammad.org>',
:body => 'Welcome!