From a1cb7b8f399cb2f65ade2d2e7943d5ce1f3b98b5 Mon Sep 17 00:00:00 2001 From: muzaffaryousaf Date: Tue, 12 Apr 2016 14:13:16 +0500 Subject: [PATCH] Common, squire fixes required to upgrade backbonejs TNL-4358 --- .../src/discussion/views/discussion_thread_view.coffee | 3 ++- .../common/js/components/collections/paging_collection.js | 7 ++++++- common/static/common/js/components/views/feedback.js | 3 ++- common/static/common/js/components/views/paginated_view.js | 6 +++--- .../static/common/js/spec/components/search_field_spec.js | 3 +-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/static/coffee/src/discussion/views/discussion_thread_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_view.coffee index 6ee84303bb..9f092fd686 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -20,6 +20,7 @@ if Backbone? super() @mode = options.mode or "inline" # allowed values are "tab" or "inline" @context = options.context or "course" # allowed values are "course" or "standalone" + @course_settings = options.course_settings if @mode not in ["tab", "inline"] throw new Error("invalid mode: " + @mode) @@ -307,7 +308,7 @@ if Backbone? model: @model mode: @mode context: @context - course_settings: @options.course_settings + course_settings: @course_settings ) @editView.bind "thread:updated thread:cancel_edit", @closeEditView @editView.bind "comment:endorse", @endorseThread diff --git a/common/static/common/js/components/collections/paging_collection.js b/common/static/common/js/components/collections/paging_collection.js index 3acb1e033d..b556a86bee 100644 --- a/common/static/common/js/components/collections/paging_collection.js +++ b/common/static/common/js/components/collections/paging_collection.js @@ -20,7 +20,12 @@ 'use strict'; define(['backbone.paginator'], function (BackbonePaginator) { var PagingCollection = BackbonePaginator.requestPager.extend({ - initialize: function () { + initialize: function (models, options) { + options = options || {}; + if (options.url) { + this.url = options.url; + } + var self = this; // These must be initialized in the constructor because otherwise all PagingCollections would point // to the same object references for sortableFields and filterableFields. diff --git a/common/static/common/js/components/views/feedback.js b/common/static/common/js/components/views/feedback.js index 0656b59458..7eccd32889 100644 --- a/common/static/common/js/components/views/feedback.js +++ b/common/static/common/js/components/views/feedback.js @@ -59,7 +59,8 @@ */ }, - initialize: function() { + initialize: function(options) { + this.options = _.extend({}, this.options, options); if (!this.options.type) { throw "SystemFeedback: type required (given " + JSON.stringify(this.options) + ")"; diff --git a/common/static/common/js/components/views/paginated_view.js b/common/static/common/js/components/views/paginated_view.js index 947ce83088..2a716a73dd 100644 --- a/common/static/common/js/components/views/paginated_view.js +++ b/common/static/common/js/components/views/paginated_view.js @@ -31,7 +31,7 @@ className: this.type + '-container', itemViewClass: this.itemViewClass }); - this.listView = new ItemListView({collection: this.options.collection}); + this.listView = new ItemListView({collection: this.collection}); this.headerView = this.createHeaderView(); this.footerView = this.createFooterView(); this.collection.on('page_changed', function () { @@ -46,12 +46,12 @@ paginationLabel: gettext("Pagination"), createHeaderView: function() { - return new PagingHeader({collection: this.options.collection, srInfo: this.srInfo}); + return new PagingHeader({collection: this.collection, srInfo: this.srInfo}); }, createFooterView: function() { return new PagingFooter({ - collection: this.options.collection, hideWhenOnePage: true, + collection: this.collection, hideWhenOnePage: true, paginationLabel: this.paginationLabel }); }, diff --git a/common/static/common/js/spec/components/search_field_spec.js b/common/static/common/js/spec/components/search_field_spec.js index 3464ef1036..2bd7dba4f2 100644 --- a/common/static/common/js/spec/components/search_field_spec.js +++ b/common/static/common/js/spec/components/search_field_spec.js @@ -21,8 +21,7 @@ define([ current_page: 1, start: 0, results: _.first(results, perPage) - }, - {parse: true} + } ); collection.start = 0; collection.totalCount = results.length;