Fixed ticket update and bulk action.
This commit is contained in:
parent
7059cc7a24
commit
419c65f9f8
7 changed files with 146 additions and 92 deletions
|
@ -284,7 +284,7 @@ class App.ControllerForm extends App.Controller
|
|||
for item in ui.model.configure_attributes
|
||||
if item.name is toChangeAttribute
|
||||
item.display = false
|
||||
item['filter'][toChangeAttribute]['id'] = newListAttributes
|
||||
item['filter'][toChangeAttribute] = newListAttributes
|
||||
if params[changedAttribute]
|
||||
item.default = params[toChangeAttribute]
|
||||
if !item.default
|
||||
|
@ -362,15 +362,12 @@ class App.ControllerForm extends App.Controller
|
|||
for record in App[attribute.relation].all()
|
||||
|
||||
# check all filter attributes
|
||||
for key of filter
|
||||
for key in filter
|
||||
|
||||
# check all filter values as array
|
||||
if filter[key]
|
||||
for value in filter[key]
|
||||
|
||||
# if it's matching, use it for selection
|
||||
if record[key] is value
|
||||
list.push record
|
||||
# if it's matching, use it for selection
|
||||
if record['id'] is key
|
||||
list.push record
|
||||
else
|
||||
list = App[attribute.relation].all()
|
||||
|
||||
|
|
|
@ -193,32 +193,22 @@ class Index extends App.Controller
|
|||
|
||||
bulk_form: =>
|
||||
@configure_attributes_ticket = [
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @bulk, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @bulk, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', filter: @bulk, nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, relation: 'User', filter: @bulk, nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
]
|
||||
form_ticket = @formGen( model: { configure_attributes: @configure_attributes_ticket, className: 'create' } )
|
||||
@configure_attributes_article = [
|
||||
# { name: 'from', display: 'From', tag: 'input', type: 'text', limit: 100, null: false, class: 'span8', },
|
||||
{ name: 'to', display: 'To', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' },
|
||||
{ name: 'cc', display: 'Cc', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' },
|
||||
{ name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' },
|
||||
{ name: 'in_reply_to', display: 'In Reply to', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' },
|
||||
{ name: 'body', display: 'Text', tag: 'textarea', rows: 4, limit: 100, null: true, class: 'span7', },
|
||||
{ name: 'ticket_article_type_id', display: 'Type', tag: 'select', multiple: false, null: true, relation: 'TicketArticleType', default: '9', class: 'medium', item_class: 'keepleft' },
|
||||
{ name: 'internal', display: 'Visability', tag: 'radio', default: false, null: true, options: { true: 'internal', false: 'public' }, class: 'medium', item_class: 'keepleft' },
|
||||
# { name: 'ticket_article_sender_id', display: 'Sender', tag: 'select', multiple: false, null: true, relation: 'TicketArticleSender', default: '', class: 'medium' },
|
||||
]
|
||||
form_article = @formGen( model: { configure_attributes: @configure_attributes_article } )
|
||||
|
||||
|
||||
# render init page
|
||||
html = App.view('agent_ticket_view/bulk')(
|
||||
meta: @overview.meta,
|
||||
form_ticket: form_ticket,
|
||||
# form_article: form_article,
|
||||
html = $( App.view('agent_ticket_view/bulk')() )
|
||||
new App.ControllerForm(
|
||||
el: html.find('#form-ticket-bulk'),
|
||||
model: {
|
||||
configure_attributes: @configure_attributes_ticket,
|
||||
className: 'create',
|
||||
},
|
||||
form_data: @bulk,
|
||||
)
|
||||
html = $(html)
|
||||
# html.delegate('.bulk-action-form', 'submit', (e) =>
|
||||
html.bind('submit', (e) =>
|
||||
e.preventDefault()
|
||||
|
|
|
@ -85,15 +85,15 @@ class Index extends App.Controller
|
|||
# set title
|
||||
@title 'Ticket Zoom ' + @ticket.number
|
||||
@configure_attributes_ticket = [
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @edit_form, translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @edit_form, translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', filter: @edit_form, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, relation: 'User', filter: @edit_form, nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
]
|
||||
if @isRole('Customer')
|
||||
@configure_attributes_ticket = [
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @edit_form, translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @edit_form, translate: true, class: 'span2', item_class: 'keepleft' },
|
||||
]
|
||||
|
||||
@configure_attributes_article = [
|
||||
|
@ -114,17 +114,30 @@ class Index extends App.Controller
|
|||
{ name: 'body', display: 'Text', tag: 'textarea', rows: 5, limit: 100, null: true, class: 'span7', item_class: '' },
|
||||
]
|
||||
|
||||
form_ticket = @formGen( model: { configure_attributes: @configure_attributes_ticket, className: 'create' }, params: @ticket )
|
||||
form_article = @formGen( model: { configure_attributes: @configure_attributes_article } )
|
||||
|
||||
@html App.view('agent_ticket_zoom')(
|
||||
ticket: @ticket,
|
||||
articles: @articles,
|
||||
form_ticket: form_ticket,
|
||||
form_article: form_article,
|
||||
nav: @nav,
|
||||
)
|
||||
|
||||
new App.ControllerForm(
|
||||
el: @el.find('#form-ticket-update'),
|
||||
model: {
|
||||
configure_attributes: @configure_attributes_ticket,
|
||||
className: 'create',
|
||||
},
|
||||
params: @ticket
|
||||
form_data: @edit_form,
|
||||
)
|
||||
|
||||
new App.ControllerForm(
|
||||
el: @el.find('#form-article-update'),
|
||||
model: {
|
||||
configure_attributes: @configure_attributes_article,
|
||||
},
|
||||
form_data: @edit_form,
|
||||
)
|
||||
|
||||
@el.find('textarea').elastic()
|
||||
|
||||
# enable user popups
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<form class="form-stacked keepleft update-box bulk-action-form">
|
||||
<%- @form_ticket %>
|
||||
<%- @form_article %>
|
||||
<div id="form-ticket-bulk"></div>
|
||||
<input type="submit" class="btn primary submit" value="update">
|
||||
</form>
|
|
@ -79,14 +79,11 @@
|
|||
</div>
|
||||
<div class="span8 well-muted article-message">
|
||||
<form class="form-stacked keepleft">
|
||||
|
||||
<%- @form_ticket %>
|
||||
|
||||
<%- @form_article %>
|
||||
|
||||
<div class="keepleft" id="file-uploader"></div>
|
||||
|
||||
<button type="submit" class="btn btn-primary submit"><%- T('Submit') %></button>
|
||||
<div id="form-ticket-update"></div>
|
||||
<div id="form-article-update"></div>
|
||||
<div class="keepleft" id="file-uploader"></div>
|
||||
|
||||
<button type="submit" class="btn btn-primary submit"><%- T('Submit') %></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -60,14 +60,25 @@ class TicketOverviewsController < ApplicationController
|
|||
end
|
||||
}
|
||||
|
||||
# get data for bulk action
|
||||
bulk_owners = Role.where( :name => ['Agent'] ).first.users.select(:id).where( :active => true ).uniq()
|
||||
bulk_owner_ids = []
|
||||
bulk_owners.each { |user|
|
||||
bulk_owner_ids.push user.id
|
||||
if !users[ user.id ]
|
||||
users[ user.id ] = User.user_data_full( user.id )
|
||||
end
|
||||
# get groups
|
||||
group_ids = []
|
||||
Group.where( :active => true ).each { |group|
|
||||
group_ids.push group.id
|
||||
}
|
||||
agents = {}
|
||||
Ticket.agents.each { |user|
|
||||
agents[ user.id ] = 1
|
||||
}
|
||||
groups_users = {}
|
||||
group_ids.each {|group_id|
|
||||
groups_users[ group_id ] = []
|
||||
Group.find(group_id).users.each {|user|
|
||||
next if !agents[ user.id ]
|
||||
groups_users[ group_id ].push user.id
|
||||
if !users[user.id]
|
||||
users[user.id] = User.user_data_full(user.id)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
# return result
|
||||
|
@ -77,9 +88,7 @@ class TicketOverviewsController < ApplicationController
|
|||
:tickets_count => overview[:tickets_count],
|
||||
:users => users,
|
||||
:bulk => {
|
||||
:owner_id => {
|
||||
:id => bulk_owner_ids,
|
||||
},
|
||||
:group_id__owner_id => groups_users,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
@ -89,18 +98,18 @@ class TicketOverviewsController < ApplicationController
|
|||
def ticket_create
|
||||
|
||||
# get attributes
|
||||
(users, ticket_owner_ids, ticket_group_ids, ticket_state_ids, ticket_priority_ids) = Ticket.create_attributes(
|
||||
create_attributes = Ticket.create_attributes(
|
||||
:current_user_id => current_user.id,
|
||||
)
|
||||
|
||||
# split data
|
||||
ticket = nil
|
||||
articles = nil
|
||||
users = {}
|
||||
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.user_data_full(ticket.owner_id)
|
||||
end
|
||||
|
@ -110,7 +119,7 @@ class TicketOverviewsController < ApplicationController
|
|||
if !users[ticket.created_by_id]
|
||||
users[ticket.created_by_id] = User.user_data_full(ticket.created_by_id)
|
||||
end
|
||||
|
||||
|
||||
owner_ids = []
|
||||
ticket.agent_of_group.each { |user|
|
||||
owner_ids.push user.id
|
||||
|
@ -121,37 +130,30 @@ class TicketOverviewsController < ApplicationController
|
|||
|
||||
# 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.user_data_full(article.created_by_id)
|
||||
end
|
||||
end
|
||||
|
||||
create_attributes[:owner_id].each {|user_id|
|
||||
if !users[user_id]
|
||||
users[user_id] = User.user_data_full(user_id)
|
||||
end
|
||||
}
|
||||
|
||||
# return result
|
||||
render :json => {
|
||||
:ticket => ticket,
|
||||
:articles => [ article ],
|
||||
:users => users,
|
||||
:edit_form => {
|
||||
:owner_id => {
|
||||
:id => ticket_owner_ids
|
||||
},
|
||||
:group_id => {
|
||||
:id => ticket_group_ids
|
||||
},
|
||||
:ticket_state_id => {
|
||||
:id => ticket_state_ids
|
||||
},
|
||||
:ticket_priority_id => {
|
||||
:id => ticket_priority_ids
|
||||
}
|
||||
}
|
||||
:ticket => ticket,
|
||||
:articles => [ article ],
|
||||
:users => users,
|
||||
:edit_form => create_attributes,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -213,15 +215,35 @@ class TicketOverviewsController < ApplicationController
|
|||
end
|
||||
}
|
||||
|
||||
# get groups
|
||||
group_ids = []
|
||||
Group.where( :active => true ).each { |group|
|
||||
group_ids.push group.id
|
||||
}
|
||||
agents = {}
|
||||
Ticket.agents.each { |user|
|
||||
agents[ user.id ] = 1
|
||||
}
|
||||
groups_users = {}
|
||||
group_ids.each {|group_id|
|
||||
groups_users[ group_id ] = []
|
||||
Group.find(group_id).users.each {|user|
|
||||
next if !agents[ user.id ]
|
||||
groups_users[ group_id ].push user.id
|
||||
if !users[user.id]
|
||||
users[user.id] = User.user_data_full(user.id)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
# return result
|
||||
render :json => {
|
||||
:ticket => ticket,
|
||||
:articles => articles_used,
|
||||
:users => users,
|
||||
:edit_form => {
|
||||
:owner_id => {
|
||||
:id => owner_ids
|
||||
}
|
||||
:group_id__owner_id => groups_users,
|
||||
:owner_id => owner_ids,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -396,12 +396,34 @@ class ClientState
|
|||
@data[cache_key] = overview_data_time
|
||||
overview_data = CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
self.log "push overview_data for user #{user.id}"
|
||||
|
||||
users = {}
|
||||
tickets = []
|
||||
overview_data[:tickets].each {|ticket_id|
|
||||
self.ticket( ticket_id, tickets, users )
|
||||
}
|
||||
|
||||
# get groups
|
||||
group_ids = []
|
||||
Group.where( :active => true ).each { |group|
|
||||
group_ids.push group.id
|
||||
}
|
||||
agents = {}
|
||||
Ticket.agents.each { |user|
|
||||
agents[ user.id ] = 1
|
||||
}
|
||||
groups_users = {}
|
||||
groups_users[''] = []
|
||||
group_ids.each {|group_id|
|
||||
groups_users[ group_id ] = []
|
||||
Group.find(group_id).users.each {|user|
|
||||
next if !agents[ user.id ]
|
||||
groups_users[ group_id ].push user.id
|
||||
if !users[user.id]
|
||||
users[user.id] = User.user_data_full(user.id)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
# send update to browser
|
||||
self.transaction({
|
||||
:data => {
|
||||
|
@ -411,7 +433,11 @@ class ClientState
|
|||
:collections => {
|
||||
:User => users,
|
||||
:Ticket => tickets,
|
||||
}
|
||||
},
|
||||
:bulk => {
|
||||
:group_id__owner_id => groups_users,
|
||||
:owner_id => [],
|
||||
},
|
||||
},
|
||||
:event => [ 'loadCollection', 'ticket_overview_rebuild' ],
|
||||
:collection => 'ticket_overview_' + overview.meta[:url].to_s,
|
||||
|
@ -424,13 +450,23 @@ class ClientState
|
|||
ticket_create_attributes_time = CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if ticket_create_attributes_time && @data[:ticket_create_attributes_time] != ticket_create_attributes_time
|
||||
@data[:ticket_create_attributes_time] = ticket_create_attributes_time
|
||||
ticket_create_attributes = CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
create_attributes = CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
users = {}
|
||||
create_attributes[:owner_id].each {|user_id|
|
||||
if !users[user_id]
|
||||
users[user_id] = User.user_data_full(user_id)
|
||||
end
|
||||
}
|
||||
data = {
|
||||
:users => users,
|
||||
:edit_form => create_attributes,
|
||||
}
|
||||
self.log "push ticket_create_attributes for user #{user.id}"
|
||||
|
||||
# send update to browser
|
||||
self.transaction({
|
||||
:collection => 'ticket_create_attributes',
|
||||
:data => ticket_create_attributes,
|
||||
:data => data,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue