Skip to content

Instantly share code, notes, and snippets.

@t2k
Last active August 29, 2015 14:09
Show Gist options
  • Save t2k/762d37c61fb7ab4b62cc to your computer and use it in GitHub Desktop.
Save t2k/762d37c61fb7ab4b62cc to your computer and use it in GitHub Desktop.
#AMD MODULE
define ["msgbus", "apps/lp/list/views", "controller/_base" ], (msgBus, Views, AppController) ->
class Controller extends AppController
initialize:->
@lpEntities = msgBus.reqres.request "lp:entities"
heatmaps = msgBus.reqres.request "lpheatmap:entities"
@layout = @getLayoutView()
@listenTo @layout, "show", =>
@heatMapRegion heatmaps
@titleRegion()
@panelRegion()
@lpRegion()
@show @layout,
loading:
entities: [@lpEntities, heatmaps]
newRegion: ->
msgBus.commands.execute "new:lp", @layout.newRegion
newSimpleRegion: ->
msgBus.commands.execute "new:lpsimple", @layout.newRegion
panelRegion:->
view = @getPanelView()
@listenTo view, "new:lp:button:clicked", =>
@newRegion()
@listenTo view, "new:lpsimple:button:clicked", =>
@newSimpleRegion()
# filters
@listenTo view, "filter:date", (date)->
msgBus.reqres.request "lp:filter:date", date
@listenTo view, "filter:id", (id)->
msgBus.reqres.request "lp:filter:id", id
@listenTo view, "filter:port", (port)->
msgBus.reqres.request "lp:filter:port", port
@listenTo view, "filter:type", (type)->
msgBus.reqres.request "lp:filter:type", type
@layout.panelRegion.show view
heatMapRegion: (coll)->
view = @getHeatMapView coll
@listenTo view, "filter:date", (date)->
msgBus.reqres.request "lp:filter:date", date
@layout.heatMapRegion.show view
titleRegion:->
view = @getTitleView()
@layout.titleRegion.show view
lpRegion: ->
lpView = new Views.LPList
collection: @lpEntities
@listenTo lpView, "childview:lp:item:clicked", (child, args) ->
msgBus.events.trigger "lp:item:clicked", args.model
@listenTo lpView, "scroll:more:lpitems", ->
msgBus.reqres.request "lp:fetch:more"
@layout.listRegion.show lpView
getPanelView: ->
new Views.Panel
getTitleView: ->
new Views.Title
getLayoutView: ->
new Views.LayoutView
getHeatMapView: (coll)->
new Views.HeatMapView
collection: coll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment