Removed obsolet code. Fixed edit overview.
This commit is contained in:
parent
aa57b72fba
commit
294c131438
4 changed files with 60 additions and 114 deletions
|
@ -75,10 +75,8 @@ class App.TicketOverview extends App.Controller
|
||||||
|
|
||||||
class Table extends App.Controller
|
class Table extends App.Controller
|
||||||
events:
|
events:
|
||||||
'click [data-type=edit]': 'zoom'
|
|
||||||
'click [data-type=settings]': 'settings'
|
'click [data-type=settings]': 'settings'
|
||||||
'click [data-type=viewmode]': 'viewmode'
|
'click [data-type=viewmode]': 'viewmode'
|
||||||
'click [data-type=page]': 'page'
|
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
@ -87,7 +85,7 @@ class Table extends App.Controller
|
||||||
|
|
||||||
# rebuild ticket overview data
|
# rebuild ticket overview data
|
||||||
@bind 'ticket_overview_rebuild', (data) =>
|
@bind 'ticket_overview_rebuild', (data) =>
|
||||||
console.log('EVENT ticket_overview_rebuild', @view, data.view)
|
#console.log('EVENT ticket_overview_rebuild', @view, data.view)
|
||||||
|
|
||||||
# remeber bulk attributes
|
# remeber bulk attributes
|
||||||
@bulk = data.bulk
|
@bulk = data.bulk
|
||||||
|
@ -99,6 +97,9 @@ class Table extends App.Controller
|
||||||
if @view is data.view
|
if @view is data.view
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
|
# force fetch ticket overview
|
||||||
|
@bind 'ticket_overview_fetch_force', =>
|
||||||
|
@fetch()
|
||||||
|
|
||||||
update: (params) =>
|
update: (params) =>
|
||||||
for key, value of params
|
for key, value of params
|
||||||
|
@ -107,13 +108,19 @@ class Table extends App.Controller
|
||||||
@view_mode = localStorage.getItem( "mode:#{@view}" ) || 's'
|
@view_mode = localStorage.getItem( "mode:#{@view}" ) || 's'
|
||||||
@log 'notice', 'view:', @view, @view_mode
|
@log 'notice', 'view:', @view, @view_mode
|
||||||
|
|
||||||
@render()
|
return if !@view
|
||||||
|
|
||||||
fetch: (force) =>
|
# fetch inital data
|
||||||
|
if !@cache || !@cache[@view]
|
||||||
|
@fetch()
|
||||||
|
else
|
||||||
|
@render()
|
||||||
|
|
||||||
|
fetch: =>
|
||||||
|
|
||||||
# init fetch via ajax, all other updates on time via websockets
|
# init fetch via ajax, all other updates on time via websockets
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'ticket_overview_' + @key
|
id: 'ticket_overview_' + @view + '_' + @view_mode
|
||||||
type: 'GET'
|
type: 'GET'
|
||||||
url: @apiPath + '/ticket_overviews'
|
url: @apiPath + '/ticket_overviews'
|
||||||
data:
|
data:
|
||||||
|
@ -140,8 +147,8 @@ class Table extends App.Controller
|
||||||
return data
|
return data
|
||||||
false
|
false
|
||||||
|
|
||||||
render: ->
|
render: =>
|
||||||
console.log('RENDER', @cache, @view)
|
#console.log('RENDER', @cache, @view)
|
||||||
return if !@cache
|
return if !@cache
|
||||||
return if !@cache[@view]
|
return if !@cache[@view]
|
||||||
|
|
||||||
|
@ -150,7 +157,6 @@ class Table extends App.Controller
|
||||||
ticket_ids = @cache[@view].ticket_ids
|
ticket_ids = @cache[@view].ticket_ids
|
||||||
|
|
||||||
# get meta data
|
# get meta data
|
||||||
overview = @cache[@view].overview
|
|
||||||
App.Overview.refresh( overview, { clear: true } )
|
App.Overview.refresh( overview, { clear: true } )
|
||||||
|
|
||||||
# get ticket list
|
# get ticket list
|
||||||
|
@ -166,7 +172,7 @@ class Table extends App.Controller
|
||||||
@selected = @bulkGetSelected()
|
@selected = @bulkGetSelected()
|
||||||
|
|
||||||
# set page title
|
# set page title
|
||||||
overview = App.Overview.find( overview.id )
|
@overview = App.Overview.find( overview.id )
|
||||||
|
|
||||||
# render init page
|
# render init page
|
||||||
checkbox = true
|
checkbox = true
|
||||||
|
@ -189,14 +195,12 @@ class Table extends App.Controller
|
||||||
if @isRole('Customer')
|
if @isRole('Customer')
|
||||||
view_modes = []
|
view_modes = []
|
||||||
html = App.view('agent_ticket_view/content')(
|
html = App.view('agent_ticket_view/content')(
|
||||||
overview: overview
|
overview: @overview
|
||||||
view_modes: view_modes
|
view_modes: view_modes
|
||||||
checkbox: checkbox
|
checkbox: checkbox
|
||||||
edit: edit
|
edit: edit
|
||||||
)
|
)
|
||||||
html = $(html)
|
html = $(html)
|
||||||
# html.find('li').removeClass('active')
|
|
||||||
# html.find("[data-id=\"#{@start_page}\"]").parents('li').addClass('active')
|
|
||||||
|
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
|
@ -204,7 +208,7 @@ class Table extends App.Controller
|
||||||
table = ''
|
table = ''
|
||||||
if @view_mode is 'm'
|
if @view_mode is 'm'
|
||||||
table = App.view('agent_ticket_view/detail')(
|
table = App.view('agent_ticket_view/detail')(
|
||||||
overview: overview
|
overview: @overview
|
||||||
objects: ticket_list_show
|
objects: ticket_list_show
|
||||||
checkbox: checkbox
|
checkbox: checkbox
|
||||||
)
|
)
|
||||||
|
@ -227,7 +231,7 @@ class Table extends App.Controller
|
||||||
controller: 'TicketZoom'
|
controller: 'TicketZoom'
|
||||||
params:
|
params:
|
||||||
ticket_id: ticket.id
|
ticket_id: ticket.id
|
||||||
overview_id: overview.id
|
overview_id: @overview.id
|
||||||
show: true
|
show: true
|
||||||
)
|
)
|
||||||
@navigate ticket.uiUrl()
|
@navigate ticket.uiUrl()
|
||||||
|
@ -269,12 +273,12 @@ class Table extends App.Controller
|
||||||
value
|
value
|
||||||
|
|
||||||
new App.ControllerTable(
|
new App.ControllerTable(
|
||||||
overview: overview.view.s
|
overview: @overview.view.s
|
||||||
el: @$('.table-overview')
|
el: @$('.table-overview')
|
||||||
model: App.Ticket
|
model: App.Ticket
|
||||||
objects: ticket_list_show
|
objects: ticket_list_show
|
||||||
checkbox: checkbox
|
checkbox: checkbox
|
||||||
groupBy: overview.group_by
|
groupBy: @overview.group_by
|
||||||
bindRow:
|
bindRow:
|
||||||
events:
|
events:
|
||||||
'click': openTicket
|
'click': openTicket
|
||||||
|
@ -353,20 +357,13 @@ class Table extends App.Controller
|
||||||
@$('.js-action-step').removeClass('hide')
|
@$('.js-action-step').removeClass('hide')
|
||||||
@$('.js-confirm-step').addClass('hide')
|
@$('.js-confirm-step').addClass('hide')
|
||||||
|
|
||||||
page: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
id = $(e.target).data('id')
|
|
||||||
@start_page = id
|
|
||||||
@fetch()
|
|
||||||
|
|
||||||
viewmode: (e) =>
|
viewmode: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@start_page = 1
|
@view_mode = $(e.target).data('mode')
|
||||||
mode = $(e.target).data('mode')
|
localStorage.setItem( "mode:#{@view}", @view_mode )
|
||||||
@view_mode = mode
|
|
||||||
localStorage.setItem( "mode:#{@view}", mode )
|
|
||||||
@fetch()
|
@fetch()
|
||||||
@render()
|
#@render()
|
||||||
|
|
||||||
articleTypeFilter = (items) =>
|
articleTypeFilter = (items) =>
|
||||||
for item in items
|
for item in items
|
||||||
|
@ -496,7 +493,7 @@ class Table extends App.Controller
|
||||||
if @bulk_count_index == @bulk_count
|
if @bulk_count_index == @bulk_count
|
||||||
|
|
||||||
# fetch overview data again
|
# fetch overview data again
|
||||||
@fetch()
|
App.Event.trigger('ticket_overview_fetch_force')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@el.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
@el.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
||||||
|
@ -505,31 +502,20 @@ class Table extends App.Controller
|
||||||
msg: App.i18n.translateContent('Bulk-Action executed!')
|
msg: App.i18n.translateContent('Bulk-Action executed!')
|
||||||
}
|
}
|
||||||
|
|
||||||
zoom: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
id = $(e.target).parents('[data-id]').data('id')
|
|
||||||
position = $(e.target).parents('[data-position]').data('position')
|
|
||||||
|
|
||||||
# set last overview
|
|
||||||
@Config.set('LastOverview', @view )
|
|
||||||
@Config.set('LastOverviewPosition', position )
|
|
||||||
@Config.set('LastOverviewTotal', @tickets_count )
|
|
||||||
|
|
||||||
@navigate 'ticket/zoom/' + id + '/nav/true'
|
|
||||||
|
|
||||||
settings: (e) =>
|
settings: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
new App.OverviewSettings(
|
new App.OverviewSettings(
|
||||||
overview_id: @overview.id
|
overview_id: @overview.id
|
||||||
view_mode: @view_mode
|
view_mode: @view_mode
|
||||||
container: @el.closest('.content')
|
container: @el.closest('.content')
|
||||||
|
callback: @render,
|
||||||
)
|
)
|
||||||
|
|
||||||
class App.OverviewSettings extends App.ControllerModal
|
class App.OverviewSettings extends App.ControllerModal
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@overview = App.Overview.find(@overview_id)
|
@overview = App.Overview.find(@overview_id)
|
||||||
|
console.log('overview_id', @overview_id)
|
||||||
@configure_attributes_article = []
|
@configure_attributes_article = []
|
||||||
if @view_mode is 'd'
|
if @view_mode is 'd'
|
||||||
@configure_attributes_article.push({
|
@configure_attributes_article.push({
|
||||||
|
@ -699,26 +685,30 @@ class App.OverviewSettings extends App.ControllerModal
|
||||||
params = @formParam(e.target)
|
params = @formParam(e.target)
|
||||||
|
|
||||||
# check if refetch is needed
|
# check if refetch is needed
|
||||||
@reload_needed = 0
|
@reload_needed = false
|
||||||
if @overview.order.by isnt params.order.by
|
if @overview.order.by isnt params.order.by
|
||||||
@overview.order.by = params.order.by
|
@overview.order.by = params.order.by
|
||||||
@reload_needed = 1
|
@reload_needed = true
|
||||||
|
|
||||||
if @overview.order.direction isnt params.order.direction
|
if @overview.order.direction isnt params.order.direction
|
||||||
@overview.order.direction = params.order.direction
|
@overview.order.direction = params.order.direction
|
||||||
@reload_needed = 1
|
@reload_needed = true
|
||||||
|
|
||||||
for key, value of params.view
|
for key, value of params.view
|
||||||
@overview.view[key] = value
|
@overview.view[key] = value
|
||||||
|
|
||||||
@overview.group_by = params.group_by
|
@overview.group_by = params.group_by
|
||||||
|
|
||||||
|
# rerender overview
|
||||||
|
if !@reload_needed
|
||||||
|
@callback()
|
||||||
|
|
||||||
@overview.save(
|
@overview.save(
|
||||||
done: =>
|
done: =>
|
||||||
|
|
||||||
|
# fetch overview data again
|
||||||
if @reload_needed
|
if @reload_needed
|
||||||
@overview.trigger('local:refetch')
|
App.Event.trigger('ticket_overview_fetch_force')
|
||||||
else
|
|
||||||
@overview.trigger('local:rerender')
|
|
||||||
)
|
)
|
||||||
@hide()
|
@hide()
|
||||||
|
|
||||||
|
@ -732,24 +722,33 @@ class Navbar extends App.Controller
|
||||||
@cache = data
|
@cache = data
|
||||||
@update()
|
@update()
|
||||||
|
|
||||||
|
|
||||||
|
# force fetch ticket overview
|
||||||
|
@bind 'ticket_overview_fetch_force', =>
|
||||||
|
@fetch()
|
||||||
|
|
||||||
# init fetch via ajax
|
# init fetch via ajax
|
||||||
ajaxInit = =>
|
ajaxInit = =>
|
||||||
|
|
||||||
# ignore if already pushed via websockets
|
# ignore if already pushed via websockets
|
||||||
return if @cache
|
return if @cache
|
||||||
#console.log('AJAX CALLL')
|
@fetch()
|
||||||
# init fetch via ajax, all other updates on time via websockets
|
|
||||||
@ajax(
|
|
||||||
id: 'ticket_overviews',
|
|
||||||
type: 'GET',
|
|
||||||
url: @apiPath + '/ticket_overviews',
|
|
||||||
processData: true,
|
|
||||||
success: (data) =>
|
|
||||||
@cache = data
|
|
||||||
@update()
|
|
||||||
)
|
|
||||||
@delay( ajaxInit, 5000 )
|
@delay( ajaxInit, 5000 )
|
||||||
|
|
||||||
|
fetch: =>
|
||||||
|
#console.log('AJAX CALLL')
|
||||||
|
# init fetch via ajax, all other updates on time via websockets
|
||||||
|
@ajax(
|
||||||
|
id: 'ticket_overviews',
|
||||||
|
type: 'GET',
|
||||||
|
url: @apiPath + '/ticket_overviews',
|
||||||
|
processData: true,
|
||||||
|
success: (data) =>
|
||||||
|
@cache = data
|
||||||
|
@update()
|
||||||
|
)
|
||||||
|
|
||||||
active: (state) =>
|
active: (state) =>
|
||||||
@activeState = state
|
@activeState = state
|
||||||
|
|
||||||
|
@ -792,59 +791,6 @@ class Navbar extends App.Controller
|
||||||
items: data
|
items: data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Router extends App.Controller
|
|
||||||
constructor: ->
|
|
||||||
super
|
|
||||||
|
|
||||||
# set new key
|
|
||||||
@key = 'ticket_overview_' + @view
|
|
||||||
|
|
||||||
# get data
|
|
||||||
cache = App.Store.get( @key )
|
|
||||||
if cache
|
|
||||||
@tickets_count = cache.tickets_count
|
|
||||||
@ticket_ids = cache.ticket_ids
|
|
||||||
@redirect()
|
|
||||||
else
|
|
||||||
@ajax(
|
|
||||||
type: 'GET'
|
|
||||||
url: @apiPath + '/ticket_overviews'
|
|
||||||
data:
|
|
||||||
view: @view
|
|
||||||
array: true
|
|
||||||
processData: true
|
|
||||||
success: @load
|
|
||||||
)
|
|
||||||
|
|
||||||
load: (data) =>
|
|
||||||
@ticket_ids = data.ticket_ids
|
|
||||||
@tickets_count = data.tickets_count
|
|
||||||
# App.Store.write( data )
|
|
||||||
@redirect()
|
|
||||||
|
|
||||||
redirect: =>
|
|
||||||
@Config.set('LastOverview', @view )
|
|
||||||
@position = parseInt( @position )
|
|
||||||
@Config.set('LastOverviewPosition', @position )
|
|
||||||
@Config.set('LastOverviewTotal', @tickets_count )
|
|
||||||
|
|
||||||
# redirect
|
|
||||||
if @direction == 'next'
|
|
||||||
if @ticket_ids[ @position ] && @ticket_ids[ @position ]
|
|
||||||
position = @position + 1
|
|
||||||
@Config.set( 'LastOverviewPosition', position )
|
|
||||||
@navigate 'ticket/zoom/' + @ticket_ids[ @position ] + '/nav/true'
|
|
||||||
else
|
|
||||||
@navigate 'ticket/zoom/' + @ticket_ids[ @position - 1 ] + '/nav/true'
|
|
||||||
else
|
|
||||||
if @ticket_ids[ @position - 2 ] && @ticket_ids[ @position - 2 ] + '/nav/true'
|
|
||||||
position = @position - 1
|
|
||||||
@Config.set( 'LastOverviewPosition', position )
|
|
||||||
@navigate 'ticket/zoom/' + @ticket_ids[ @position - 2 ] + '/nav/true'
|
|
||||||
else
|
|
||||||
@navigate 'ticket/zoom/' + @ticket_ids[ @position - 1 ] + '/nav/true'
|
|
||||||
|
|
||||||
class TicketOverviewRouter extends App.ControllerPermanent
|
class TicketOverviewRouter extends App.ControllerPermanent
|
||||||
constructor: (params) ->
|
constructor: (params) ->
|
||||||
super
|
super
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Sessions::Backend::TicketCreate
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 25.seconds } )
|
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 30.seconds } )
|
||||||
|
|
||||||
ticket_create_attributes = self.load
|
ticket_create_attributes = self.load
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Sessions::Backend::TicketOverviewIndex
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 5.seconds } )
|
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 20.seconds } )
|
||||||
|
|
||||||
data = self.load
|
data = self.load
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Sessions::Backend::TicketOverviewList
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 6.seconds } )
|
Sessions::CacheIn.set( self.client_key, true, { :expires_in => 20.seconds } )
|
||||||
|
|
||||||
items = self.load
|
items = self.load
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue