Improved loading assets.
This commit is contained in:
parent
e01873b590
commit
8f744e2856
14 changed files with 58 additions and 44 deletions
|
@ -32,8 +32,8 @@ class App.DashboardActivityStream extends App.Controller
|
|||
load: (data) =>
|
||||
items = data.activity_stream
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@render(items)
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class App.DashboardRecentViewed extends App.Controller
|
|||
success: (data, status, xhr) =>
|
||||
@items = data.recent_viewed
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@render()
|
||||
)
|
||||
|
|
|
@ -38,18 +38,16 @@ class App.DashboardTicket extends App.Controller
|
|||
}
|
||||
processData: true,
|
||||
success: (data) =>
|
||||
data.ajax = true
|
||||
@load(data)
|
||||
@load( data, true )
|
||||
)
|
||||
|
||||
load: (data) =>
|
||||
load: (data, ajax = false) =>
|
||||
|
||||
if data.ajax
|
||||
data.ajax = false
|
||||
if ajax
|
||||
App.Store.write( @key, data )
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# get meta data
|
||||
App.Overview.refresh( data.overview, options: { clear: true } )
|
||||
|
|
|
@ -103,8 +103,8 @@ class App.TicketCreate extends App.Controller
|
|||
# get edit form attributes
|
||||
@edit_form = cache.edit_form
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', cache.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( cache.assets )
|
||||
|
||||
@render()
|
||||
else
|
||||
|
@ -124,8 +124,8 @@ class App.TicketCreate extends App.Controller
|
|||
# get edit form attributes
|
||||
@edit_form = data.edit_form
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# split ticket
|
||||
if data.split && data.split.ticket_id && data.split.article_id
|
||||
|
|
|
@ -13,8 +13,8 @@ class App.TicketMerge extends App.ControllerModal
|
|||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@ticket_ids_by_customer = data.ticket_ids_by_customer
|
||||
@ticket_ids_recent_viewed = data.ticket_ids_recent_viewed
|
||||
|
|
|
@ -29,8 +29,8 @@ class Index extends App.ControllerContent
|
|||
# get edit form attributes
|
||||
@edit_form = cache.edit_form
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', cache.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( cache.assets )
|
||||
|
||||
@render()
|
||||
else
|
||||
|
@ -47,8 +47,8 @@ class Index extends App.ControllerContent
|
|||
# get edit form attributes
|
||||
@edit_form = data.edit_form
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@render()
|
||||
)
|
||||
|
|
|
@ -104,8 +104,8 @@ class App.Navigation extends App.Controller
|
|||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@result = data.result
|
||||
for area in @result
|
||||
|
@ -303,8 +303,8 @@ class App.Navigation extends App.Controller
|
|||
|
||||
items = data.recent_viewed
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# remove old views
|
||||
NavBarRight = @Config.get( 'NavBarRight' ) || {}
|
||||
|
|
|
@ -27,8 +27,8 @@ class Index extends App.ControllerContent
|
|||
|
||||
render: (data) ->
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# fill users
|
||||
for session in data.sessions
|
||||
|
|
|
@ -12,8 +12,8 @@ class App.TicketHistory extends App.GenericHistory
|
|||
url: @apiPath + '/ticket_history/' + @ticket_id,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# render page
|
||||
@render(data.history)
|
||||
|
|
|
@ -91,8 +91,8 @@ class Table extends App.ControllerContent
|
|||
data.ajax = false
|
||||
App.Store.write( @key, data )
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# get meta data
|
||||
@overview = data.overview
|
||||
|
|
|
@ -115,8 +115,8 @@ class App.TicketZoom extends App.Controller
|
|||
# get signature
|
||||
@signature = data.signature
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# get data
|
||||
@ticket = App.Ticket.retrieve( @ticket_id )
|
||||
|
|
|
@ -12,8 +12,8 @@ class App.UserHistory extends App.GenericHistory
|
|||
url: @apiPath + '/users/history/' + @user_id,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# render page
|
||||
@render(data.history)
|
||||
|
|
|
@ -23,8 +23,8 @@ class App.WidgetLink extends App.ControllerDrox
|
|||
success: (data, status, xhr) =>
|
||||
@links = data.links
|
||||
|
||||
# load collections
|
||||
App.Event.trigger 'loadAssets', data.assets
|
||||
# load assets
|
||||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
@render()
|
||||
|
||||
|
|
|
@ -9,11 +9,21 @@ class App.Collection
|
|||
_instance ?= new _collectionSingleton
|
||||
_instance.load( args )
|
||||
|
||||
@loadAssets: ( args ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _collectionSingleton
|
||||
_instance.loadAssets( args )
|
||||
|
||||
@reset: ( args ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _collectionSingleton
|
||||
_instance.reset( args )
|
||||
|
||||
@resetCollection: ( args ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _collectionSingleton
|
||||
_instance.resetCollection( args )
|
||||
|
||||
class _collectionSingleton extends Spine.Module
|
||||
@include App.LogInclude
|
||||
|
||||
|
@ -25,9 +35,7 @@ class _collectionSingleton extends Spine.Module
|
|||
@log 'error', 'loadAssets:trigger, got no data, cant load assets'
|
||||
return
|
||||
|
||||
for type, collections of data
|
||||
@log 'debug', 'loadCollection:trigger', type, collections
|
||||
@load( localStorage: data.localStorage, type: type, data: collections )
|
||||
@loadAssets( data )
|
||||
|
||||
# add trigger - bind new events
|
||||
App.Event.bind 'resetCollection', (data) =>
|
||||
|
@ -35,10 +43,7 @@ class _collectionSingleton extends Spine.Module
|
|||
@log 'error', 'resetCollection:trigger, got no data, cant for collections'
|
||||
return
|
||||
|
||||
# load collections
|
||||
for type, collection of data
|
||||
@log 'debug', 'resetCollection:trigger', type, collection
|
||||
@reset( localStorage: data.localStorage, type: type, data: collection )
|
||||
@resetCollections( data )
|
||||
|
||||
# find collections to load
|
||||
@_loadObjectsFromLocalStore()
|
||||
|
@ -55,6 +60,12 @@ class _collectionSingleton extends Spine.Module
|
|||
@log 'debug', 'load INIT', data
|
||||
@load( data )
|
||||
|
||||
resetCollections: (data) ->
|
||||
# load assets
|
||||
for type, collection of data
|
||||
@log 'debug', 'resetCollection:trigger', type, collection
|
||||
@reset( localStorage: data.localStorage, type: type, data: collection )
|
||||
|
||||
reset: (params) ->
|
||||
if !App[ params.type ]
|
||||
@log 'error', 'reset', 'no such collection', params
|
||||
|
@ -72,6 +83,11 @@ class _collectionSingleton extends Spine.Module
|
|||
for object in params.data
|
||||
@localStore( params.type, object )
|
||||
|
||||
loadAssets: (assets) ->
|
||||
@log 'debug', 'loadAssets', assets
|
||||
for type, collections of assets
|
||||
@load( localStorage: false, type: type, data: collections )
|
||||
|
||||
load: (params) ->
|
||||
@log 'debug', 'load', params
|
||||
|
||||
|
|
Loading…
Reference in a new issue