Last active
December 10, 2015 22:49
-
-
Save mattd/4505087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'marionette', | |
'vent', | |
'views/layouts/manage/groups', | |
'views/group/collection', | |
'views/learner/collection', | |
'collections/api/group', | |
'collections/api/learner' | |
], function ( | |
Marionette, | |
vent, | |
ManageGroupsLayout, | |
GroupCollectionView, | |
LearnerCollectionView, | |
GroupCollection, | |
LearnerCollection | |
) { | |
"use strict"; | |
return Marionette.Controller.extend({ | |
initialize : function (options) { | |
this.moduleLayout = options.moduleLayout; | |
this.groupsLayout = new ManageGroupsLayout(); | |
}, | |
showGroups : function (selectedGroupId) { | |
var collection = new GroupCollection([], { | |
selected : selectedGroupId | |
}); | |
this.moduleLayout.content.show(this.groupsLayout); | |
this.groupsLayout.groups.show( | |
new GroupCollectionView({ | |
collection: collection | |
}) | |
); | |
collection.fetch(); | |
}, | |
showLearners: function (groupId) { | |
var collection = new LearnerCollection({groupId: groupId}); | |
// Handle direct linking from another hash. | |
if (this.groupsLayout.isClosed) { | |
this.groupsLayout.render(); | |
} | |
// Handle fresh page load. | |
if (!this.groupsLayout.groups.currentView) { | |
this.showGroups(groupId); | |
} | |
this.groupsLayout.learners.show( | |
new LearnerCollectionView({ | |
collection: collection | |
}) | |
); | |
collection.fetch(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment