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([ ...@@ -4,14 +4,16 @@ define([
'backbone.super', 'backbone.super',
'pages/course_list_page', 'pages/course_list_page',
'pages/course_detail_page', 'pages/course_detail_page',
'pages/course_create_page' 'pages/course_create_page',
'pages/course_edit_page'
], ],
function (Backbone, function (Backbone,
BackboneRouteFilter, BackboneRouteFilter,
BackboneSuper, BackboneSuper,
CourseListPage, CourseListPage,
CourseDetailPage, CourseDetailPage,
CourseCreatePage) { CourseCreatePage,
CourseEditPage) {
'use strict'; 'use strict';
return Backbone.Router.extend({ return Backbone.Router.extend({
...@@ -47,6 +49,8 @@ define([ ...@@ -47,6 +49,8 @@ define([
// Custom routes, requiring RegExp or other complex placeholders, should be defined here // 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 + '(\/)?$'), 'show');
this.route(new RegExp('^' + courseIdRegex.source + '/edit(\/)?$'), 'edit');
}, },
/** /**
...@@ -105,6 +109,12 @@ define([ ...@@ -105,6 +109,12 @@ define([
var page = new CourseCreatePage(); var page = new CourseCreatePage();
this.currentView = page; this.currentView = page;
this.$el.html(page.el); 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([ ...@@ -49,6 +49,9 @@ define([
// Render the complete view // Render the complete view
this.$el.html($html); this.$el.html($html);
// Activate the tooltips
this.$el.find('[data-toggle="tooltip"]').tooltip();
return this; 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