57 lines
1.8 KiB
CoffeeScript
57 lines
1.8 KiB
CoffeeScript
Backbone = require 'backbone'
|
|
Marionette = require 'backbone.marionette'
|
|
Radio = require 'backbone.radio'
|
|
_ = require 'underscore'
|
|
|
|
ProjectCollectionView = require './projects/projects.collection.view.coffee'
|
|
MapsTreeView = require './mapstreeview'
|
|
LoaderView = require './loaderView.coffee'
|
|
|
|
class RootLayout extends Marionette.View
|
|
|
|
template: require './views/rootLayoutView.hbs'
|
|
|
|
regions:
|
|
projectsListContainer: '.projects-list-container'
|
|
mapsTreeView: '.mapsTreeView'
|
|
|
|
initialize: ( ) ->
|
|
super()
|
|
scope = this
|
|
|
|
Radio.channel('app').on 'project:selected', ( project ) ->
|
|
scope.populateMapsForProject( project )
|
|
|
|
populateMapsForProject: ( project ) ->
|
|
scope = this
|
|
$((scope.getRegion 'mapsTreeView').el).jstree('destroy')
|
|
@getRegion('mapsTreeView').reset()
|
|
|
|
scope.showChildView('mapsTreeView', new LoaderView)
|
|
|
|
SG = Radio.channel('app').request('getShotgun')
|
|
SG.getMaps(project.replace('\n',''))
|
|
.then ( maps ) ->
|
|
regex = ///Coach|Video|FX///gi
|
|
transformedData = _.map maps, ( map ) ->
|
|
map.sg_assets_2 = _.filter map.sg_assets_2, ( item ) ->
|
|
regex.test(item.name)
|
|
map
|
|
mt = new MapsTreeView collection: new Backbone.Collection(transformedData)
|
|
|
|
scope.getRegion('mapsTreeView').reset()
|
|
scope.showChildView 'mapsTreeView', mt
|
|
$((scope.getRegion 'mapsTreeView').el).jstree {
|
|
core:
|
|
themes:
|
|
stripes: true
|
|
plugins: ['contextmenu']
|
|
}
|
|
|
|
onRender: ( ) ->
|
|
pv = new ProjectCollectionView
|
|
@showChildView 'projectsListContainer', pv
|
|
|
|
onAttach: ( ) ->
|
|
|
|
module.exports = RootLayout
|