Commit 596685ce by Clinton Blackburn

Added course edit view

XCOM-520
parent 53a8b55b
define([
'models/course_model',
'pages/page',
'views/course_create_edit_view'
],
function (Course,
Page,
CourseCreateEditView) {
'use strict';
return Page.extend({
title: function () {
return this.model.get('name') + ' - ' + gettext('Edit Course');
},
initialize: function (options) {
this.model = Course.findOrCreate({id: options.id});
this.view = new CourseCreateEditView({
editing: true,
model: this.model
});
this.listenTo(this.model, 'change sync', this.render);
this.model.fetch({
data: {include_products: true}
});
}
});
}
);
......@@ -4,14 +4,16 @@ define([
'backbone.super',
'pages/course_list_page',
'pages/course_detail_page',
'pages/course_create_page'
'pages/course_create_page',
'pages/course_edit_page'
],
function (Backbone,
BackboneRouteFilter,
BackboneSuper,
CourseListPage,
CourseDetailPage,
CourseCreatePage) {
CourseCreatePage,
CourseEditPage) {
'use strict';
return Backbone.Router.extend({
......@@ -47,6 +49,8 @@ define([
// Custom routes, requiring RegExp or other complex placeholders, should be defined here
this.route(new RegExp('^' + courseIdRegex.source + '(\/)?$'), 'show');
this.route(new RegExp('^' + courseIdRegex.source + '/edit(\/)?$'), 'edit');
},
/**
......@@ -105,6 +109,12 @@ define([
var page = new CourseCreatePage();
this.currentView = page;
this.$el.html(page.el);
},
edit: function (id) {
var page = new CourseEditPage({id: id});
this.currentView = page;
$('#app').html(page.el);
}
});
}
......
......@@ -49,6 +49,9 @@ define([
// Render the complete view
this.$el.html($html);
// Activate the tooltips
this.$el.find('[data-toggle="tooltip"]').tooltip();
return this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment