Commit 674bfc4f by Andy Armstrong

Use edx namespace for Backbone classes

parent 5ea7ced9
(function(Backbone) {
var CohortCollection = Backbone.Collection.extend({
model : this.CohortModel,
comparator: "name",
parse: function(response) {
return response.cohorts;
}
});
this.CohortCollection = CohortCollection;
}).call(this, Backbone);
var edx = edx || {};
(function(Backbone, CohortModel) {
'use strict';
edx.groups = edx.groups || {};
edx.groups.CohortCollection = Backbone.Collection.extend({
model : CohortModel,
comparator: "name",
parse: function(response) {
return response.cohorts;
}
});
}).call(this, Backbone, edx.groups.CohortModel);
var edx = edx || {};
(function(Backbone) {
var CohortModel = Backbone.Model.extend({
'use strict';
edx.groups = edx.groups || {};
edx.groups.CohortModel = Backbone.Model.extend({
idAttribute: 'id',
defaults: {
name: '',
......@@ -20,6 +26,4 @@
group_id: null
}
});
this.CohortModel = CohortModel;
}).call(this, Backbone);
var edx = edx || {};
(function(Backbone, _, $, gettext, ngettext, interpolate_text, NotificationModel, NotificationView) {
var CohortEditorView = Backbone.View.extend({
'use strict';
edx.groups = edx.groups || {};
edx.groups.CohortEditorView = Backbone.View.extend({
events : {
"submit .cohort-management-group-add-form": "addStudents"
},
......@@ -202,6 +208,4 @@
}
}
});
this.CohortEditorView = CohortEditorView;
}).call(this, Backbone, _, $, gettext, ngettext, interpolate_text, NotificationModel, NotificationView);
(function($, _, Backbone, gettext, interpolate_text, CohortEditorView, NotificationModel, NotificationView, FileUploaderView) {
var edx = edx || {};
(function($, _, Backbone, gettext, interpolate_text, CohortEditorView,
NotificationModel, NotificationView, FileUploaderView) {
'use strict';
var hiddenClass = 'is-hidden',
disabledClass = 'is-disabled';
this.CohortsView = Backbone.View.extend({
edx.groups = edx.groups || {};
edx.groups.CohortsView = Backbone.View.extend({
events : {
'change .cohort-select': 'onCohortSelected',
'click .action-create': 'showAddCohortForm',
......@@ -226,6 +233,6 @@
getSectionCss: function (section) {
return ".instructor-nav .nav-item a[data-section='" + section + "']";
}
});
}).call(this, $, _, Backbone, gettext, interpolate_text, CohortEditorView, NotificationModel, NotificationView, FileUploaderView);
}).call(this, $, _, Backbone, gettext, interpolate_text, edx.groups.CohortEditorView,
NotificationModel, NotificationView, FileUploaderView);
define(['backbone', 'jquery', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers',
'js/views/cohorts', 'js/collections/cohort', 'string_utils'],
'js/groups/views/cohorts', 'js/groups/collections/cohort', 'string_utils'],
function (Backbone, $, AjaxHelpers, TemplateHelpers, CohortsView, CohortCollection) {
describe("Cohorts View", function () {
var catLoversInitialCount = 123, dogLoversInitialCount = 456, unknownUserMessage,
......
......@@ -61,13 +61,13 @@
'js/staff_debug_actions': 'js/staff_debug_actions',
// Backbone classes loaded explicitly until they are converted to use RequireJS
'js/models/notification': 'js/models/notification',
'js/views/file_uploader': 'js/views/file_uploader',
'js/models/cohort': 'js/models/cohort',
'js/collections/cohort': 'js/collections/cohort',
'js/views/cohort_editor': 'js/views/cohort_editor',
'js/views/cohorts': 'js/views/cohorts',
'js/views/notification': 'js/views/notification',
'js/models/notification': 'js/models/notification',
'js/groups/models/cohort': 'js/groups/models/cohort',
'js/groups/collections/cohort': 'js/groups/collections/cohort',
'js/groups/views/cohort_editor': 'js/groups/views/cohort_editor',
'js/groups/views/cohorts': 'js/groups/views/cohorts',
'js/student_account/account': 'js/student_account/account',
'js/student_account/views/FormView': 'js/student_account/views/FormView',
'js/student_account/models/LoginModel': 'js/student_account/models/LoginModel',
......@@ -280,23 +280,25 @@
exports: 'edx.instructor_dashboard.ecommerce.ExpiryCouponView',
deps: ['backbone', 'jquery', 'underscore']
},
'js/models/cohort': {
exports: 'CohortModel',
'js/groups/models/cohort': {
exports: 'edx.groups.CohortModel',
deps: ['backbone']
},
'js/collections/cohort': {
exports: 'CohortCollection',
deps: ['backbone', 'js/models/cohort']
'js/groups/collections/cohort': {
exports: 'edx.groups.CohortCollection',
deps: ['backbone', 'js/groups/models/cohort']
},
'js/views/cohort_editor': {
exports: 'CohortsEditor',
deps: ['backbone', 'jquery', 'underscore', 'js/views/notification', 'js/models/notification',
'js/groups/views/cohort_editor': {
exports: 'edx.groups.CohortsEditor',
deps: [
'backbone', 'jquery', 'underscore', 'js/views/notification', 'js/models/notification',
'string_utils'
]
},
'js/views/cohorts': {
exports: 'CohortsView',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'string_utils', 'js/views/cohort_editor',
'js/groups/views/cohorts': {
exports: 'edx.groups.CohortsView',
deps: [
'jquery', 'underscore', 'backbone', 'gettext', 'string_utils', 'js/groups/views/cohort_editor',
'js/views/notification', 'js/models/notification', 'js/views/file_uploader'
]
},
......@@ -310,7 +312,8 @@
},
'js/views/file_uploader': {
exports: 'FileUploaderView',
deps: ['backbone', 'jquery', 'underscore', 'gettext', 'string_utils', 'js/views/notification',
deps: [
'backbone', 'jquery', 'underscore', 'gettext', 'string_utils', 'js/views/notification',
'js/models/notification', 'jquery.fileupload'
]
},
......@@ -505,12 +508,12 @@
// TODO: why do these need 'lms/include' at the front but the CMS equivalent logic doesn't?
define([
// Run the LMS tests
'lms/include/js/spec/views/cohorts_spec.js',
'lms/include/js/spec/photocapture_spec.js',
'lms/include/js/spec/staff_debug_actions_spec.js',
'lms/include/js/spec/views/notification_spec.js',
'lms/include/js/spec/views/file_uploader_spec.js',
'lms/include/js/spec/dashboard/donation.js',
'lms/include/js/spec/groups/views/cohorts_spec.js',
'lms/include/js/spec/shoppingcart/shoppingcart_spec.js',
'lms/include/js/spec/instructor_dashboard/ecommerce_spec.js',
'lms/include/js/spec/student_account/account_spec.js',
......
......@@ -57,10 +57,10 @@
<script type="text/javascript" src="${static.url('js/models/notification.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/notification.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/file_uploader.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/cohort.js')}"></script>
<script type="text/javascript" src="${static.url('js/collections/cohort.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/cohort_editor.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/cohorts.js')}"></script>
<script type="text/javascript" src="${static.url('js/groups/models/cohort.js')}"></script>
<script type="text/javascript" src="${static.url('js/groups/collections/cohort.js')}"></script>
<script type="text/javascript" src="${static.url('js/groups/views/cohort_editor.js')}"></script>
<script type="text/javascript" src="${static.url('js/groups/views/cohorts.js')}"></script>
</%block>
## Include Underscore templates
......
......@@ -258,9 +258,9 @@
$(document).ready(function() {
var cohortManagementElement = $('.cohort-management');
if (cohortManagementElement.length > 0) {
var cohorts = new CohortCollection();
var cohorts = new edx.groups.CohortCollection();
cohorts.url = cohortManagementElement.data('ajax_url');
var cohortsView = new CohortsView({
var cohortsView = new edx.groups.CohortsView({
el: cohortManagementElement,
model: cohorts,
advanced_settings_url: cohortManagementElement.data('advanced-settings-url'),
......
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