program_details_view.js 2.21 KB
Newer Older
1
(function(define) {
2 3 4 5 6 7
    'use strict';

    define(['backbone',
            'jquery',
            'underscore',
            'gettext',
8
            'edx-ui-toolkit/js/utils/html-utils',
9
            'js/learner_dashboard/collections/course_card_collection',
10
            'js/learner_dashboard/views/program_header_view',
11 12
            'js/learner_dashboard/views/collection_list_view',
            'js/learner_dashboard/views/course_card_view',
13 14
            'text!../../../templates/learner_dashboard/program_details_view.underscore'
           ],
15 16 17 18 19 20
         function(
             Backbone,
             $,
             _,
             gettext,
             HtmlUtils,
21
             CourseCardCollection,
22 23 24 25 26
             HeaderView,
             CollectionListView,
             CourseCardView,
             pageTpl
         ) {
27 28
             return Backbone.View.extend({
                 el: '.js-program-details-wrapper',
29

30
                 tpl: HtmlUtils.template(pageTpl),
31

32 33 34 35
                 initialize: function(options) {
                     this.options = options;
                     this.programModel = new Backbone.Model(this.options.programData);
                     this.courseCardCollection = new CourseCardCollection(
36 37
                        this.programModel.get('course_codes')
                    );
38 39
                     this.render();
                 },
40

41 42 43 44
                 render: function() {
                     HtmlUtils.setHtml(this.$el, this.tpl());
                     this.postRender();
                 },
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
                 postRender: function() {
                     this.headerView = new HeaderView({
                         model: new Backbone.Model(this.options)
                     });
                     new CollectionListView({
                         el: '.js-course-list',
                         childView: CourseCardView,
                         collection: this.courseCardCollection,
                         context: this.options,
                         titleContext: {
                             el: 'h2',
                             title: 'Course List'
                         }
                     }).render();
                 }
             });
         }
63 64
    );
}).call(this, define || RequireJS.define);