Skip to content

Instantly share code, notes, and snippets.

@mattd
Last active December 10, 2015 22:49
Show Gist options
  • Save mattd/4505087 to your computer and use it in GitHub Desktop.
Save mattd/4505087 to your computer and use it in GitHub Desktop.
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