Improve StudentCoursesView

* Add alert explaining when a user joins a course, and links directly to the course
* Add header to My Courses list
* Have My Courses list sorted by classroom creation then course creation
This commit is contained in:
Scott Erickson 2015-11-10 12:08:44 -08:00
parent 4561ff42ce
commit a0212da789
2 changed files with 18 additions and 0 deletions

View file

@ -20,12 +20,28 @@ block content
if view.state === 'unknown_error'
.alert.alert-danger= view.stateMessage
- var justJoinedCourseInstance = view.courseInstances.find(function(ci) { return ci.justJoined; });
if justJoinedCourseInstance
- var course = view.courses.get(justJoinedCourseInstance.get('courseID'));
- var classroom = view.classrooms.get(justJoinedCourseInstance.get('classroomID'));
if course && classroom
.alert.alert-info
span.spr Successfully joined "#{classroom.get('name')}"!
a(href="/courses/#{course.id}/#{justJoinedCourseInstance.id}")
strong Click here to start taking "#{course.get('name')}".
.panel.panel-default
.panel-heading
.panel-title My Courses
.list-group
.list-group-item
.row
.col-sm-3
strong Classroom
.col-sm-3
strong Course
for courseInstance in view.courseInstances.models
- var classroom = view.classrooms.get(courseInstance.get('classroomID'))
- var course = view.courses.get(courseInstance.get('courseID'))

View file

@ -22,6 +22,7 @@ module.exports = class StudentCoursesView extends RootView
constructor: (options) ->
super(options)
@courseInstances = new CocoCollection([], { url: "/db/user/#{me.id}/course_instances", model: CourseInstance})
@courseInstances.comparator = (ci) -> return ci.get('classroomID') + ci.get('courseID')
@supermodel.loadCollection(@courseInstances, 'course_instances')
@classrooms = new CocoCollection([], { url: "/db/classroom", model: Classroom })
@supermodel.loadCollection(@classrooms, 'classrooms', { data: {memberID: me.id} })
@ -85,6 +86,7 @@ module.exports = class StudentCoursesView extends RootView
context: @
success: (data) ->
@courseInstances.add(data)
@courseInstances.get(data._id).justJoined = true
})
$.when(jqxhrs...).done =>
@state = ''