Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
e33e10e17e
17 changed files with 579 additions and 108 deletions
|
@ -654,9 +654,13 @@ class App.ControllerForm extends App.Controller
|
||||||
item = $( App.view('generic/textarea')( attribute: attribute ) + '<div class="file-uploader ' + attribute.class + '" id="' + fileUploaderId + '"></div>' )
|
item = $( App.view('generic/textarea')( attribute: attribute ) + '<div class="file-uploader ' + attribute.class + '" id="' + fileUploaderId + '"></div>' )
|
||||||
|
|
||||||
a = =>
|
a = =>
|
||||||
$( item[0] ).expanding()
|
visible = $( item[0] ).is(":visible")
|
||||||
$( item[0] ).on('focus', ->
|
if visible && !$( item[0] ).expanding('active')
|
||||||
$( item[0] ).expanding()
|
$( item[0] ).expanding()
|
||||||
|
$( item[0] ).on('focus', ->
|
||||||
|
visible = $( item[0] ).is(":visible")
|
||||||
|
if visible && !$( item[0] ).expanding('active')
|
||||||
|
$( item[0] ).expanding()
|
||||||
)
|
)
|
||||||
App.Delay.set( a, 80 )
|
App.Delay.set( a, 80 )
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
class App.DashboardTicketSearch extends App.Controller
|
||||||
|
events:
|
||||||
|
'click [data-type=page]': 'page'
|
||||||
|
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@start_page = 1
|
||||||
|
@navupdate '#'
|
||||||
|
|
||||||
|
# render
|
||||||
|
@fetch()
|
||||||
|
|
||||||
|
fetch: (force) =>
|
||||||
|
|
||||||
|
@ajax(
|
||||||
|
id: 'dashboard_ticket_search' + @name,
|
||||||
|
type: 'GET',
|
||||||
|
url: @apiPath + '/tickets/search',
|
||||||
|
data:
|
||||||
|
condition: @condition
|
||||||
|
order: @order
|
||||||
|
detail: true
|
||||||
|
limit: 200
|
||||||
|
processData: true,
|
||||||
|
success: (data) =>
|
||||||
|
|
||||||
|
@load( data, true )
|
||||||
|
)
|
||||||
|
|
||||||
|
load: (data = false, ajax = false) =>
|
||||||
|
|
||||||
|
if ajax
|
||||||
|
App.Store.write( 'dashboard_ticket_search' + @name, data )
|
||||||
|
|
||||||
|
# load assets
|
||||||
|
App.Collection.loadAssets( data.assets )
|
||||||
|
|
||||||
|
@render( data )
|
||||||
|
|
||||||
|
else
|
||||||
|
data = App.Store.get( 'dashboard_ticket_search' + @name )
|
||||||
|
if data
|
||||||
|
@render( data )
|
||||||
|
|
||||||
|
|
||||||
|
render: (data) ->
|
||||||
|
return if !data
|
||||||
|
return if !data.tickets
|
||||||
|
|
||||||
|
@overview =
|
||||||
|
name: @name
|
||||||
|
@tickets_count = data.tickets_count
|
||||||
|
@ticket_ids = data.tickets
|
||||||
|
per_page = @per_page || 5
|
||||||
|
pages_total = parseInt( ( @tickets_count / per_page ) + 0.99999 ) || 1
|
||||||
|
html = App.view('dashboard/ticket')(
|
||||||
|
overview: @overview,
|
||||||
|
pages_total: pages_total,
|
||||||
|
start_page: @start_page,
|
||||||
|
)
|
||||||
|
html = $(html)
|
||||||
|
html.find('li').removeClass('active')
|
||||||
|
html.find(".page [data-id=\"#{@start_page}\"]").parents('li').addClass('active')
|
||||||
|
|
||||||
|
@tickets_in_table = []
|
||||||
|
start = ( @start_page-1 ) * 5
|
||||||
|
end = ( @start_page ) * 5
|
||||||
|
i = start
|
||||||
|
while i < end
|
||||||
|
i = i + 1
|
||||||
|
if @ticket_ids[ i - 1 ]
|
||||||
|
@tickets_in_table.push App.Ticket.fullLocal( @ticket_ids[ i - 1 ] )
|
||||||
|
|
||||||
|
openTicket = (id,e) =>
|
||||||
|
ticket = App.Ticket.fullLocal(id)
|
||||||
|
@navigate ticket.uiUrl()
|
||||||
|
callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) =>
|
||||||
|
attribute.title = object.title
|
||||||
|
value
|
||||||
|
callbackLinkToTicket = (value, object, attribute, attributes, refObject) =>
|
||||||
|
attribute.link = object.uiUrl()
|
||||||
|
value
|
||||||
|
callbackResetLink = (value, object, attribute, attributes, refObject) =>
|
||||||
|
attribute.link = undefined
|
||||||
|
value
|
||||||
|
callbackUserPopover = (value, object, attribute, attributes, refObject) =>
|
||||||
|
attribute.class = 'user-popover'
|
||||||
|
attribute.data =
|
||||||
|
id: refObject.id
|
||||||
|
value
|
||||||
|
|
||||||
|
new App.ControllerTable(
|
||||||
|
overview: @view.d
|
||||||
|
el: html.find('.table-overview'),
|
||||||
|
model: App.Ticket
|
||||||
|
objects: @tickets_in_table,
|
||||||
|
checkbox: false
|
||||||
|
groupBy: @group_by
|
||||||
|
bindRow:
|
||||||
|
events:
|
||||||
|
'click': openTicket
|
||||||
|
callbackAttributes:
|
||||||
|
customer_id:
|
||||||
|
[ callbackResetLink, callbackUserPopover ]
|
||||||
|
owner_id:
|
||||||
|
[ callbackResetLink, callbackUserPopover ]
|
||||||
|
title:
|
||||||
|
[ callbackLinkToTicket, callbackTicketTitleAdd ]
|
||||||
|
number:
|
||||||
|
[ callbackLinkToTicket, callbackTicketTitleAdd ]
|
||||||
|
)
|
||||||
|
|
||||||
|
@html html
|
||||||
|
|
||||||
|
# show frontend times
|
||||||
|
@frontendTimeUpdate()
|
||||||
|
|
||||||
|
# start user popups
|
||||||
|
@userPopups()
|
||||||
|
|
||||||
|
zoom: (e) =>
|
||||||
|
e.preventDefault()
|
||||||
|
id = $(e.target).parents('[data-id]').data('id')
|
||||||
|
|
||||||
|
@navigate 'ticket/zoom/' + id
|
||||||
|
|
||||||
|
page: (e) =>
|
||||||
|
e.preventDefault()
|
||||||
|
id = $(e.target).data('id')
|
||||||
|
@start_page = id
|
||||||
|
@load()
|
||||||
|
|
|
@ -38,6 +38,11 @@ class App.OrganizationZoom extends App.Controller
|
||||||
organization: organization
|
organization: organization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
new Overviews(
|
||||||
|
el: @el
|
||||||
|
organization: organization
|
||||||
|
)
|
||||||
|
|
||||||
new App.UpdateTastbar(
|
new App.UpdateTastbar(
|
||||||
genericObject: organization
|
genericObject: organization
|
||||||
)
|
)
|
||||||
|
@ -60,6 +65,55 @@ class App.OrganizationZoom extends App.Controller
|
||||||
ui: @
|
ui: @
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Overviews extends App.Controller
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
|
||||||
|
# subscribe and reload data / fetch new data if triggered
|
||||||
|
@subscribeId = App.Organization.full( @organization.id, @render, false, true )
|
||||||
|
|
||||||
|
release: =>
|
||||||
|
App.Organization.unsubscribe(@subscribeId)
|
||||||
|
|
||||||
|
render: (organization) =>
|
||||||
|
|
||||||
|
plugins =
|
||||||
|
main:
|
||||||
|
my_organization:
|
||||||
|
controller: App.DashboardTicketSearch,
|
||||||
|
params:
|
||||||
|
name: 'Tickets of Organization'
|
||||||
|
condition:
|
||||||
|
'tickets.state_id': [ 1,2,3,4,6 ]
|
||||||
|
'tickets.organization_id': organization.id
|
||||||
|
order:
|
||||||
|
by: 'created_at'
|
||||||
|
direction: 'DESC'
|
||||||
|
view:
|
||||||
|
d: [ 'number', 'title', 'customer', 'state', 'priority', 'created_at' ]
|
||||||
|
view_mode_default: 'd'
|
||||||
|
|
||||||
|
for area, plugins of plugins
|
||||||
|
for name, plugin of plugins
|
||||||
|
target = area + '_' + name
|
||||||
|
@el.find('.' + area + '-overviews').append('<div class="" id="' + target + '"></div>')
|
||||||
|
if plugin.controller
|
||||||
|
params = plugin.params || {}
|
||||||
|
params.el = @el.find( '#' + target )
|
||||||
|
new plugin.controller( params )
|
||||||
|
|
||||||
|
dndOptions =
|
||||||
|
handle: 'h2.can-move'
|
||||||
|
placeholder: 'can-move-plcaeholder'
|
||||||
|
tolerance: 'pointer'
|
||||||
|
distance: 15
|
||||||
|
opacity: 0.6
|
||||||
|
forcePlaceholderSize: true
|
||||||
|
|
||||||
|
@el.find( '#sortable' ).sortable( dndOptions )
|
||||||
|
@el.find( '#sortable-sidebar' ).sortable( dndOptions )
|
||||||
|
|
||||||
|
|
||||||
class Widgets extends App.Controller
|
class Widgets extends App.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
|
@ -150,14 +150,6 @@ class App.TicketZoom extends App.Controller
|
||||||
if !@editWidget || _.isEmpty( App.TaskManager.get(@task_key).state )
|
if !@editWidget || _.isEmpty( App.TaskManager.get(@task_key).state )
|
||||||
@editWidget = @Edit()
|
@editWidget = @Edit()
|
||||||
|
|
||||||
# show text module UI
|
|
||||||
if !@isRole('Customer')
|
|
||||||
new App.WidgetTextModule(
|
|
||||||
el: @el.find('textarea')
|
|
||||||
data:
|
|
||||||
ticket: @ticket
|
|
||||||
)
|
|
||||||
|
|
||||||
# scroll to article if given
|
# scroll to article if given
|
||||||
if @article_id && document.getElementById( 'article-' + @article_id )
|
if @article_id && document.getElementById( 'article-' + @article_id )
|
||||||
offset = document.getElementById( 'article-' + @article_id ).offsetTop
|
offset = document.getElementById( 'article-' + @article_id ).offsetTop
|
||||||
|
@ -324,6 +316,8 @@ class Edit extends App.Controller
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
@autosaveStop()
|
@autosaveStop()
|
||||||
|
if @subscribeIdTextModule
|
||||||
|
App.Ticket.unsubscribe(@subscribeIdTextModule)
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
|
|
||||||
|
@ -422,6 +416,19 @@ class Edit extends App.Controller
|
||||||
# enable user popups
|
# enable user popups
|
||||||
@userPopups()
|
@userPopups()
|
||||||
|
|
||||||
|
# show text module UI
|
||||||
|
if !@isRole('Customer')
|
||||||
|
textModule = new App.WidgetTextModule(
|
||||||
|
el: @el.find('textarea')
|
||||||
|
data:
|
||||||
|
ticket: ticket
|
||||||
|
)
|
||||||
|
callback = (ticket) =>
|
||||||
|
textModule.reload(
|
||||||
|
ticket: ticket
|
||||||
|
)
|
||||||
|
@subscribeIdTextModule = ticket.subscribe( callback )
|
||||||
|
|
||||||
autosaveStop: =>
|
autosaveStop: =>
|
||||||
@clearInterval( 'autosave' )
|
@clearInterval( 'autosave' )
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,16 @@ class App.UserZoom extends App.Controller
|
||||||
|
|
||||||
render: (user) =>
|
render: (user) =>
|
||||||
|
|
||||||
|
|
||||||
@html App.view('user_zoom')(
|
@html App.view('user_zoom')(
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
|
|
||||||
|
new Overviews(
|
||||||
|
el: @el
|
||||||
|
user: user
|
||||||
|
)
|
||||||
|
|
||||||
new App.UpdateTastbar(
|
new App.UpdateTastbar(
|
||||||
genericObject: user
|
genericObject: user
|
||||||
)
|
)
|
||||||
|
@ -60,6 +66,74 @@ class App.UserZoom extends App.Controller
|
||||||
ui: @
|
ui: @
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Overviews extends App.Controller
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
|
||||||
|
# subscribe and reload data / fetch new data if triggered
|
||||||
|
@subscribeId = App.User.full( @user.id, @render, false, true )
|
||||||
|
|
||||||
|
release: =>
|
||||||
|
App.User.unsubscribe(@subscribeId)
|
||||||
|
|
||||||
|
render: (user) =>
|
||||||
|
|
||||||
|
plugins = {
|
||||||
|
main: {
|
||||||
|
my_assigned: {
|
||||||
|
controller: App.DashboardTicketSearch,
|
||||||
|
params: {
|
||||||
|
name: 'Tickets of User'
|
||||||
|
condition:
|
||||||
|
'tickets.state_id': [ 1,2,3,4,6 ]
|
||||||
|
'tickets.customer_id': user.id
|
||||||
|
order:
|
||||||
|
by: 'created_at'
|
||||||
|
direction: 'DESC'
|
||||||
|
view:
|
||||||
|
d: [ 'number', 'title', 'state', 'priority', 'created_at' ]
|
||||||
|
view_mode_default: 'd'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if user.organization_id
|
||||||
|
plugins.main.my_organization = {
|
||||||
|
controller: App.DashboardTicketSearch,
|
||||||
|
params: {
|
||||||
|
name: 'Tickets of Organization'
|
||||||
|
condition:
|
||||||
|
'tickets.state_id': [ 1,2,3,4,6 ]
|
||||||
|
'tickets.organization_id': user.organization_id
|
||||||
|
order:
|
||||||
|
by: 'created_at'
|
||||||
|
direction: 'DESC'
|
||||||
|
view:
|
||||||
|
d: [ 'number', 'title', 'customer', 'state', 'priority', 'created_at' ]
|
||||||
|
view_mode_default: 'd'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for area, plugins of plugins
|
||||||
|
for name, plugin of plugins
|
||||||
|
target = area + '_' + name
|
||||||
|
@el.find('.' + area + '-overviews').append('<div class="" id="' + target + '"></div>')
|
||||||
|
if plugin.controller
|
||||||
|
params = plugin.params || {}
|
||||||
|
params.el = @el.find( '#' + target )
|
||||||
|
new plugin.controller( params )
|
||||||
|
|
||||||
|
dndOptions =
|
||||||
|
handle: 'h2.can-move'
|
||||||
|
placeholder: 'can-move-plcaeholder'
|
||||||
|
tolerance: 'pointer'
|
||||||
|
distance: 15
|
||||||
|
opacity: 0.6
|
||||||
|
forcePlaceholderSize: true
|
||||||
|
|
||||||
|
@el.find( '#sortable' ).sortable( dndOptions )
|
||||||
|
@el.find( '#sortable-sidebar' ).sortable( dndOptions )
|
||||||
|
|
||||||
class Widgets extends App.Controller
|
class Widgets extends App.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
|
@ -42,11 +42,15 @@ class App.WidgetOrganization extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
a = =>
|
a = =>
|
||||||
@el.find('textarea').expanding()
|
visible = @el.find('textarea').is(":visible")
|
||||||
@el.find('textarea').on('focus', =>
|
if visible && !@el.find('textarea').expanding('active')
|
||||||
@el.find('textarea').expanding()
|
@el.find('textarea').expanding()
|
||||||
|
@el.find('textarea').on('focus', (e) =>
|
||||||
|
visible = @el.find('textarea').is(":visible")
|
||||||
|
if visible && !@el.find('textarea').expanding('active')
|
||||||
|
@el.find('textarea').expanding()
|
||||||
)
|
)
|
||||||
@delay( a, 80 )
|
@delay( a, 40 )
|
||||||
|
|
||||||
# enable user popups
|
# enable user popups
|
||||||
@userPopups()
|
@userPopups()
|
||||||
|
|
|
@ -14,6 +14,10 @@ class App.WidgetUser extends App.ControllerDrox
|
||||||
|
|
||||||
render: (user) =>
|
render: (user) =>
|
||||||
|
|
||||||
|
# execute callback on render/rerender
|
||||||
|
if @callback
|
||||||
|
@callback(user)
|
||||||
|
|
||||||
# get display data
|
# get display data
|
||||||
userData = []
|
userData = []
|
||||||
for item2 in App.User.configure_attributes
|
for item2 in App.User.configure_attributes
|
||||||
|
@ -72,11 +76,15 @@ class App.WidgetUser extends App.ControllerDrox
|
||||||
)
|
)
|
||||||
|
|
||||||
a = =>
|
a = =>
|
||||||
@el.find('textarea').expanding()
|
visible = @el.find('textarea').is(":visible")
|
||||||
@el.find('textarea').on('focus', =>
|
if visible && !@el.find('textarea').expanding('active')
|
||||||
@el.find('textarea').expanding()
|
@el.find('textarea').expanding()
|
||||||
|
@el.find('textarea').on('focus', (e) =>
|
||||||
|
visible = @el.find('textarea').is(":visible")
|
||||||
|
if visible && !@el.find('textarea').expanding('active')
|
||||||
|
@el.find('textarea').expanding()
|
||||||
)
|
)
|
||||||
@delay( a, 80 )
|
@delay( a, 40 )
|
||||||
|
|
||||||
@userTicketPopups(
|
@userTicketPopups(
|
||||||
selector: '.user-tickets'
|
selector: '.user-tickets'
|
||||||
|
|
|
@ -291,7 +291,7 @@ class App.Model extends Spine.Model
|
||||||
|
|
||||||
# subscribe and render data after local change
|
# subscribe and render data after local change
|
||||||
@bind(
|
@bind(
|
||||||
'refresh change'
|
'change'
|
||||||
(items) =>
|
(items) =>
|
||||||
|
|
||||||
# check if result is array or singel item
|
# check if result is array or singel item
|
||||||
|
@ -301,7 +301,26 @@ class App.Model extends Spine.Model
|
||||||
for item in items
|
for item in items
|
||||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||||
item = App[ @className ]._fillUp( item )
|
item = App[ @className ]._fillUp( item )
|
||||||
callback(item)
|
callback(item, 'change')
|
||||||
|
)
|
||||||
|
|
||||||
|
@changeTable = {}
|
||||||
|
@bind(
|
||||||
|
'refresh'
|
||||||
|
(items) =>
|
||||||
|
|
||||||
|
# check if result is array or singel item
|
||||||
|
if !_.isArray(items)
|
||||||
|
items = [items]
|
||||||
|
|
||||||
|
for item in items
|
||||||
|
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||||
|
|
||||||
|
# only trigger callbacks if object has changed
|
||||||
|
if !@changeTable[key] || @changeTable[key] isnt item.updated_at
|
||||||
|
@changeTable[key] = item.updated_at
|
||||||
|
item = App[ @className ]._fillUp( item )
|
||||||
|
callback(item, 'refresh')
|
||||||
)
|
)
|
||||||
|
|
||||||
# subscribe and render data after server change
|
# subscribe and render data after server change
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
<div class="page-header clearfix">
|
<div class="page-header clearfix">
|
||||||
<div class="page-header-title">
|
<div class="page-header-title">
|
||||||
<h2 class="can-move"><%- @T( @overview.name ) %> <small><a href="#" data-type="settings" class="glyphicon glyphicon-edit"></a></small></h2>
|
<h2 class="can-move"><%- @T( @overview.name ) %> <small><% if @overview.id: %><a href="#" data-type="settings" class="glyphicon glyphicon-edit"></a><% end %></small></h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="page-header-meta">
|
<div class="page-header-meta">
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
<h1></h1>
|
<h1></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ticket-answer">
|
<div class="main-overviews" id="sortable"></div>
|
||||||
<div class="article-view"></div>
|
|
||||||
<div class="edit"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -9,10 +9,7 @@
|
||||||
<h1></h1>
|
<h1></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ticket-answer">
|
<div class="main-overviews" id="sortable"></div>
|
||||||
<div class="article-view"></div>
|
|
||||||
<div class="edit"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -364,7 +364,9 @@ class TicketsController < ApplicationController
|
||||||
tickets = Ticket.search(
|
tickets = Ticket.search(
|
||||||
:limit => params[:limit],
|
:limit => params[:limit],
|
||||||
:query => params[:term],
|
:query => params[:term],
|
||||||
|
:condition => params[:condition],
|
||||||
:current_user => current_user,
|
:current_user => current_user,
|
||||||
|
:detail => params[:detail]
|
||||||
)
|
)
|
||||||
assets = {}
|
assets = {}
|
||||||
ticket_result = []
|
ticket_result = []
|
||||||
|
@ -375,8 +377,9 @@ class TicketsController < ApplicationController
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => {
|
render :json => {
|
||||||
:tickets => ticket_result,
|
:tickets => ticket_result,
|
||||||
:assets => assets,
|
:tickets_count => tickets.count,
|
||||||
|
:assets => assets,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,20 @@ returns
|
||||||
|
|
||||||
result = [ticket_model1, ticket_model2]
|
result = [ticket_model1, ticket_model2]
|
||||||
|
|
||||||
|
|
||||||
|
search tickets
|
||||||
|
|
||||||
|
result = Ticket.search(
|
||||||
|
:current_user => User.find(123),
|
||||||
|
:query => 'search something',
|
||||||
|
:limit => 15,
|
||||||
|
:full => 0
|
||||||
|
)
|
||||||
|
|
||||||
|
returns
|
||||||
|
|
||||||
|
result = [1,3,5,6,7]
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def search (params)
|
def search (params)
|
||||||
|
@ -24,9 +38,13 @@ returns
|
||||||
query = params[:query]
|
query = params[:query]
|
||||||
limit = params[:limit] || 12
|
limit = params[:limit] || 12
|
||||||
current_user = params[:current_user]
|
current_user = params[:current_user]
|
||||||
|
full = false
|
||||||
|
if params[:full] || !params.has_key?(:full)
|
||||||
|
full = true
|
||||||
|
end
|
||||||
|
|
||||||
# try search index backend
|
# try search index backend
|
||||||
if SearchIndexBackend.enabled?
|
if !params[:detail] && SearchIndexBackend.enabled?
|
||||||
query_extention = {}
|
query_extention = {}
|
||||||
query_extention['bool'] = {}
|
query_extention['bool'] = {}
|
||||||
query_extention['bool']['must'] = []
|
query_extention['bool']['must'] = []
|
||||||
|
@ -39,28 +57,31 @@ returns
|
||||||
groups.each {|group|
|
groups.each {|group|
|
||||||
group_condition.push group.name
|
group_condition.push group.name
|
||||||
}
|
}
|
||||||
condition = {
|
access_condition = {
|
||||||
'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" }
|
'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" }
|
||||||
}
|
}
|
||||||
query_extention['bool']['must'].push condition
|
query_extention['bool']['must'].push access_condition
|
||||||
else
|
else
|
||||||
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
||||||
condition = {
|
access_condition = {
|
||||||
'query_string' => { 'default_field' => 'Ticket.customer_id', 'query' => current_user.id }
|
'query_string' => { 'default_field' => 'Ticket.customer_id', 'query' => current_user.id }
|
||||||
}
|
}
|
||||||
# customer_id: XXX
|
# customer_id: XXX
|
||||||
# conditions = [ 'customer_id = ?', current_user.id ]
|
# conditions = [ 'customer_id = ?', current_user.id ]
|
||||||
else
|
else
|
||||||
condition = {
|
access_condition = {
|
||||||
'query_string' => { 'query' => "Ticket.customer_id:#{current_user.id} OR Ticket.organization_id:#{current_user.organization.id}" }
|
'query_string' => { 'query' => "Ticket.customer_id:#{current_user.id} OR Ticket.organization_id:#{current_user.organization.id}" }
|
||||||
}
|
}
|
||||||
# customer_id: XXX OR organization_id: XXX
|
# customer_id: XXX OR organization_id: XXX
|
||||||
# conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ]
|
# conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ]
|
||||||
end
|
end
|
||||||
query_extention['bool']['must'].push condition
|
query_extention['bool']['must'].push access_condition
|
||||||
end
|
end
|
||||||
|
|
||||||
ids = SearchIndexBackend.search( query, limit, 'Ticket', query_extention )
|
ids = SearchIndexBackend.search( query, limit, 'Ticket', query_extention )
|
||||||
|
if !full
|
||||||
|
return ids
|
||||||
|
end
|
||||||
tickets = []
|
tickets = []
|
||||||
ids.each { |id|
|
ids.each { |id|
|
||||||
tickets.push Ticket.lookup( :id => id )
|
tickets.push Ticket.lookup( :id => id )
|
||||||
|
@ -69,38 +90,53 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
# fallback do sql query
|
# fallback do sql query
|
||||||
conditions = []
|
access_condition = []
|
||||||
if current_user.is_role('Agent')
|
if current_user.is_role('Agent')
|
||||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||||
where( 'groups_users.user_id = ?', current_user.id ).
|
where( 'groups_users.user_id = ?', current_user.id ).
|
||||||
where( 'groups.active = ?', true ).
|
where( 'groups.active = ?', true ).
|
||||||
map( &:id )
|
map( &:id )
|
||||||
conditions = [ 'group_id IN (?)', group_ids ]
|
access_condition = [ 'group_id IN (?)', group_ids ]
|
||||||
else
|
else
|
||||||
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
||||||
conditions = [ 'customer_id = ?', current_user.id ]
|
access_condition = [ 'customer_id = ?', current_user.id ]
|
||||||
else
|
else
|
||||||
conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ]
|
access_condition = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# do query
|
# do query
|
||||||
# - stip out * we already search for *query* -
|
# - stip out * we already search for *query* -
|
||||||
query.gsub! '*', ''
|
if query
|
||||||
tickets_all = Ticket.select('DISTINCT(tickets.id)').
|
query.gsub! '*', ''
|
||||||
where(conditions).
|
tickets_all = Ticket.select('DISTINCT(tickets.id)').
|
||||||
where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ).
|
where(access_condition).
|
||||||
joins(:articles).
|
where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ).
|
||||||
order('`tickets`.`created_at` DESC').
|
joins(:articles).
|
||||||
limit(limit)
|
order('`tickets`.`created_at` DESC').
|
||||||
|
limit(limit)
|
||||||
# build result list
|
else
|
||||||
tickets = []
|
tickets_all = Ticket.select('DISTINCT(tickets.id)').
|
||||||
tickets_all.each do |ticket|
|
where(access_condition).
|
||||||
tickets.push Ticket.lookup( :id => ticket.id )
|
where(params[:condition]).
|
||||||
|
order('`tickets`.`created_at` DESC').
|
||||||
|
limit(limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
tickets
|
# build result list
|
||||||
|
if !full
|
||||||
|
ids = []
|
||||||
|
tickets_all.each { |ticket|
|
||||||
|
ids.push ticket.id
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
end
|
||||||
|
|
||||||
|
tickets = []
|
||||||
|
tickets_all.each { |ticket|
|
||||||
|
tickets.push Ticket.lookup( :id => ticket.id )
|
||||||
|
}
|
||||||
|
return tickets
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'browser_test_helper'
|
require 'browser_test_helper'
|
||||||
|
|
||||||
class TextModuleTest < TestCase
|
class AgentTicketActionLevel5Test < TestCase
|
||||||
def test_I
|
def test_I
|
||||||
random = 'text_module_test_' + rand(999999).to_s
|
random = 'text_module_test_' + rand(999999).to_s
|
||||||
random2 = 'text_module_test_' + rand(999999).to_s
|
random2 = 'text_module_test_' + rand(999999).to_s
|
||||||
|
@ -155,6 +155,13 @@ class TextModuleTest < TestCase
|
||||||
def test_II
|
def test_II
|
||||||
random = 'text_II_module_test_' + rand(999999).to_s
|
random = 'text_II_module_test_' + rand(999999).to_s
|
||||||
|
|
||||||
|
user_rand = rand(999999).to_s
|
||||||
|
login = 'agent-text-module-' + user_rand
|
||||||
|
firstname = 'Text' + user_rand
|
||||||
|
lastname = 'Module' + user_rand
|
||||||
|
email = 'agent-text-module-' + user_rand + '@example.com'
|
||||||
|
password = 'agentpw'
|
||||||
|
|
||||||
# user
|
# user
|
||||||
tests = [
|
tests = [
|
||||||
{
|
{
|
||||||
|
@ -258,6 +265,22 @@ class TextModuleTest < TestCase
|
||||||
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# create user
|
||||||
|
{
|
||||||
|
:name => 'create user',
|
||||||
|
:action => [
|
||||||
|
{
|
||||||
|
:where => :instance1,
|
||||||
|
:execute => 'create_user',
|
||||||
|
:login => login,
|
||||||
|
:firstname => firstname,
|
||||||
|
:lastname => lastname,
|
||||||
|
:email => email,
|
||||||
|
:password => password,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
:name => 'check if text module exists in instance2, for ready to use',
|
:name => 'check if text module exists in instance2, for ready to use',
|
||||||
:action => [
|
:action => [
|
||||||
|
@ -365,6 +388,12 @@ class TextModuleTest < TestCase
|
||||||
:name => 'verify zoom',
|
:name => 'verify zoom',
|
||||||
:action => [
|
:action => [
|
||||||
|
|
||||||
|
{
|
||||||
|
:where => :instance1,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => 'a[href="#manage"]',
|
||||||
|
},
|
||||||
|
|
||||||
# create ticket
|
# create ticket
|
||||||
{
|
{
|
||||||
:where => :instance2,
|
:where => :instance2,
|
||||||
|
@ -406,7 +435,7 @@ class TextModuleTest < TestCase
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'wait',
|
||||||
:value => 1,
|
:value => 0.5,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:where => :instance2,
|
:where => :instance2,
|
||||||
|
@ -433,6 +462,113 @@ class TextModuleTest < TestCase
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:name => 'change customer',
|
||||||
|
:action => [
|
||||||
|
|
||||||
|
{
|
||||||
|
:where => :instance1,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => 'a[href="#manage"]',
|
||||||
|
},
|
||||||
|
|
||||||
|
# create ticket
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => '.active .action button',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => '.active .action [data-type="customer"]',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'set',
|
||||||
|
:css => '#form-customer input[name="customer_id_autocompletion"]',
|
||||||
|
:value => firstname,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'sendkey',
|
||||||
|
:css => '#form-customer input[name="customer_id_autocompletion"]',
|
||||||
|
:value => :arrow_down,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'sendkey',
|
||||||
|
:css => '#form-customer input[name="customer_id_autocompletion"]',
|
||||||
|
:value => :tab,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => '.modal-content [type="submit"]',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'set',
|
||||||
|
:css => '.active textarea[name=body]',
|
||||||
|
:value => '::' + random,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 0.2,
|
||||||
|
},
|
||||||
|
# {
|
||||||
|
# :where => :instance2,
|
||||||
|
# :execute => 'match',
|
||||||
|
# :css => 'body',
|
||||||
|
# :value => random,
|
||||||
|
# :match_result => true,
|
||||||
|
# },
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'click',
|
||||||
|
:css => '.-sew-list-item.selected',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:where => :instance2,
|
||||||
|
:execute => 'match',
|
||||||
|
:css => '.active textarea[name=body]',
|
||||||
|
:value => 'some content ' + lastname,
|
||||||
|
:match_result => true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
browser_double_test(tests)
|
browser_double_test(tests)
|
||||||
end
|
end
|
|
@ -20,54 +20,12 @@ class ManageTest < TestCase
|
||||||
:css => 'a[href="#manage/users"]',
|
:css => 'a[href="#manage/users"]',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'create_user',
|
||||||
:value => 2,
|
:login => 'some login' + random,
|
||||||
},
|
:firstname => 'Manage Firstname' + random,
|
||||||
{
|
:lastname => 'Manage Lastname' + random,
|
||||||
:execute => 'click',
|
:email => user_email,
|
||||||
:css => 'a[data-type="new"]',
|
:password => 'some-pass',
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'wait',
|
|
||||||
:value => 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name=login]',
|
|
||||||
:value => 'some login' + random,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name="firstname"]',
|
|
||||||
:value => 'Manage Firstname' + random,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name="lastname"]',
|
|
||||||
:value => 'Manage Lastname' + random,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name="email"]',
|
|
||||||
:value => user_email,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name="password"]',
|
|
||||||
:value => 'some-pass',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'set',
|
|
||||||
:css => '.modal input[name="password_confirm"]',
|
|
||||||
:value => 'some-pass',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'click',
|
|
||||||
:css => '.modal input[name="role_ids"][value="3"]',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
:execute => 'click',
|
|
||||||
:css => '.modal button.submit',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'watch_for',
|
:execute => 'watch_for',
|
||||||
|
@ -144,13 +102,17 @@ class ManageTest < TestCase
|
||||||
:area => 'body',
|
:area => 'body',
|
||||||
:value => random,
|
:value => random,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 3,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
:execute => 'click',
|
:execute => 'click',
|
||||||
:css => '.table-overview tr:last-child td',
|
:css => '.table-overview tr:last-child td',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'wait',
|
||||||
:value => 2,
|
:value => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'set',
|
:execute => 'set',
|
||||||
|
@ -168,12 +130,12 @@ class ManageTest < TestCase
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'watch_for',
|
:execute => 'watch_for',
|
||||||
:area => 'body',
|
:area => 'body table',
|
||||||
:value => 'some sla update ' + random,
|
:value => 'some sla update ' + random,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'wait',
|
||||||
:value => 1,
|
:value => 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'click',
|
:execute => 'click',
|
||||||
|
@ -189,7 +151,7 @@ class ManageTest < TestCase
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'wait',
|
||||||
:value => 2,
|
:value => 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'match',
|
:execute => 'match',
|
||||||
|
|
|
@ -256,6 +256,44 @@ class TestCase < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
|
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
|
||||||
return
|
return
|
||||||
|
elsif action[:execute] == 'create_user'
|
||||||
|
|
||||||
|
instance.find_element( { :css => 'a[href="#manage"]' } ).click
|
||||||
|
instance.find_element( { :css => 'a[href="#manage/users"]' } ).click
|
||||||
|
sleep 2
|
||||||
|
instance.find_element( { :css => 'a[data-type="new"]' } ).click
|
||||||
|
sleep 2
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=login]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:login] )
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=firstname]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:firstname] )
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=lastname]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:lastname] )
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=email]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:email] )
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=password]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:password] )
|
||||||
|
element = instance.find_element( { :css => '.modal input[name=password_confirm]' } )
|
||||||
|
element.clear
|
||||||
|
element.send_keys( action[:password] )
|
||||||
|
instance.find_element( { :css => '.modal input[name="role_ids"][value="3"]' } ).click
|
||||||
|
instance.find_element( { :css => '.modal button.submit' } ).click
|
||||||
|
(1..14).each {|loop|
|
||||||
|
element = instance.find_element( { :css => 'body' } )
|
||||||
|
text = element.text
|
||||||
|
if text =~ /#{Regexp.quote(action[:lastname])}/
|
||||||
|
assert( true, "(#{test[:name]}) user created" )
|
||||||
|
return
|
||||||
|
end
|
||||||
|
sleep 0.5
|
||||||
|
}
|
||||||
|
assert( true, "(#{test[:name]}) user creation failed" )
|
||||||
|
return
|
||||||
elsif action[:execute] == 'create_ticket'
|
elsif action[:execute] == 'create_ticket'
|
||||||
instance.find_element( { :css => 'a[href="#new"]' } ).click
|
instance.find_element( { :css => 'a[href="#new"]' } ).click
|
||||||
instance.find_element( { :css => 'a[href="#ticket/create/call_inbound"]' } ).click
|
instance.find_element( { :css => 'a[href="#ticket/create/call_inbound"]' } ).click
|
||||||
|
|
Loading…
Reference in a new issue