Skip to content

Instantly share code, notes, and snippets.

@uris77
Created September 4, 2013 20:36
Show Gist options
  • Save uris77/6442516 to your computer and use it in GitHub Desktop.
Save uris77/6442516 to your computer and use it in GitHub Desktop.
class List.Controller extends App.Controllers.Base
initialize: (options) ->
@searchModel = options.searchModel
@searchModel.on "change:sortField", @fetchAttendees
@searchModel.on "change:queryString", @fetchAttendees
@searchModel.on "change:group", @fetchAttendees
@fetchAttendees()
@layout = @getLayout()
@show @layout
attendeeRoles = App.request "attendee:eventRoles"
App.execute "when:fetched", attendeeRoles, =>
@showSearchBar attendeeRoles
@showTopPanel attendeeRoles
getListView: (attendees, searchModel) ->
new App.AttendeeGeneralList.Views.AttendeesListView
collection: attendees
searchModel: searchModel
showTopPanel: (attendeeRoles) ->
new App.AttendeeGeneralList.TopPanel.Controller
region: @layout.topPanelRegion
modalRegion: @layout.modalRegion
attendeeRoles: attendeeRoles
showSearchBar: (attendeeRoles) ->
new App.AttendeeGeneralList.SearchBar.Controller
region: @layout.searchPanelRegion
searchModel: @searchModel
attendeeRoles: attendeeRoles
getAttendees: (options) ->
App.request "attendees:fetchAll", options
fetchAttendees: =>
@attendees = App.request "attendees:fetchAll", @searchModel
App.execute "when:fetched", @attendees, =>
@updateAttendeeList @attendees
updateAttendeeList: (attendees) ->
listView = @getListView attendees, @searchModel
@layout.attendeeListRegion.show listView
getLayout: ->
new App.AttendeeGeneralList.Views.Layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment