LMS fixes required to upgrade BackboneJS
This commit is contained in:
committed by
Clinton Blackburn
parent
eed09cc001
commit
762a6657fe
@@ -9,7 +9,11 @@
|
||||
|
||||
function(Backbone, CertificateInvalidation) {
|
||||
return Backbone.Collection.extend({
|
||||
model: CertificateInvalidation
|
||||
model: CertificateInvalidation,
|
||||
|
||||
initialize: function(models, options) {
|
||||
this.url = options.url;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
model: CertificateExceptionModel,
|
||||
|
||||
initialize: function(attrs, options){
|
||||
this.url = options.url;
|
||||
this.generate_certificates_url = options.generate_certificates_url;
|
||||
},
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
notes: ''
|
||||
},
|
||||
|
||||
url: function() {
|
||||
return this.get('url');
|
||||
initialize: function (attributes, options) {
|
||||
this.url = options.url;
|
||||
},
|
||||
|
||||
validate: function(attrs) {
|
||||
|
||||
@@ -35,11 +35,15 @@
|
||||
var notes = this.$("#certificate-invalidation-notes").val();
|
||||
var message = "";
|
||||
|
||||
var certificate_invalidation = new CertificateInvalidationModel({
|
||||
url: this.collection.url,
|
||||
user: user,
|
||||
notes: notes
|
||||
});
|
||||
var certificate_invalidation = new CertificateInvalidationModel(
|
||||
{
|
||||
user: user,
|
||||
notes: notes
|
||||
},
|
||||
{
|
||||
url: this.collection.url
|
||||
}
|
||||
);
|
||||
|
||||
if (this.collection.findWhere({user: user})) {
|
||||
message = gettext("Certificate of <%= user %> has already been invalidated. Please check your spelling and retry."); // jshint ignore:line
|
||||
|
||||
@@ -9,6 +9,7 @@ define([
|
||||
initialize: function(models, options) {
|
||||
PagingCollection.prototype.initialize.call(this);
|
||||
|
||||
this.url = options.url;
|
||||
this.perPage = options.perPage;
|
||||
this.server_api = _.pick(this.server_api, "page", "page_size");
|
||||
if (options.text) {
|
||||
|
||||
@@ -11,7 +11,8 @@ define([
|
||||
return 'note-section-' + _.uniqueId();
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
this.template = _.template(this.options.template);
|
||||
this.className = this.options.className;
|
||||
},
|
||||
@@ -37,8 +38,9 @@ define([
|
||||
},
|
||||
template: _.template('<h3 class="course-title"><%- chapterName %></h3>'),
|
||||
|
||||
initialize: function () {
|
||||
initialize: function (options) {
|
||||
this.children = [];
|
||||
this.options = _.extend({}, options);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
||||
@@ -17,6 +17,7 @@ define([
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
this.template = templateUtils.loadTemplate('note-item');
|
||||
this.logger = NotesLogger.getLogger('note_item', options.debug);
|
||||
this.listenTo(this.model, 'change:is_expanded', this.render);
|
||||
|
||||
@@ -12,8 +12,9 @@ function (gettext, _, Backbone, NoteItemView, PagingHeaderView, PagingFooterView
|
||||
'tabindex': -1
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
initialize: function (options) {
|
||||
this.children = [];
|
||||
this.options = _.extend({}, options);
|
||||
if (this.options.createHeaderFooter) {
|
||||
this.pagingHeaderView = new PagingHeaderView({collection: this.collection});
|
||||
this.pagingFooterView = new PagingFooterView({collection: this.collection, hideWhenOnePage: true});
|
||||
|
||||
@@ -52,6 +52,7 @@ define([
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
_.bindAll(this, 'onBeforeSearchStart', 'onSearch', 'onSearchError');
|
||||
TabView.prototype.initialize.call(this, options);
|
||||
this.searchResults = null;
|
||||
|
||||
@@ -24,6 +24,7 @@ define([
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
TabView.prototype.initialize.call(this, options);
|
||||
_.bindAll(this, 'scrollToTag');
|
||||
this.options.scrollToTag = this.scrollToTag;
|
||||
|
||||
@@ -29,7 +29,7 @@ define([
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
certificate_invalidation = new CertificateInvalidationModel({user: 'test_user'});
|
||||
certificate_invalidation = new CertificateInvalidationModel({user: 'test_user'}, {url: 'test/url/'});
|
||||
certificate_invalidation.set({
|
||||
notes: "Test notes"
|
||||
});
|
||||
@@ -174,7 +174,9 @@ define([
|
||||
it("verifies view is rendered on add/remove to collection", function() {
|
||||
var user = 'test3',
|
||||
notes = 'test3 notes',
|
||||
model = new CertificateInvalidationModel({user: user, notes: notes});
|
||||
model = new CertificateInvalidationModel(
|
||||
{user: user, notes: notes}, {url: certificate_invalidation_url}
|
||||
);
|
||||
|
||||
// Add another model in collection and verify it is rendered
|
||||
view.collection.add(model);
|
||||
|
||||
@@ -654,6 +654,7 @@ define([
|
||||
|
||||
function navigatesToSearch () {
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
Backbone.history.start();
|
||||
Backbone.history.loadUrl('search/query');
|
||||
expect(requests[0].requestBody).toContain('search_string=query');
|
||||
}
|
||||
@@ -687,6 +688,10 @@ define([
|
||||
this.$searchResults = $('.courseware-results');
|
||||
});
|
||||
|
||||
afterEach(function (){
|
||||
Backbone.history.stop();
|
||||
});
|
||||
|
||||
it('shows loading message on search', showsLoadingMessage);
|
||||
it('performs search', performsSearch);
|
||||
it('shows an error message', showsErrorMessage);
|
||||
@@ -715,6 +720,10 @@ define([
|
||||
this.$searchResults = $('#dashboard-search-results');
|
||||
});
|
||||
|
||||
afterEach(function (){
|
||||
Backbone.history.stop();
|
||||
});
|
||||
|
||||
it('shows loading message on search', showsLoadingMessage);
|
||||
it('performs search', performsSearch);
|
||||
it('shows an error message', showsErrorMessage);
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
AccountSettingsFieldViews.PasswordFieldView = FieldViews.LinkFieldView.extend({
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
this._super(options);
|
||||
_.bindAll(this, 'resetPassword');
|
||||
},
|
||||
@@ -111,6 +112,7 @@
|
||||
AccountSettingsFieldViews.AuthFieldView = FieldViews.LinkFieldView.extend({
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
this._super(options);
|
||||
_.bindAll(this, 'redirect_to', 'disconnect', 'successMessage', 'inProgressMessage');
|
||||
},
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
var AccountSettingsView = Backbone.View.extend({
|
||||
|
||||
initialize: function () {
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
_.bindAll(this, 'render', 'renderFields', 'showLoadingError');
|
||||
},
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
var BadgeView = Backbone.View.extend({
|
||||
initialize: function(options) {
|
||||
this.options = _.extend({}, options);
|
||||
this.context = _.extend(this.options.model.toJSON(), {
|
||||
'created': new Moment(this.options.model.toJSON().created),
|
||||
'ownProfile': options.ownProfile,
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
var LearnerProfileView = Backbone.View.extend({
|
||||
|
||||
initialize: function () {
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
_.bindAll(this, 'showFullProfile', 'render', 'renderFields', 'showLoadingError');
|
||||
this.listenTo(this.options.preferencesModel, "change:" + 'account_privacy', this.render);
|
||||
var Router = Backbone.Router.extend({
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
'class': 'wrapper-profile-section-two'
|
||||
},
|
||||
template: _.template(sectionTwoTemplate),
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
},
|
||||
render: function () {
|
||||
var self = this;
|
||||
var showFullProfile = this.options.showFullProfile();
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
'focus .focusguard-start': 'focusGuardStart',
|
||||
'focus .focusguard-end': 'focusGuardEnd'
|
||||
},
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
},
|
||||
focusGuardStart: function () {
|
||||
// Should only be selected directly if shift-tabbing from the start, so grab last item.
|
||||
this.$el.find("a").last().focus();
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
'success': gettext('Your changes have been saved.')
|
||||
},
|
||||
|
||||
constructor: function(options) {
|
||||
this.options = _.extend({}, options);
|
||||
Backbone.View.apply(this, arguments);
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
|
||||
this.template = _.template(this.fieldTemplate || '');
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = _.extend({}, options);
|
||||
this._super(options);
|
||||
_.bindAll(this, 'render', 'imageChangeSucceeded', 'imageChangeFailed', 'fileSelected',
|
||||
'watchForPageUnload', 'onBeforeUnload');
|
||||
|
||||
@@ -61,7 +61,7 @@ var libraryFiles = [
|
||||
{pattern: 'xmodule_js/common_static/js/src/**/*.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.string.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/backbone-min.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/common/js/vendor/backbone-min.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/backbone.paginator.min.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/js/vendor/edxnotes/annotator-full.min.js', included: false},
|
||||
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
|
||||
|
||||
Reference in New Issue
Block a user