Improved merge feature.
This commit is contained in:
parent
507eae63bb
commit
1d805d13db
9 changed files with 154 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
class App.Controller extends Spine.Controller
|
||||
|
||||
|
||||
# add @title methode to set title
|
||||
title: (name) ->
|
||||
# $('html head title').html( Config.product_name + ' - ' + App.i18n.translateInline(name) )
|
||||
|
|
|
@ -14,6 +14,8 @@ class App.ControllerTable extends App.Controller
|
|||
overview: ['host', 'user', 'adapter', 'active'],
|
||||
model: App.Channel,
|
||||
objects: data,
|
||||
checkbox: false,
|
||||
radio: false,
|
||||
)
|
||||
|
||||
new App.ControllerTable(
|
||||
|
@ -34,6 +36,8 @@ class App.ControllerTable extends App.Controller
|
|||
],
|
||||
model: App.Ticket,
|
||||
objects: tickets,
|
||||
checkbox: false,
|
||||
radio: false,
|
||||
)
|
||||
|
||||
###
|
||||
|
@ -43,6 +47,7 @@ class App.ControllerTable extends App.Controller
|
|||
attributes = data.attributes || data.model.configure_attributes || {}
|
||||
header = data.header
|
||||
|
||||
# check if table is empty
|
||||
if _.isEmpty(data.objects)
|
||||
table = ''
|
||||
table = '-none-'
|
||||
|
@ -111,11 +116,8 @@ class App.ControllerTable extends App.Controller
|
|||
overview: dataTypesForCols,
|
||||
objects: data.objects,
|
||||
checkbox: data.checkbox,
|
||||
radio: data.radio,
|
||||
)
|
||||
# @log 'ttt', $(table).find('span')
|
||||
# $(table).find('span').bind('click', ->
|
||||
# console.log('----------click---------')
|
||||
# )
|
||||
|
||||
# convert to jquery object
|
||||
table = $(table)
|
||||
|
|
|
@ -1,10 +1,99 @@
|
|||
class App.TicketMerge extends App.ControllerModal
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
@fetch()
|
||||
|
||||
fetch: ->
|
||||
|
||||
# merge tickets
|
||||
App.Com.ajax(
|
||||
id: 'ticket_merge_list',
|
||||
type: 'GET',
|
||||
url: '/api/ticket_merge_list/' + @ticket_id,
|
||||
data: {
|
||||
# view: @view
|
||||
}
|
||||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
if data.customer
|
||||
App.Collection.load( type: 'Ticket', data: data.customer.tickets )
|
||||
App.Collection.load( type: 'User', data: data.customer.users )
|
||||
|
||||
if data.recent
|
||||
App.Collection.load( type: 'Ticket', data: data.recent.tickets )
|
||||
App.Collection.load( type: 'User', data: data.recent.users )
|
||||
|
||||
@render( data )
|
||||
)
|
||||
|
||||
render: (data) ->
|
||||
|
||||
render: ->
|
||||
@html App.view('agent_ticket_merge')()
|
||||
|
||||
list = []
|
||||
for t in data.customer.tickets
|
||||
ticketItem = App.Collection.find( 'Ticket', t.id )
|
||||
list.push ticketItem
|
||||
new App.ControllerTable(
|
||||
el: @el.find('#ticket-merge-customer-tickets'),
|
||||
overview_extended: [
|
||||
{ name: 'number', link: true },
|
||||
{ name: 'title', link: true },
|
||||
# { name: 'customer', class: 'user-data', data: { id: true } },
|
||||
{ name: 'ticket_state', translate: true },
|
||||
# { name: 'ticket_priority', translate: true },
|
||||
{ name: 'group' },
|
||||
# { name: 'owner', class: 'user-data', data: { id: true } },
|
||||
{ name: 'created_at', callback: @humanTime },
|
||||
# { name: 'last_contact', callback: @frontendTime },
|
||||
# { name: 'last_contact_agent', callback: @frontendTime },
|
||||
# { name: 'last_contact_customer', callback: @frontendTime },
|
||||
# { name: 'first_response', callback: @frontendTime },
|
||||
# { name: 'close_time', callback: @frontendTime },
|
||||
],
|
||||
model: App.Ticket,
|
||||
objects: list,
|
||||
radio: true,
|
||||
)
|
||||
|
||||
list = []
|
||||
for t in data.recent.tickets
|
||||
ticketItem = App.Collection.find( 'Ticket', t.id )
|
||||
list.push ticketItem
|
||||
new App.ControllerTable(
|
||||
el: @el.find('#ticket-merge-recent-tickets'),
|
||||
overview_extended: [
|
||||
{ name: 'number', link: true },
|
||||
{ name: 'title', link: true },
|
||||
# { name: 'customer', class: 'user-data', data: { id: true } },
|
||||
{ name: 'ticket_state', translate: true },
|
||||
# { name: 'ticket_priority', translate: true },
|
||||
{ name: 'group' },
|
||||
# { name: 'owner', class: 'user-data', data: { id: true } },
|
||||
{ name: 'created_at', callback: @humanTime },
|
||||
# { name: 'last_contact', callback: @frontendTime },
|
||||
# { name: 'last_contact_agent', callback: @frontendTime },
|
||||
# { name: 'last_contact_customer', callback: @frontendTime },
|
||||
# { name: 'first_response', callback: @frontendTime },
|
||||
# { name: 'close_time', callback: @frontendTime },
|
||||
],
|
||||
model: App.Ticket,
|
||||
objects: list,
|
||||
radio: true,
|
||||
)
|
||||
|
||||
@el.delegate('[name="master_ticket_number"]', 'focus', (e) ->
|
||||
$(e.target).parents().find('[name="radio"]').attr( 'checked', false )
|
||||
)
|
||||
|
||||
@el.delegate('[name="radio"]', 'click', (e) ->
|
||||
if $(e.target).attr('checked')
|
||||
ticket_id = $(e.target).val()
|
||||
ticket = App.Collection.find( 'Ticket', ticket_id )
|
||||
$(e.target).parents().find('[name="master_ticket_number"]').val( ticket.number )
|
||||
)
|
||||
|
||||
@modalShow()
|
||||
|
||||
submit: (e) =>
|
||||
|
|
|
@ -4,19 +4,14 @@
|
|||
<h3><%- @T( 'Merge' ) %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="table_history"></div>
|
||||
<h4><%- @T( 'Merge to Ticket#' ) %></h4>
|
||||
<input type="text" name="master_ticket_number" value=""/>
|
||||
|
||||
<hr>
|
||||
<h4><%- @T( 'Recent Customer Tickets' ) %></h4>
|
||||
<div id="ticket-merge-customer-tickets"></div>
|
||||
<!--
|
||||
<ul>
|
||||
<li>Ticket#</li>
|
||||
<li>Recent Views Tickets</li>
|
||||
<li>Recent Customer Tickets</li>
|
||||
</ul>
|
||||
-->
|
||||
<hr>
|
||||
<h4><%- @T( 'Recent Views Tickets' ) %></h4>
|
||||
<div id="ticket-merge-recent-tickets"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary"><%- @T( 'Submit' ) %></button>
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<% if @checkbox: %>
|
||||
<th style="width: 10px"><input type="checkbox" value="" name="bulk_all"/></th>
|
||||
<% end %>
|
||||
<% if @radio: %>
|
||||
<th style="width: 10px"></th>
|
||||
<% end %>
|
||||
<% for row in @header: %>
|
||||
<th <% if row.style: %>style="<%= row.style %>"<% end %>><%- @T( row.display ) %></th>
|
||||
<% end %>
|
||||
|
@ -18,9 +21,10 @@
|
|||
<% position++ %>
|
||||
<tr class="item <% if object.active is false: %>not-active<% end %>" data-id="<%= object.id %>" data-position="<%= position %>" >
|
||||
<% if @checkbox: %>
|
||||
<td>
|
||||
<input type="checkbox" value="<%= object.id %>" name="bulk"/>
|
||||
</td>
|
||||
<td><input type="checkbox" value="<%= object.id %>" name="bulk"/></td>
|
||||
<% end %>
|
||||
<% if @radio: %>
|
||||
<td><input type="radio" value="<%= object.id %>" name="radio"/></td>
|
||||
<% end %>
|
||||
<% for row in @overview: %>
|
||||
<% displayName = @P( object[row.name], row ) %>
|
||||
|
|
|
@ -17,7 +17,7 @@ curl http://localhost/api/recent_viewed.json -v -u #{login}:#{password} -H "Cont
|
|||
=end
|
||||
|
||||
def recent_viewed
|
||||
recent_viewed = History.recent_viewed_fulldata(current_user)
|
||||
recent_viewed = History.recent_viewed_fulldata( current_user, 10 )
|
||||
|
||||
# return result
|
||||
render :json => recent_viewed
|
||||
|
|
|
@ -185,6 +185,45 @@ class TicketsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
# GET /ticket_merge_list/1
|
||||
def ticket_merge_list
|
||||
|
||||
# get closed/open states
|
||||
ticket_states = Ticket::State.where(
|
||||
:ticket_state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action', 'closed'] )
|
||||
)
|
||||
ticket = Ticket.find( params[:ticket_id] )
|
||||
ticket_list = Ticket.where( :customer_id => ticket.customer_id, :ticket_state_id => ticket_states ).limit(6)
|
||||
|
||||
# get related users
|
||||
users = {}
|
||||
tickets = []
|
||||
ticket_list.each {|ticket|
|
||||
data = Ticket.full_data(ticket.id)
|
||||
tickets.push data
|
||||
if !users[ data['owner_id'] ]
|
||||
users[ data['owner_id'] ] = User.user_data_full( data['owner_id'] )
|
||||
end
|
||||
if !users[ data['customer_id'] ]
|
||||
users[ data['customer_id'] ] = User.user_data_full( data['customer_id'] )
|
||||
end
|
||||
if !users[ data['created_by_id'] ]
|
||||
users[ data['created_by_id'] ] = User.user_data_full( data['created_by_id'] )
|
||||
end
|
||||
}
|
||||
|
||||
recent_viewed = History.recent_viewed_fulldata( current_user, 6 )
|
||||
|
||||
# return result
|
||||
render :json => {
|
||||
:customer => {
|
||||
:tickets => tickets,
|
||||
:users => users,
|
||||
},
|
||||
:recent => recent_viewed
|
||||
}
|
||||
end
|
||||
|
||||
# GET /ticket_merge/1/1
|
||||
def ticket_merge
|
||||
|
||||
|
|
|
@ -188,14 +188,14 @@ class History < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
def self.recent_viewed(user)
|
||||
def self.recent_viewed( user, limit = 10 )
|
||||
# g = Group.where( :active => true ).joins(:users).where( 'users.id' => user.id )
|
||||
stream = History.select("distinct(o_id), created_by_id, history_type_id, history_object_id, created_at").
|
||||
where( :history_object_id => History::Object.where( :name => 'Ticket').first.id ).
|
||||
where( :history_type_id => History::Type.where( :name => ['viewed'] ) ).
|
||||
where( :created_by_id => user.id ).
|
||||
order('created_at DESC, id ASC').
|
||||
limit(10)
|
||||
limit(limit)
|
||||
datas = []
|
||||
stream.each do |item|
|
||||
data = item.attributes
|
||||
|
@ -209,8 +209,8 @@ class History < ActiveRecord::Base
|
|||
return datas
|
||||
end
|
||||
|
||||
def self.recent_viewed_fulldata(user)
|
||||
recent_viewed = History.recent_viewed(user)
|
||||
def self.recent_viewed_fulldata( user, limit )
|
||||
recent_viewed = History.recent_viewed( user, limit )
|
||||
|
||||
# get related users
|
||||
users = {}
|
||||
|
|
|
@ -10,6 +10,7 @@ module ExtraRoutes
|
|||
map.match '/api/ticket_full/:id', :to => 'tickets#ticket_full', :via => :get
|
||||
map.match '/api/ticket_history/:id', :to => 'tickets#ticket_history', :via => :get
|
||||
map.match '/api/ticket_customer', :to => 'tickets#ticket_customer', :via => :get
|
||||
map.match '/api/ticket_merge_list/:ticket_id', :to => 'tickets#ticket_merge_list', :via => :get
|
||||
map.match '/api/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge'
|
||||
|
||||
# ticket overviews
|
||||
|
|
Loading…
Reference in a new issue