Commit c28003b5 by Andy Armstrong

Merge pull request #8416 from edx/andya/common-list-component

Create a common paginated list view
parents 439f72f9 5fbad148
...@@ -58,9 +58,9 @@ ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules' ...@@ -58,9 +58,9 @@ ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules'
ADVANCED_PROBLEM_TYPES = settings.ADVANCED_PROBLEM_TYPES ADVANCED_PROBLEM_TYPES = settings.ADVANCED_PROBLEM_TYPES
CONTAINER_TEMPATES = [ CONTAINER_TEMPLATES = [
"basic-modal", "modal-button", "edit-xblock-modal", "basic-modal", "modal-button", "edit-xblock-modal",
"editor-mode-button", "upload-dialog", "image-modal", "editor-mode-button", "upload-dialog",
"add-xblock-component", "add-xblock-component-button", "add-xblock-component-menu", "add-xblock-component", "add-xblock-component-button", "add-xblock-component-menu",
"add-xblock-component-menu-problem", "xblock-string-field-editor", "publish-xblock", "publish-history", "add-xblock-component-menu-problem", "xblock-string-field-editor", "publish-xblock", "publish-history",
"unit-outline", "container-message", "license-selector", "unit-outline", "container-message", "license-selector",
...@@ -217,7 +217,7 @@ def container_handler(request, usage_key_string): ...@@ -217,7 +217,7 @@ def container_handler(request, usage_key_string):
'xblock_info': xblock_info, 'xblock_info': xblock_info,
'draft_preview_link': preview_lms_link, 'draft_preview_link': preview_lms_link,
'published_preview_link': lms_link, 'published_preview_link': lms_link,
'templates': CONTAINER_TEMPATES 'templates': CONTAINER_TEMPLATES
}) })
else: else:
return HttpResponseBadRequest("Only supports HTML requests") return HttpResponseBadRequest("Only supports HTML requests")
......
...@@ -26,7 +26,7 @@ from xmodule.modulestore import ModuleStoreEnum ...@@ -26,7 +26,7 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from .user import user_with_role from .user import user_with_role
from .component import get_component_templates, CONTAINER_TEMPATES from .component import get_component_templates, CONTAINER_TEMPLATES
from student.auth import ( from student.auth import (
STUDIO_VIEW_USERS, STUDIO_EDIT_ROLES, get_user_permissions, has_studio_read_access, has_studio_write_access STUDIO_VIEW_USERS, STUDIO_EDIT_ROLES, get_user_permissions, has_studio_read_access, has_studio_write_access
) )
...@@ -197,7 +197,7 @@ def library_blocks_view(library, user, response_format): ...@@ -197,7 +197,7 @@ def library_blocks_view(library, user, response_format):
'context_library': library, 'context_library': library,
'component_templates': json.dumps(component_templates), 'component_templates': json.dumps(component_templates),
'xblock_info': xblock_info, 'xblock_info': xblock_info,
'templates': CONTAINER_TEMPATES, 'templates': CONTAINER_TEMPLATES,
}) })
......
...@@ -210,6 +210,7 @@ MAKO_TEMPLATES['main'] = [ ...@@ -210,6 +210,7 @@ MAKO_TEMPLATES['main'] = [
COMMON_ROOT / 'templates', COMMON_ROOT / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates', COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_js' / 'templates', COMMON_ROOT / 'djangoapps' / 'pipeline_js' / 'templates',
COMMON_ROOT / 'static', # required to statically include common Underscore templates
] ]
for namespace, template_dirs in lms.envs.common.MAKO_TEMPLATES.iteritems(): for namespace, template_dirs in lms.envs.common.MAKO_TEMPLATES.iteritems():
......
...@@ -30,6 +30,11 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ...@@ -30,6 +30,11 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
LMS_BASE = "localhost:8000" LMS_BASE = "localhost:8000"
FEATURES['PREVIEW_LMS_BASE'] = "preview." + LMS_BASE FEATURES['PREVIEW_LMS_BASE'] = "preview." + LMS_BASE
########################### PIPELINE #################################
# Skip RequireJS optimizer in development
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
############################# ADVANCED COMPONENTS ############################# ############################# ADVANCED COMPONENTS #############################
# Make it easier to test advanced components in local dev # Make it easier to test advanced components in local dev
...@@ -92,6 +97,11 @@ FEATURES['ENABLE_COURSEWARE_INDEX'] = True ...@@ -92,6 +97,11 @@ FEATURES['ENABLE_COURSEWARE_INDEX'] = True
FEATURES['ENABLE_LIBRARY_INDEX'] = True FEATURES['ENABLE_LIBRARY_INDEX'] = True
SEARCH_ENGINE = "search.elastic.ElasticSearchEngine" SEARCH_ENGINE = "search.elastic.ElasticSearchEngine"
################################# DJANGO-REQUIRE ###############################
# Whether to run django-require in debug mode.
REQUIRE_DEBUG = DEBUG
############################################################################### ###############################################################################
# See if the developer has any local overrides. # See if the developer has any local overrides.
try: try:
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
* As of 1.0.3, this value can also be a string that is converted to a * As of 1.0.3, this value can also be a string that is converted to a
* RegExp via new RegExp(). * RegExp via new RegExp().
*/ */
fileExclusionRegExp: /^\.|spec/, fileExclusionRegExp: /^\.|spec|spec_helpers/,
/** /**
* Allow CSS optimizations. Allowed values: * Allow CSS optimizations. Allowed values:
* - "standard": @import inlining and removal of comments, unnecessary * - "standard": @import inlining and removal of comments, unnecessary
...@@ -153,6 +153,6 @@ ...@@ -153,6 +153,6 @@
* SILENT: 4 * SILENT: 4
* Default is 0. * Default is 0.
*/ */
logLevel: 4 logLevel: 1
}; };
} ()) } ())
...@@ -23,6 +23,7 @@ requirejs.config({ ...@@ -23,6 +23,7 @@ requirejs.config({
"jquery.simulate": "xmodule_js/common_static/js/vendor/jquery.simulate", "jquery.simulate": "xmodule_js/common_static/js/vendor/jquery.simulate",
"datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair", "datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair",
"date": "xmodule_js/common_static/js/vendor/date", "date": "xmodule_js/common_static/js/vendor/date",
"text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "xmodule_js/common_static/js/vendor/underscore-min", "underscore": "xmodule_js/common_static/js/vendor/underscore-min",
"underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min", "underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min",
"backbone": "xmodule_js/common_static/js/vendor/backbone-min", "backbone": "xmodule_js/common_static/js/vendor/backbone-min",
...@@ -240,13 +241,11 @@ define([ ...@@ -240,13 +241,11 @@ define([
"js/spec/views/active_video_upload_list_spec", "js/spec/views/active_video_upload_list_spec",
"js/spec/views/previous_video_upload_spec", "js/spec/views/previous_video_upload_spec",
"js/spec/views/previous_video_upload_list_spec", "js/spec/views/previous_video_upload_list_spec",
"js/spec/views/paging_spec",
"js/spec/views/assets_spec", "js/spec/views/assets_spec",
"js/spec/views/baseview_spec", "js/spec/views/baseview_spec",
"js/spec/views/container_spec", "js/spec/views/container_spec",
"js/spec/views/paged_container_spec", "js/spec/views/paged_container_spec",
"js/spec/views/group_configuration_spec", "js/spec/views/group_configuration_spec",
"js/spec/views/paging_spec",
"js/spec/views/unit_outline_spec", "js/spec/views/unit_outline_spec",
"js/spec/views/xblock_spec", "js/spec/views/xblock_spec",
"js/spec/views/xblock_editor_spec", "js/spec/views/xblock_editor_spec",
......
require ["jquery", "backbone", "coffee/src/main", "js/common_helpers/ajax_helpers", "jasmine-stealth", "jquery.cookie"], require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_helpers", "jasmine-stealth", "jquery.cookie"],
($, Backbone, main, AjaxHelpers) -> ($, Backbone, main, AjaxHelpers) ->
describe "CMS", -> describe "CMS", ->
it "should initialize URL", -> it "should initialize URL", ->
......
...@@ -21,6 +21,7 @@ requirejs.config({ ...@@ -21,6 +21,7 @@ requirejs.config({
"jquery.immediateDescendents": "xmodule_js/common_static/coffee/src/jquery.immediateDescendents", "jquery.immediateDescendents": "xmodule_js/common_static/coffee/src/jquery.immediateDescendents",
"datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair", "datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair",
"date": "xmodule_js/common_static/js/vendor/date", "date": "xmodule_js/common_static/js/vendor/date",
"text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "xmodule_js/common_static/js/vendor/underscore-min", "underscore": "xmodule_js/common_static/js/vendor/underscore-min",
"underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min", "underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min",
"backbone": "xmodule_js/common_static/js/vendor/backbone-min", "backbone": "xmodule_js/common_static/js/vendor/backbone-min",
......
define ["js/models/section", "js/common_helpers/ajax_helpers", "js/utils/module"], (Section, AjaxHelpers, ModuleUtils) -> define ["js/models/section", "common/js/spec_helpers/ajax_helpers", "js/utils/module"], (Section, AjaxHelpers, ModuleUtils) ->
describe "Section", -> describe "Section", ->
describe "basic", -> describe "basic", ->
beforeEach -> beforeEach ->
......
define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], define ["jquery", "jasmine", "common/js/spec_helpers/ajax_helpers", "squire"],
($, jasmine, AjaxHelpers, Squire) -> ($, jasmine, AjaxHelpers, Squire) ->
feedbackTpl = readFixtures('system-feedback.underscore') feedbackTpl = readFixtures('system-feedback.underscore')
assetLibraryTpl = readFixtures('asset-library.underscore') assetLibraryTpl = readFixtures('asset-library.underscore')
assetTpl = readFixtures('asset.underscore') assetTpl = readFixtures('asset.underscore')
pagingHeaderTpl = readFixtures('paging-header.underscore')
pagingFooterTpl = readFixtures('paging-footer.underscore')
describe "Asset view", -> describe "Asset view", ->
beforeEach -> beforeEach ->
...@@ -141,8 +139,6 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -141,8 +139,6 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
beforeEach -> beforeEach ->
setFixtures($("<script>", {id: "asset-library-tpl", type: "text/template"}).text(assetLibraryTpl)) setFixtures($("<script>", {id: "asset-library-tpl", type: "text/template"}).text(assetLibraryTpl))
appendSetFixtures($("<script>", {id: "asset-tpl", type: "text/template"}).text(assetTpl)) appendSetFixtures($("<script>", {id: "asset-tpl", type: "text/template"}).text(assetTpl))
appendSetFixtures($("<script>", {id: "paging-header-tpl", type: "text/template"}).text(pagingHeaderTpl))
appendSetFixtures($("<script>", {id: "paging-footer-tpl", type: "text/template"}).text(pagingFooterTpl))
appendSetFixtures($("<script>", {id: "system-feedback-tpl", type: "text/template"}).text(feedbackTpl)) appendSetFixtures($("<script>", {id: "system-feedback-tpl", type: "text/template"}).text(feedbackTpl))
window.analytics = jasmine.createSpyObj('analytics', ['track']) window.analytics = jasmine.createSpyObj('analytics', ['track'])
window.course_location_analytics = jasmine.createSpy() window.course_location_analytics = jasmine.createSpy()
...@@ -241,7 +237,7 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -241,7 +237,7 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
describe "Basic", -> describe "Basic", ->
# Separate setup method to work-around mis-parenting of beforeEach methods # Separate setup method to work-around mis-parenting of beforeEach methods
setup = (requests) -> setup = (requests) ->
@view.setPage(0) @view.pagingView.setPage(0)
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
$.fn.fileupload = -> $.fn.fileupload = ->
...@@ -285,7 +281,7 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -285,7 +281,7 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
{view: @view, requests: requests} = @createAssetsView(this) {view: @view, requests: requests} = @createAssetsView(this)
appendSetFixtures('<div class="ui-loading"/>') appendSetFixtures('<div class="ui-loading"/>')
expect($('.ui-loading').is(':visible')).toBe(true) expect($('.ui-loading').is(':visible')).toBe(true)
@view.setPage(0) @view.pagingView.setPage(0)
AjaxHelpers.respondWithError(requests) AjaxHelpers.respondWithError(requests)
expect($('.ui-loading').is(':visible')).toBe(false) expect($('.ui-loading').is(':visible')).toBe(false)
...@@ -333,27 +329,27 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -333,27 +329,27 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
describe "Sorting", -> describe "Sorting", ->
# Separate setup method to work-around mis-parenting of beforeEach methods # Separate setup method to work-around mis-parenting of beforeEach methods
setup = (requests) -> setup = (requests) ->
@view.setPage(0) @view.pagingView.setPage(0)
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
it "should have the correct default sort order", -> it "should have the correct default sort order", ->
{view: @view, requests: requests} = @createAssetsView(this) {view: @view, requests: requests} = @createAssetsView(this)
setup.call(this, requests) setup.call(this, requests)
expect(@view.sortDisplayName()).toBe("Date Added") expect(@view.pagingView.sortDisplayName()).toBe("Date Added")
expect(@view.collection.sortDirection).toBe("desc") expect(@view.collection.sortDirection).toBe("desc")
it "should toggle the sort order when clicking on the currently sorted column", -> it "should toggle the sort order when clicking on the currently sorted column", ->
{view: @view, requests: requests} = @createAssetsView(this) {view: @view, requests: requests} = @createAssetsView(this)
setup.call(this, requests) setup.call(this, requests)
expect(@view.sortDisplayName()).toBe("Date Added") expect(@view.pagingView.sortDisplayName()).toBe("Date Added")
expect(@view.collection.sortDirection).toBe("desc") expect(@view.collection.sortDirection).toBe("desc")
@view.$("#js-asset-date-col").click() @view.$("#js-asset-date-col").click()
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
expect(@view.sortDisplayName()).toBe("Date Added") expect(@view.pagingView.sortDisplayName()).toBe("Date Added")
expect(@view.collection.sortDirection).toBe("asc") expect(@view.collection.sortDirection).toBe("asc")
@view.$("#js-asset-date-col").click() @view.$("#js-asset-date-col").click()
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
expect(@view.sortDisplayName()).toBe("Date Added") expect(@view.pagingView.sortDisplayName()).toBe("Date Added")
expect(@view.collection.sortDirection).toBe("desc") expect(@view.collection.sortDirection).toBe("desc")
it "should switch the sort order when clicking on a different column", -> it "should switch the sort order when clicking on a different column", ->
...@@ -361,11 +357,11 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -361,11 +357,11 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
setup.call(this, requests) setup.call(this, requests)
@view.$("#js-asset-name-col").click() @view.$("#js-asset-name-col").click()
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
expect(@view.sortDisplayName()).toBe("Name") expect(@view.pagingView.sortDisplayName()).toBe("Name")
expect(@view.collection.sortDirection).toBe("asc") expect(@view.collection.sortDirection).toBe("asc")
@view.$("#js-asset-name-col").click() @view.$("#js-asset-name-col").click()
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
expect(@view.sortDisplayName()).toBe("Name") expect(@view.pagingView.sortDisplayName()).toBe("Name")
expect(@view.collection.sortDirection).toBe("desc") expect(@view.collection.sortDirection).toBe("desc")
it "should switch sort to most recent date added when a new asset is added", -> it "should switch sort to most recent date added when a new asset is added", ->
...@@ -375,5 +371,5 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"], ...@@ -375,5 +371,5 @@ define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
addMockAsset.call(this, requests) addMockAsset.call(this, requests)
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse) AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
expect(@view.sortDisplayName()).toBe("Date Added") expect(@view.pagingView.sortDisplayName()).toBe("Date Added")
expect(@view.collection.sortDirection).toBe("desc") expect(@view.collection.sortDirection).toBe("desc")
define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info", "js/collections/course_update", "js/common_helpers/ajax_helpers"], define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info", "js/collections/course_update", "common/js/spec_helpers/ajax_helpers"],
(CourseInfoHandoutsView, CourseInfoUpdateView, ModuleInfo, CourseUpdateCollection, AjaxHelpers) -> (CourseInfoHandoutsView, CourseInfoUpdateView, ModuleInfo, CourseUpdateCollection, AjaxHelpers) ->
describe "Course Updates and Handouts", -> describe "Course Updates and Handouts", ->
......
define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course", define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course",
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks", "js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
"js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification", "js/views/utils/view_utils", "js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification", "js/views/utils/view_utils",
"js/common_helpers/ajax_helpers", "js/spec_helpers/modal_helpers", "jasmine-stealth"], "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/modal_helpers", "jasmine-stealth"],
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTextbooks, EditChapter, Prompt, Notification, ViewUtils, AjaxHelpers, modal_helpers) -> (Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTextbooks, EditChapter, Prompt, Notification, ViewUtils, AjaxHelpers, modal_helpers) ->
feedbackTpl = readFixtures('system-feedback.underscore') feedbackTpl = readFixtures('system-feedback.underscore')
......
define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/common_helpers/ajax_helpers", "js/spec_helpers/modal_helpers"], (FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) -> define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/modal_helpers"], (FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) ->
feedbackTpl = readFixtures('system-feedback.underscore') feedbackTpl = readFixtures('system-feedback.underscore')
......
../../common/static/common
\ No newline at end of file
...@@ -8,8 +8,8 @@ define([ // jshint ignore:line ...@@ -8,8 +8,8 @@ define([ // jshint ignore:line
'js/certificates/views/certificate_details', 'js/certificates/views/certificate_details',
'js/certificates/views/certificate_preview', 'js/certificates/views/certificate_preview',
'js/views/feedback_notification', 'js/views/feedback_notification',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec_helpers/view_helpers', 'js/spec_helpers/view_helpers',
'js/spec_helpers/validation_helpers', 'js/spec_helpers/validation_helpers',
'js/certificates/spec/custom_matchers' 'js/certificates/spec/custom_matchers'
......
...@@ -8,8 +8,8 @@ define([ // jshint ignore:line ...@@ -8,8 +8,8 @@ define([ // jshint ignore:line
'js/certificates/collections/certificates', 'js/certificates/collections/certificates',
'js/certificates/views/certificate_editor', 'js/certificates/views/certificate_editor',
'js/views/feedback_notification', 'js/views/feedback_notification',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec_helpers/view_helpers', 'js/spec_helpers/view_helpers',
'js/spec_helpers/validation_helpers', 'js/spec_helpers/validation_helpers',
'js/certificates/spec/custom_matchers' 'js/certificates/spec/custom_matchers'
......
...@@ -11,8 +11,8 @@ define([ // jshint ignore:line ...@@ -11,8 +11,8 @@ define([ // jshint ignore:line
'js/certificates/views/certificates_list', 'js/certificates/views/certificates_list',
'js/certificates/views/certificate_preview', 'js/certificates/views/certificate_preview',
'js/views/feedback_notification', 'js/views/feedback_notification',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/certificates/spec/custom_matchers' 'js/certificates/spec/custom_matchers'
], ],
function(_, Course, CertificatesCollection, CertificateModel, CertificateDetailsView, CertificateEditorView, function(_, Course, CertificatesCollection, CertificateModel, CertificateDetailsView, CertificateEditorView,
......
...@@ -4,11 +4,10 @@ define([ // jshint ignore:line ...@@ -4,11 +4,10 @@ define([ // jshint ignore:line
'jquery', 'jquery',
'underscore', 'underscore',
'gettext', 'gettext',
'js/common_helpers/page_helpers',
'js/views/pages/base_page', 'js/views/pages/base_page',
'js/certificates/views/certificates_list' 'js/certificates/views/certificates_list'
], ],
function ($, _, gettext, PageHelpers, BasePage, CertificatesListView) { function ($, _, gettext, BasePage, CertificatesListView) {
'use strict'; 'use strict';
var CertificatesPage = BasePage.extend({ var CertificatesPage = BasePage.extend({
......
../../../common/static/js/spec_helpers
\ No newline at end of file
define(['domReady!', 'jquery', 'backbone', 'underscore', 'gettext']); define(['domReady!', 'jquery', 'backbone', 'underscore', 'gettext', 'text']);
define(['jquery', 'js/factories/xblock_validation', 'js/common_helpers/template_helpers'], define(['jquery', 'js/factories/xblock_validation', 'common/js/spec_helpers/template_helpers'],
function($, XBlockValidationFactory, TemplateHelpers) { function($, XBlockValidationFactory, TemplateHelpers) {
describe('XBlockValidationFactory', function() { describe('XBlockValidationFactory', function() {
......
define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/common_helpers/ajax_helpers", "jquery", "underscore"], define(["js/utils/drag_and_drop", "js/views/feedback_notification", "common/js/spec_helpers/ajax_helpers", "jquery", "underscore"],
function (ContentDragger, Notification, AjaxHelpers, $, _) { function (ContentDragger, Notification, AjaxHelpers, $, _) {
describe("Overview drag and drop functionality", function () { describe("Overview drag and drop functionality", function () {
beforeEach(function () { beforeEach(function () {
......
define( define(
[ [
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'squire' 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'squire'
], ],
function ($, _, AjaxHelpers, Squire) { function ($, _, AjaxHelpers, Squire) {
'use strict'; 'use strict';
......
define( define(
[ [
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'squire' 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'squire'
], ],
function ($, _, AjaxHelpers, Squire) { function ($, _, AjaxHelpers, Squire) {
'use strict'; 'use strict';
......
define( define(
["jquery", "js/models/active_video_upload", "js/views/active_video_upload_list", "js/common_helpers/template_helpers", "mock-ajax", "jasmine-jquery"], ["jquery", "js/models/active_video_upload", "js/views/active_video_upload_list", "common/js/spec_helpers/template_helpers", "mock-ajax", "jasmine-jquery"],
function($, ActiveVideoUpload, ActiveVideoUploadListView, TemplateHelpers) { function($, ActiveVideoUpload, ActiveVideoUploadListView, TemplateHelpers) {
"use strict"; "use strict";
var concurrentUploadLimit = 2; var concurrentUploadLimit = 2;
......
define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "js/views/assets", define([ "jquery", "common/js/spec_helpers/ajax_helpers", "URI", "js/views/asset", "js/views/assets",
"js/models/asset", "js/collections/asset", "js/spec_helpers/view_helpers"], "js/models/asset", "js/collections/asset", "js/spec_helpers/view_helpers"],
function ($, AjaxHelpers, URI, AssetView, AssetsView, AssetModel, AssetCollection, ViewHelpers) { function ($, AjaxHelpers, URI, AssetView, AssetsView, AssetModel, AssetCollection, ViewHelpers) {
...@@ -8,15 +8,11 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -8,15 +8,11 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
assetLibraryTpl = readFixtures('asset-library.underscore'); assetLibraryTpl = readFixtures('asset-library.underscore');
assetTpl = readFixtures('asset.underscore'); assetTpl = readFixtures('asset.underscore');
pagingHeaderTpl = readFixtures('paging-header.underscore');
pagingFooterTpl = readFixtures('paging-footer.underscore');
uploadModalTpl = readFixtures('asset-upload-modal.underscore'); uploadModalTpl = readFixtures('asset-upload-modal.underscore');
beforeEach(function () { beforeEach(function () {
setFixtures($("<script>", { id: "asset-library-tpl", type: "text/template" }).text(assetLibraryTpl)); setFixtures($("<script>", { id: "asset-library-tpl", type: "text/template" }).text(assetLibraryTpl));
appendSetFixtures($("<script>", { id: "asset-tpl", type: "text/template" }).text(assetTpl)); appendSetFixtures($("<script>", { id: "asset-tpl", type: "text/template" }).text(assetTpl));
appendSetFixtures($("<script>", { id: "paging-header-tpl", type: "text/template" }).text(pagingHeaderTpl));
appendSetFixtures($("<script>", { id: "paging-footer-tpl", type: "text/template" }).text(pagingFooterTpl));
appendSetFixtures(uploadModalTpl); appendSetFixtures(uploadModalTpl);
appendSetFixtures(sandbox({ id: "asset_table_body" })); appendSetFixtures(sandbox({ id: "asset_table_body" }));
...@@ -139,7 +135,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -139,7 +135,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
var setup; var setup;
setup = function(responseData) { setup = function(responseData) {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
assetsView.setPage(0); assetsView.pagingView.setPage(0);
if (!responseData){ if (!responseData){
AjaxHelpers.respondWithJson(requests, mockEmptyAssetsResponse); AjaxHelpers.respondWithJson(requests, mockEmptyAssetsResponse);
} }
...@@ -188,8 +184,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -188,8 +184,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
spyOn(assetsView, "addAsset").andCallFake(function () { spyOn(assetsView, "addAsset").andCallFake(function () {
assetsView.collection.add(mockAssetUploadResponse.asset); assetsView.collection.add(mockAssetUploadResponse.asset);
assetsView.renderPageItems(); assetsView.pagingView.renderPageItems();
assetsView.setPage(0); assetsView.pagingView.setPage(0);
}); });
$('a:contains("Upload your first asset")').click(); $('a:contains("Upload your first asset")').click();
...@@ -248,9 +244,9 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -248,9 +244,9 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
}); });
it('returns the registered info for a filter column', function () { it('returns the registered info for a filter column', function () {
assetsView.registerSortableColumn('test-col', 'Test Column', 'testField', 'asc'); assetsView.pagingView.registerSortableColumn('test-col', 'Test Column', 'testField', 'asc');
assetsView.registerFilterableColumn('js-asset-type-col', 'Type', 'asset_type'); assetsView.pagingView.registerFilterableColumn('js-asset-type-col', 'Type', 'asset_type');
var filterInfo = assetsView.filterableColumnInfo('js-asset-type-col'); var filterInfo = assetsView.pagingView.filterableColumnInfo('js-asset-type-col');
expect(filterInfo.displayName).toBe('Type'); expect(filterInfo.displayName).toBe('Type');
expect(filterInfo.fieldName).toBe('asset_type'); expect(filterInfo.fieldName).toBe('asset_type');
}); });
...@@ -265,16 +261,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -265,16 +261,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
it('make sure selectFilter sets collection filter if undefined', function () { it('make sure selectFilter sets collection filter if undefined', function () {
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
assetsView.collection.filterField = ''; assetsView.collection.filterField = '';
assetsView.selectFilter('js-asset-type-col'); assetsView.pagingView.selectFilter('js-asset-type-col');
expect(assetsView.collection.filterField).toEqual('asset_type'); expect(assetsView.collection.filterField).toEqual('asset_type');
}); });
it('make sure _toggleFilterColumn filters asset list', function () { it('make sure _toggleFilterColumn filters asset list', function () {
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
$.each(assetsView.filterableColumns, function(columnID, columnData){ $.each(assetsView.pagingView.filterableColumns, function(columnID, columnData){
var $typeColumn = $('#' + columnID); var $typeColumn = $('#' + columnID);
assetsView.setPage(0); assetsView.pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockAssets(requests);
var assetsNumber = assetsView.collection.length; var assetsNumber = assetsView.collection.length;
assetsView._toggleFilterColumn('Images', 'Images'); assetsView._toggleFilterColumn('Images', 'Images');
...@@ -288,7 +284,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -288,7 +284,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
it('opens and closes select type menu', function () { it('opens and closes select type menu', function () {
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
setup.call(this, mockExampleAssetsResponse); setup.call(this, mockExampleAssetsResponse);
$.each(assetsView.filterableColumns, function(columnID, columnData){ $.each(assetsView.pagingView.filterableColumns, function(columnID, columnData){
var $typeColumn = $('#' + columnID); var $typeColumn = $('#' + columnID);
expect($typeColumn).toBeVisible(); expect($typeColumn).toBeVisible();
var assetsNumber = $('#asset-table-body .type-col').length; var assetsNumber = $('#asset-table-body .type-col').length;
...@@ -304,12 +300,12 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -304,12 +300,12 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
it('check filtering works with sorting by column on', function () { it('check filtering works with sorting by column on', function () {
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
assetsView.registerSortableColumn('name-col', 'Name Column', 'nameField', 'asc'); assetsView.pagingView.registerSortableColumn('name-col', 'Name Column', 'nameField', 'asc');
assetsView.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type'); assetsView.pagingView.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type');
assetsView.setInitialSortColumn('name-col'); assetsView.pagingView.setInitialSortColumn('name-col');
assetsView.setPage(0); assetsView.pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockAssets(requests);
var sortInfo = assetsView.sortableColumnInfo('name-col'); var sortInfo = assetsView.pagingView.sortableColumnInfo('name-col');
expect(sortInfo.defaultSortDirection).toBe('asc'); expect(sortInfo.defaultSortDirection).toBe('asc');
var $firstFilter = $($('#js-asset-type-col').find('li.nav-item a')[1]); var $firstFilter = $($('#js-asset-type-col').find('li.nav-item a')[1]);
$firstFilter.trigger('click'); $firstFilter.trigger('click');
...@@ -322,8 +318,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j ...@@ -322,8 +318,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/asset", "j
it('shows type select menu, selects type, and filters results', function () { it('shows type select menu, selects type, and filters results', function () {
expect(assetsView).toBeDefined(); expect(assetsView).toBeDefined();
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
$.each(assetsView.filterableColumns, function(columnID, columnData) { $.each(assetsView.pagingView.filterableColumns, function(columnID, columnData) {
assetsView.setPage(0); assetsView.pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockAssets(requests);
var $typeColumn = $('#' + columnID); var $typeColumn = $('#' + columnID);
expect($typeColumn).toBeVisible(); expect($typeColumn).toBeVisible();
......
define([ "jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers", define([ "jquery", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
"js/views/container", "js/models/xblock_info", "jquery.simulate", "js/views/container", "js/models/xblock_info", "jquery.simulate",
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"], "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
function ($, AjaxHelpers, EditHelpers, ContainerView, XBlockInfo) { function ($, AjaxHelpers, EditHelpers, ContainerView, XBlockInfo) {
......
...@@ -4,7 +4,7 @@ define([ ...@@ -4,7 +4,7 @@ define([
'js/views/group_configuration_details', 'js/views/group_configurations_list', 'js/views/group_configuration_editor', 'js/views/group_configuration_details', 'js/views/group_configurations_list', 'js/views/group_configuration_editor',
'js/views/group_configuration_item', 'js/views/experiment_group_edit', 'js/views/content_group_list', 'js/views/group_configuration_item', 'js/views/experiment_group_edit', 'js/views/content_group_list',
'js/views/content_group_details', 'js/views/content_group_editor', 'js/views/content_group_item', 'js/views/content_group_details', 'js/views/content_group_editor', 'js/views/content_group_item',
'js/views/feedback_notification', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', 'js/views/feedback_notification', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec_helpers/view_helpers', 'jasmine-stealth' 'js/spec_helpers/view_helpers', 'jasmine-stealth'
], function( ], function(
_, Course, GroupConfigurationModel, GroupModel, GroupConfigurationCollection, GroupCollection, _, Course, GroupConfigurationModel, GroupModel, GroupConfigurationCollection, GroupCollection,
......
define(["js/views/license", "js/models/license", "js/common_helpers/template_helpers"], define(["js/views/license", "js/models/license", "common/js/spec_helpers/template_helpers"],
function(LicenseView, LicenseModel, TemplateHelpers) { function(LicenseView, LicenseModel, TemplateHelpers) {
describe("License view", function() { describe("License view", function() {
......
define(["jquery", "underscore", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers", define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
"js/views/modals/edit_xblock", "js/models/xblock_info"], "js/views/modals/edit_xblock", "js/models/xblock_info"],
function ($, _, AjaxHelpers, EditHelpers, EditXBlockModal, XBlockInfo) { function ($, _, AjaxHelpers, EditHelpers, EditXBlockModal, XBlockInfo) {
......
define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "URI", "js/models/xblock_info", define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "URI", "js/models/xblock_info",
"js/views/paged_container", "js/views/paging_header", "js/views/paging_footer", "js/views/xblock"], "js/views/paged_container", "common/js/components/views/paging_header",
"common/js/components/views/paging_footer", "js/views/xblock"],
function ($, _, AjaxHelpers, URI, XBlockInfo, PagedContainer, PagingHeader, PagingFooter, XBlockView) { function ($, _, AjaxHelpers, URI, XBlockInfo, PagedContainer, PagingHeader, PagingFooter, XBlockView) {
var htmlResponseTpl = _.template('' + var htmlResponseTpl = _.template('' +
...@@ -175,11 +176,6 @@ define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "URI", "js/mo ...@@ -175,11 +176,6 @@ define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "URI", "js/mo
}); });
describe("PagingHeader", function () { describe("PagingHeader", function () {
beforeEach(function () {
var pagingFooterTpl = readFixtures('paging-header.underscore');
appendSetFixtures($("<script>", { id: "paging-header-tpl", type: "text/template" }).text(pagingFooterTpl));
});
describe("Next page button", function () { describe("Next page button", function () {
beforeEach(function () { beforeEach(function () {
pagingContainer.render(); pagingContainer.render();
...@@ -331,11 +327,6 @@ define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "URI", "js/mo ...@@ -331,11 +327,6 @@ define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "URI", "js/mo
}); });
describe("PagingFooter", function () { describe("PagingFooter", function () {
beforeEach(function () {
var pagingFooterTpl = readFixtures('paging-footer.underscore');
appendSetFixtures($("<script>", { id: "paging-footer-tpl", type: "text/template" }).text(pagingFooterTpl));
});
describe("Next page button", function () { describe("Next page button", function () {
beforeEach(function () { beforeEach(function () {
// Render the page and header so that they can react to events // Render the page and header so that they can react to events
......
define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_helpers", define(["jquery", "underscore", "underscore.string", "common/js/spec_helpers/ajax_helpers",
"js/common_helpers/template_helpers", "js/spec_helpers/edit_helpers", "common/js/spec_helpers/template_helpers", "js/spec_helpers/edit_helpers",
"js/views/pages/container", "js/views/pages/paged_container", "js/models/xblock_info", "jquery.simulate"], "js/views/pages/container", "js/views/pages/paged_container", "js/models/xblock_info", "jquery.simulate"],
function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, ContainerPage, PagedContainerPage, XBlockInfo) { function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, ContainerPage, PagedContainerPage, XBlockInfo) {
......
define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_helpers", define(["jquery", "underscore", "underscore.string", "common/js/spec_helpers/ajax_helpers",
"js/common_helpers/template_helpers", "js/spec_helpers/edit_helpers", "common/js/spec_helpers/template_helpers", "js/spec_helpers/edit_helpers",
"js/views/feedback_prompt", "js/views/pages/container", "js/views/pages/container_subviews", "js/views/feedback_prompt", "js/views/pages/container", "js/views/pages/container_subviews",
"js/models/xblock_info", "js/views/utils/xblock_utils"], "js/models/xblock_info", "js/views/utils/xblock_utils"],
function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, Prompt, ContainerPage, ContainerSubviews, function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, Prompt, ContainerPage, ContainerSubviews,
......
define(["jquery", "sinon", "js/common_helpers/ajax_helpers", "js/views/utils/view_utils", "js/views/pages/course_outline", define(["jquery", "sinon", "common/js/spec_helpers/ajax_helpers", "js/views/utils/view_utils", "js/views/pages/course_outline",
"js/models/xblock_outline_info", "js/utils/date_utils", "js/spec_helpers/edit_helpers", "js/models/xblock_outline_info", "js/utils/date_utils", "js/spec_helpers/edit_helpers",
"js/common_helpers/template_helpers"], "common/js/spec_helpers/template_helpers"],
function($, Sinon, AjaxHelpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils, EditHelpers, TemplateHelpers) { function($, Sinon, AjaxHelpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils, EditHelpers, TemplateHelpers) {
describe("CourseOutlinePage", function() { describe("CourseOutlinePage", function() {
......
define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/views/course_rerun", define(["jquery", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/views/course_rerun",
"js/views/utils/create_course_utils", "js/views/utils/view_utils", "jquery.simulate"], "js/views/utils/create_course_utils", "js/views/utils/view_utils", "jquery.simulate"],
function ($, AjaxHelpers, ViewHelpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) { function ($, AjaxHelpers, ViewHelpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) {
describe("Create course rerun page", function () { describe("Create course rerun page", function () {
......
define([ define([
'jquery', 'underscore', 'js/views/pages/group_configurations', 'jquery', 'underscore', 'js/views/pages/group_configurations',
'js/models/group_configuration', 'js/collections/group_configuration', 'js/models/group_configuration', 'js/collections/group_configuration',
'js/common_helpers/template_helpers' 'common/js/spec_helpers/template_helpers'
], function ($, _, GroupConfigurationsPage, GroupConfigurationModel, GroupConfigurationCollection, TemplateHelpers) { ], function ($, _, GroupConfigurationsPage, GroupConfigurationModel, GroupConfigurationCollection, TemplateHelpers) {
'use strict'; 'use strict';
describe('GroupConfigurationsPage', function() { describe('GroupConfigurationsPage', function() {
......
define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/index", define(["jquery", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/index",
"js/views/utils/view_utils"], "js/views/utils/view_utils"],
function ($, AjaxHelpers, ViewHelpers, IndexUtils, ViewUtils) { function ($, AjaxHelpers, ViewHelpers, IndexUtils, ViewUtils) {
describe("Course listing page", function () { describe("Course listing page", function () {
......
define([ define([
"jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "jquery", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/view_helpers",
"js/factories/manage_users_lib", "js/views/utils/view_utils" "js/factories/manage_users_lib", "js/views/utils/view_utils"
], ],
function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) { function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
......
define( define(
["jquery", "underscore", "backbone", "js/views/previous_video_upload_list", "js/common_helpers/template_helpers"], ["jquery", "underscore", "backbone", "js/views/previous_video_upload_list", "common/js/spec_helpers/template_helpers"],
function($, _, Backbone, PreviousVideoUploadListView, TemplateHelpers) { function($, _, Backbone, PreviousVideoUploadListView, TemplateHelpers) {
"use strict"; "use strict";
describe("PreviousVideoUploadListView", function() { describe("PreviousVideoUploadListView", function() {
......
define( define(
["jquery", "backbone", "js/views/previous_video_upload", "js/common_helpers/template_helpers"], ["jquery", "backbone", "js/views/previous_video_upload", "common/js/spec_helpers/template_helpers"],
function($, Backbone, PreviousVideoUploadView, TemplateHelpers) { function($, Backbone, PreviousVideoUploadView, TemplateHelpers) {
"use strict"; "use strict";
describe("PreviousVideoUploadView", function() { describe("PreviousVideoUploadView", function() {
......
define([ define([
'jquery', 'js/models/settings/course_details', 'js/views/settings/main', 'jquery', 'js/models/settings/course_details', 'js/views/settings/main',
'js/common_helpers/ajax_helpers' 'common/js/spec_helpers/ajax_helpers'
], function($, CourseDetailsModel, MainView, AjaxHelpers) { ], function($, CourseDetailsModel, MainView, AjaxHelpers) {
'use strict'; 'use strict';
......
define(["jquery", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers", define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
"js/spec_helpers/view_helpers", "js/views/utils/view_utils", "js/views/unit_outline", "js/models/xblock_info"], "js/spec_helpers/view_helpers", "js/views/utils/view_utils", "js/views/unit_outline", "js/models/xblock_info"],
function ($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils, UnitOutlineView, XBlockInfo) { function ($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils, UnitOutlineView, XBlockInfo) {
......
define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers", define([ "jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
"js/views/xblock_editor", "js/models/xblock_info"], "js/views/xblock_editor", "js/models/xblock_info"],
function ($, _, AjaxHelpers, EditHelpers, XBlockEditorView, XBlockInfo) { function ($, _, AjaxHelpers, EditHelpers, XBlockEditorView, XBlockInfo) {
......
define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/xblock", "js/models/xblock_info", define([ "jquery", "common/js/spec_helpers/ajax_helpers", "URI", "js/views/xblock", "js/models/xblock_info",
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"], "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
function ($, AjaxHelpers, URI, XBlockView, XBlockInfo) { function ($, AjaxHelpers, URI, XBlockView, XBlockInfo) {
......
define(["jquery", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers", define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
"js/spec_helpers/edit_helpers", "js/models/xblock_info", "js/views/xblock_string_field_editor"], "js/spec_helpers/edit_helpers", "js/models/xblock_info", "js/views/xblock_string_field_editor"],
function ($, AjaxHelpers, TemplateHelpers, EditHelpers, XBlockInfo, XBlockStringFieldEditor) { function ($, AjaxHelpers, TemplateHelpers, EditHelpers, XBlockInfo, XBlockStringFieldEditor) {
describe("XBlockStringFieldEditorView", function () { describe("XBlockStringFieldEditorView", function () {
......
define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', 'js/common_helpers/template_helpers'], define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', 'common/js/spec_helpers/template_helpers'],
function($, XBlockValidationModel, XBlockValidationView, TemplateHelpers) { function($, XBlockValidationModel, XBlockValidationView, TemplateHelpers) {
beforeEach(function () { beforeEach(function () {
......
/** /**
* Provides helper methods for invoking Studio modal windows in Jasmine tests. * Provides helper methods for invoking Studio modal windows in Jasmine tests.
*/ */
define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", "js/common_helpers/template_helpers"], define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", "common/js/spec_helpers/template_helpers"],
function($, NotificationView, Prompt, TemplateHelpers) { function($, NotificationView, Prompt, TemplateHelpers) {
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing, var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing, verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
......
/** /**
* Provides helper methods for invoking Studio editors in Jasmine tests. * Provides helper methods for invoking Studio editors in Jasmine tests.
*/ */
define(["jquery", "underscore", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers", define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
"js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock", "js/collections/component_template", "js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock", "js/collections/component_template",
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"], "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) { function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) {
......
/** /**
* Provides helper methods for invoking Studio modal windows in Jasmine tests. * Provides helper methods for invoking Studio modal windows in Jasmine tests.
*/ */
define(["jquery", "js/common_helpers/template_helpers", "js/spec_helpers/view_helpers"], define(["jquery", "common/js/spec_helpers/template_helpers", "js/spec_helpers/view_helpers"],
function($, TemplateHelpers, ViewHelpers) { function($, TemplateHelpers, ViewHelpers) {
var installModalTemplates, getModalElement, getModalTitle, isShowingModal, hideModalIfShowing, var installModalTemplates, getModalElement, getModalTitle, isShowingModal, hideModalIfShowing,
pressModalButton, cancelModal, cancelModalIfShowing; pressModalButton, cancelModal, cancelModalIfShowing;
......
/** /**
* Provides helper methods for invoking Validation modal in Jasmine tests. * Provides helper methods for invoking Validation modal in Jasmine tests.
*/ */
define(['jquery', 'js/spec_helpers/modal_helpers', 'js/common_helpers/template_helpers'], define(['jquery', 'js/spec_helpers/modal_helpers', 'common/js/spec_helpers/template_helpers'],
function($, ModalHelpers, TemplateHelpers) { function($, ModalHelpers, TemplateHelpers) {
var installValidationTemplates, checkErrorContents, undoChanges; var installValidationTemplates, checkErrorContents, undoChanges;
......
/** /**
* Provides helper methods for invoking Studio modal windows in Jasmine tests. * Provides helper methods for invoking Studio modal windows in Jasmine tests.
*/ */
define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", 'js/common_helpers/ajax_helpers', define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", 'common/js/spec_helpers/ajax_helpers',
"js/common_helpers/template_helpers"], "common/js/spec_helpers/template_helpers"],
function($, NotificationView, Prompt, AjaxHelpers, TemplateHelpers) { function($, NotificationView, Prompt, AjaxHelpers, TemplateHelpers) {
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing, var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing, verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
......
define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", "js/views/asset", define(["jquery", "underscore", "gettext", "js/views/baseview", "js/models/asset", "common/js/components/views/paging",
"js/views/paging_header", "js/views/paging_footer", "js/utils/modal", "js/views/utils/view_utils", "js/views/asset", "common/js/components/views/paging_header", "common/js/components/views/paging_footer",
"js/views/feedback_notification", "jquery.fileupload-process", "jquery.fileupload-validate"], "js/utils/modal", "js/views/utils/view_utils", "js/views/feedback_notification",
function($, _, gettext, AssetModel, PagingView, AssetView, PagingHeader, PagingFooter, ModalUtils, ViewUtils, NotificationView) { "text!templates/asset-library.underscore",
"jquery.fileupload-process", "jquery.fileupload-validate"],
function($, _, gettext, BaseView, AssetModel, PagingView, AssetView, PagingHeader, PagingFooter,
ModalUtils, ViewUtils, NotificationView, asset_library_template) {
var CONVERSION_FACTOR_MBS_TO_BYTES = 1000 * 1000; var CONVERSION_FACTOR_MBS_TO_BYTES = 1000 * 1000;
var AssetsView = PagingView.extend({ var AssetsView = BaseView.extend({
// takes AssetCollection as model // takes AssetCollection as model
events : { events : {
...@@ -19,21 +22,14 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -19,21 +22,14 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
allLabel: 'ALL', allLabel: 'ALL',
initialize : function(options) { initialize : function(options) {
options = options || {}; options = options || {};
PagingView.prototype.initialize.call(this); BaseView.prototype.initialize.call(this);
var collection = this.collection; var collection = this.collection;
this.template = this.loadTemplate("asset-library"); this.pagingView = this.createPagingView();
this.listenTo(collection, 'destroy', this.handleDestroy); this.listenTo(collection, 'destroy', this.handleDestroy);
this.registerSortableColumn('js-asset-name-col', gettext('Name'), 'display_name', 'asc');
this.registerSortableColumn('js-asset-date-col', gettext('Date Added'), 'date_added', 'desc');
this.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type');
this.setInitialSortColumn('js-asset-date-col');
this.setInitialFilterColumn('js-asset-type-col');
ViewUtils.showLoadingIndicator(); ViewUtils.showLoadingIndicator();
this.setPage(0);
// set default file size for uploads via template var, // set default file size for uploads via template var,
// and default to static old value if none exists // and default to static old value if none exists
this.uploadChunkSizeInMBs = options.uploadChunkSizeInMBs || 10; this.uploadChunkSizeInMBs = options.uploadChunkSizeInMBs || 10;
...@@ -41,66 +37,81 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -41,66 +37,81 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
this.uploadChunkSizeInBytes = this.uploadChunkSizeInMBs * CONVERSION_FACTOR_MBS_TO_BYTES; this.uploadChunkSizeInBytes = this.uploadChunkSizeInMBs * CONVERSION_FACTOR_MBS_TO_BYTES;
this.maxFileSizeInBytes = this.maxFileSizeInMBs * CONVERSION_FACTOR_MBS_TO_BYTES; this.maxFileSizeInBytes = this.maxFileSizeInMBs * CONVERSION_FACTOR_MBS_TO_BYTES;
this.maxFileSizeRedirectUrl = options.maxFileSizeRedirectUrl || ''; this.maxFileSizeRedirectUrl = options.maxFileSizeRedirectUrl || '';
assetsView = this;
// error message modal for large file uploads // error message modal for large file uploads
this.largeFileErrorMsg = null; this.largeFileErrorMsg = null;
}, },
render: function() { PagingAssetView: PagingView.extend({
// Wait until the content is loaded the first time to render renderPageItems: function() {
return this; var self = this,
}, assets = this.collection,
hasAssets = this.collection.assetType !== '' || assets.length > 0,
afterRender: function(){ tableBody = this.getTableBody();
// Bind events with html elements tableBody.empty();
$('li a.upload-button').on('click', this.showUploadModal); if (hasAssets) {
$('.upload-modal .close-button').on('click', this.hideModal); assets.each(
$('.upload-modal .choose-file-button').on('click', this.showFileSelectionMenu); function(asset) {
return this; var view = new AssetView({model: asset});
}, tableBody.append(view.render().el);
}
);
}
self.$('.assets-library').toggle(hasAssets);
self.$('.no-asset-content').toggle(!hasAssets);
return this;
},
getTableBody: function() {
var tableBody = this.tableBody;
if (!tableBody) {
ViewUtils.hideLoadingIndicator();
// Create the table
this.$el.html(_.template(asset_library_template, {typeData: this.typeData}));
tableBody = this.$('#asset-table-body');
this.tableBody = tableBody;
this.pagingHeader = new PagingHeader({view: this, el: $('#asset-paging-header')});
this.pagingFooter = new PagingFooter({view: this, el: $('#asset-paging-footer')});
this.pagingHeader.render();
this.pagingFooter.render();
// Hide the contents until the collection has loaded the first time
this.$('.assets-library').hide();
this.$('.no-asset-content').hide();
}
return tableBody;
},
getTableBody: function() { onError: function() {
var tableBody = this.tableBody;
if (!tableBody) {
ViewUtils.hideLoadingIndicator(); ViewUtils.hideLoadingIndicator();
// Create the table
this.$el.html(this.template({typeData: this.typeData}));
tableBody = this.$('#asset-table-body');
this.tableBody = tableBody;
this.pagingHeader = new PagingHeader({view: this, el: $('#asset-paging-header')});
this.pagingFooter = new PagingFooter({view: this, el: $('#asset-paging-footer')});
this.pagingHeader.render();
this.pagingFooter.render();
// Hide the contents until the collection has loaded the first time
this.$('.assets-library').hide();
this.$('.no-asset-content').hide();
} }
return tableBody; }),
createPagingView: function() {
var pagingView = new this.PagingAssetView({
el: this.$el,
collection: this.collection
});
pagingView.registerSortableColumn('js-asset-name-col', gettext('Name'), 'display_name', 'asc');
pagingView.registerSortableColumn('js-asset-date-col', gettext('Date Added'), 'date_added', 'desc');
pagingView.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type');
pagingView.setInitialSortColumn('js-asset-date-col');
pagingView.setInitialFilterColumn('js-asset-type-col');
pagingView.setPage(0);
return pagingView;
}, },
renderPageItems: function() { render: function() {
var self = this, this.pagingView.render();
assets = this.collection,
hasAssets = this.collection.assetType !== '' || assets.length > 0,
tableBody = this.getTableBody();
tableBody.empty();
if (hasAssets) {
assets.each(
function(asset) {
var view = new AssetView({model: asset});
tableBody.append(view.render().el);
}
);
}
self.$('.assets-library').toggle(hasAssets);
self.$('.no-asset-content').toggle(!hasAssets);
return this; return this;
}, },
onError: function() { afterRender: function(){
ViewUtils.hideLoadingIndicator(); // Bind events with html elements
$('li a.upload-button').on('click', _.bind(this.showUploadModal, this));
$('.upload-modal .close-button').on('click', _.bind(this.hideModal, this));
$('.upload-modal .choose-file-button').on('click', _.bind(this.showFileSelectionMenu, this));
return this;
}, },
handleDestroy: function(model) { handleDestroy: function(model) {
...@@ -114,9 +125,9 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -114,9 +125,9 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
addAsset: function (model) { addAsset: function (model) {
// Switch the sort column back to the default (most recent date added) and show the first page // Switch the sort column back to the default (most recent date added) and show the first page
// so that the new asset is shown at the top of the page. // so that the new asset is shown at the top of the page.
this.setInitialSortColumn('js-asset-date-col'); this.pagingView.setInitialSortColumn('js-asset-date-col');
this.setInitialFilterColumn('js-asset-type-col'); this.pagingView.setInitialFilterColumn('js-asset-type-col');
this.setPage(0); this.pagingView.setPage(0);
analytics.track('Uploaded a File', { analytics.track('Uploaded a File', {
'course': course_location_analytics, 'course': course_location_analytics,
...@@ -126,7 +137,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -126,7 +137,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
onToggleColumn: function(event) { onToggleColumn: function(event) {
var columnName = event.target.id; var columnName = event.target.id;
this.toggleSortOrder(columnName); this.pagingView.toggleSortOrder(columnName);
}, },
onFilterColumn: function(event) { onFilterColumn: function(event) {
...@@ -140,13 +151,13 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -140,13 +151,13 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
} }
$('.file-input').unbind('change.startUpload'); $('.file-input').unbind('change.startUpload');
ModalUtils.hideModal(); ModalUtils.hideModal();
if (assetsView.largeFileErrorMsg) { if (this.largeFileErrorMsg) {
assetsView.largeFileErrorMsg.hide(); this.largeFileErrorMsg.hide();
} }
}, },
showUploadModal: function (event) { showUploadModal: function (event) {
var self = assetsView; var self = this;
event.preventDefault(); event.preventDefault();
self.resetUploadModal(); self.resetUploadModal();
ModalUtils.showModal(); ModalUtils.showModal();
...@@ -180,33 +191,33 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -180,33 +191,33 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
error = error + " " + instructions; error = error + " " + instructions;
} }
assetsView.largeFileErrorMsg = new NotificationView.Error({ self.largeFileErrorMsg = new NotificationView.Error({
"title": gettext("Your file could not be uploaded"), "title": gettext("Your file could not be uploaded"),
"message": error "message": error
}); });
assetsView.largeFileErrorMsg.show(); self.largeFileErrorMsg.show();
assetsView.displayFailedUpload({ self.displayFailedUpload({
"msg": gettext("Max file size exceeded") "msg": gettext("Max file size exceeded")
}); });
}, },
processdone: function(event, data) { processdone: function(event, data) {
assetsView.largeFileErrorMsg = null; self.largeFileErrorMsg = null;
} }
}); });
}, },
showFileSelectionMenu: function(event) { showFileSelectionMenu: function(event) {
event.preventDefault(); event.preventDefault();
if (assetsView.largeFileErrorMsg) { if (this.largeFileErrorMsg) {
assetsView.largeFileErrorMsg.hide(); this.largeFileErrorMsg.hide();
} }
$('.file-input').click(); $('.file-input').click();
}, },
startUpload: function (event) { startUpload: function (event) {
var file = event.target.value; var file = event.target.value;
if (!assetsView.largeFileErrorMsg) { if (!this.largeFileErrorMsg) {
$('.upload-modal h1').text(gettext('Uploading')); $('.upload-modal h1').text(gettext('Uploading'));
$('.upload-modal .file-name').html(file.substring(file.lastIndexOf("\\") + 1)); $('.upload-modal .file-name').html(file.substring(file.lastIndexOf("\\") + 1));
$('.upload-modal .choose-file-button').hide(); $('.upload-modal .choose-file-button').hide();
...@@ -228,7 +239,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -228,7 +239,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
$('.upload-modal .embeddable-xml-input').val(''); $('.upload-modal .embeddable-xml-input').val('');
$('.upload-modal .embeddable').hide(); $('.upload-modal .embeddable').hide();
assetsView.largeFileErrorMsg = null; this.largeFileErrorMsg = null;
}, },
showUploadFeedback: function (event, percentComplete) { showUploadFeedback: function (event, percentComplete) {
...@@ -285,8 +296,8 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -285,8 +296,8 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
title.addClass('column-selected-link'); title.addClass('column-selected-link');
} }
this.filterableColumns['js-asset-type-col'].displayName = assettypeLabel; this.pagingView.filterableColumns['js-asset-type-col'].displayName = assettypeLabel;
this.selectFilter('js-asset-type-col'); this.pagingView.selectFilter('js-asset-type-col');
this.closeFilterPopup(this.$el.find( this.closeFilterPopup(this.$el.find(
'.column-filter-link[data-assetfilter="' + assettype + '"]')); '.column-filter-link[data-assetfilter="' + assettype + '"]'));
}, },
...@@ -307,7 +318,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging", ...@@ -307,7 +318,7 @@ define(["jquery", "underscore", "gettext", "js/models/asset", "js/views/paging",
$('.upload-modal .choose-file-button').text(gettext('Load Another File')).show(); $('.upload-modal .choose-file-button').text(gettext('Load Another File')).show();
$('.upload-modal .progress-fill').width('100%'); $('.upload-modal .progress-fill').width('100%');
assetsView.addAsset(new AssetModel(asset)); this.addAsset(new AssetModel(asset));
}, },
displayFailedUpload: function (resp) { displayFailedUpload: function (resp) {
......
define(["jquery", "underscore", "js/views/utils/view_utils", "js/views/container", "js/utils/module", "gettext", define(["jquery", "underscore", "js/views/utils/view_utils", "js/views/container", "js/utils/module", "gettext",
"js/views/feedback_notification", "js/views/paging_header", "js/views/paging_footer", "js/views/paging_mixin"], "js/views/feedback_notification", "common/js/components/views/paging_header",
"common/js/components/views/paging_footer", "common/js/components/views/paging_mixin"],
function ($, _, ViewUtils, ContainerView, ModuleUtils, gettext, NotificationView, PagingHeader, PagingFooter, PagingMixin) { function ($, _, ViewUtils, ContainerView, ModuleUtils, gettext, NotificationView, PagingHeader, PagingFooter, PagingMixin) {
var PagedContainerView = ContainerView.extend(PagingMixin).extend({ var PagedContainerView = ContainerView.extend(PagingMixin).extend({
initialize: function(options){ initialize: function(options){
......
...@@ -70,14 +70,15 @@ lib_paths: ...@@ -70,14 +70,15 @@ lib_paths:
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js - xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js - xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js
- xmodule_js/common_static/js/vendor/mock-ajax.js - xmodule_js/common_static/js/vendor/mock-ajax.js
- xmodule_js/common_static/js/vendor/requirejs/text.js
# Paths to source JavaScript files # Paths to source JavaScript files
src_paths: src_paths:
- coffee/src - coffee/src
- js - js
- js/common_helpers
- js/factories
- js/certificates - js/certificates
- js/factories
- common/js
# Paths to spec (test) JavaScript files # Paths to spec (test) JavaScript files
# We should define the custom path mapping in /coffee/spec/main.coffee as well e.g. certificates etc. # We should define the custom path mapping in /coffee/spec/main.coffee as well e.g. certificates etc.
...@@ -98,6 +99,8 @@ spec_paths: ...@@ -98,6 +99,8 @@ spec_paths:
# #
fixture_paths: fixture_paths:
- coffee/fixtures - coffee/fixtures
- templates
- common/templates
requirejs: requirejs:
paths: paths:
......
...@@ -62,12 +62,13 @@ lib_paths: ...@@ -62,12 +62,13 @@ lib_paths:
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js - xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js - xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process.js
- xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js - xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate.js
- xmodule_js/common_static/js/vendor/requirejs/text.js
# Paths to source JavaScript files # Paths to source JavaScript files
src_paths: src_paths:
- coffee/src - coffee/src
- js - js
- js/common_helpers - common/js
# Paths to spec (test) JavaScript files # Paths to spec (test) JavaScript files
spec_paths: spec_paths:
...@@ -86,6 +87,8 @@ spec_paths: ...@@ -86,6 +87,8 @@ spec_paths:
# #
fixture_paths: fixture_paths:
- coffee/fixtures - coffee/fixtures
- templates
- common/templates
requirejs: requirejs:
paths: paths:
......
...@@ -27,6 +27,7 @@ require.config({ ...@@ -27,6 +27,7 @@ require.config({
"jquery.immediateDescendents": "coffee/src/jquery.immediateDescendents", "jquery.immediateDescendents": "coffee/src/jquery.immediateDescendents",
"datepair": "js/vendor/timepicker/datepair", "datepair": "js/vendor/timepicker/datepair",
"date": "js/vendor/date", "date": "js/vendor/date",
"text": 'js/vendor/requirejs/text',
"moment": "js/vendor/moment.min", "moment": "js/vendor/moment.min",
"underscore": "js/vendor/underscore-min", "underscore": "js/vendor/underscore-min",
"underscore.string": "js/vendor/underscore.string.min", "underscore.string": "js/vendor/underscore.string.min",
......
../templates/js
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<%namespace name='static' file='static_content.html'/> <%namespace name='static' file='static_content.html'/>
<%block name="header_extras"> <%block name="header_extras">
% for template_name in ["asset-library", "asset", "paging-header", "paging-footer"]: % for template_name in ["asset-library", "asset"]:
<script type="text/template" id="${template_name}-tpl"> <script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" /> <%static:include path="js/${template_name}.underscore" />
</script> </script>
......
...@@ -24,6 +24,9 @@ from django.utils.translation import ugettext as _ ...@@ -24,6 +24,9 @@ from django.utils.translation import ugettext as _
<%static:include path="js/${template_name}.underscore" /> <%static:include path="js/${template_name}.underscore" />
</script> </script>
% endfor % endfor
<script type="text/template" id="image-modal-tpl">
<%static:include path="common/templates/image-modal.underscore" />
</script>
<link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" /> <link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
</%block> </%block>
......
...@@ -13,39 +13,6 @@ ...@@ -13,39 +13,6 @@
<div class="xblock" data-locator="locator-container" data-request-token="page-render-token" <div class="xblock" data-locator="locator-container" data-request-token="page-render-token"
data-init="MockXBlock" data-runtime-class="StudioRuntime" data-runtime-version="1"> data-init="MockXBlock" data-runtime-class="StudioRuntime" data-runtime-version="1">
<script type="text/template" id="paging-header-tpl">
<div class="meta-wrap">
<div class="meta">
<%= messageHtml %>
</div>
<nav class="pagination pagination-compact top">
<ol>
<li class="nav-item previous"><a class="nav-link previous-page-link" href="#"><i class="icon fa fa-angle-left"></i> <span class="nav-label">Previous</span></a></li>
<li class="nav-item next"><a class="nav-link next-page-link" href="#"><span class="nav-label">Next</span> <i class="icon fa fa-angle-right"></i></a></li>
</ol>
</nav>
</div>
</script>
<script type="text/template" id="paging-footer-tpl">
<nav class="pagination pagination-full bottom">
<ol>
<li class="nav-item previous"><a class="nav-link previous-page-link" href="#"><i class="icon fa fa-angle-left"></i> <span class="nav-label">Previous</span></a></li>
<li class="nav-item page">
<div class="pagination-form">
<label class="page-number-label" for="page-number">Page number</label>
<input id="page-number-input" class="page-number-input" name="page-number" type="text" size="4" />
</div>
<span class="current-page"><%= current_page + 1 %></span>
<span class="page-divider">/</span>
<span class="total-pages"><%= total_pages %></span>
</li>
<li class="nav-item next"><a class="nav-link next-page-link" href="#"><span class="nav-label">Next</span> <i class="icon fa fa-angle-right"></i></a></li>
</ol>
</nav>
</script>
<div class="container-paging-header"></div> <div class="container-paging-header"></div>
<div class="studio-xblock-wrapper" data-locator="locator-group-A"> <div class="studio-xblock-wrapper" data-locator="locator-group-A">
......
...@@ -13,39 +13,6 @@ ...@@ -13,39 +13,6 @@
<div class="xblock" data-locator="locator-container" data-request-token="page-render-token" <div class="xblock" data-locator="locator-container" data-request-token="page-render-token"
data-init="MockXBlock" data-runtime-class="StudioRuntime" data-runtime-version="1"> data-init="MockXBlock" data-runtime-class="StudioRuntime" data-runtime-version="1">
<script type="text/template" id="paging-header-tpl">
<div class="meta-wrap">
<div class="meta">
<%= messageHtml %>
</div>
<nav class="pagination pagination-compact top">
<ol>
<li class="nav-item previous"><a class="nav-link previous-page-link" href="#"><i class="icon fa fa-angle-left"></i> <span class="nav-label">Previous</span></a></li>
<li class="nav-item next"><a class="nav-link next-page-link" href="#"><span class="nav-label">Next</span> <i class="icon fa fa-angle-right"></i></a></li>
</ol>
</nav>
</div>
</script>
<script type="text/template" id="paging-footer-tpl">
<nav class="pagination pagination-full bottom">
<ol>
<li class="nav-item previous"><a class="nav-link previous-page-link" href="#"><i class="icon fa fa-angle-left"></i> <span class="nav-label">Previous</span></a></li>
<li class="nav-item page">
<div class="pagination-form">
<label class="page-number-label" for="page-number">Page number</label>
<input id="page-number-input" class="page-number-input" name="page-number" type="text" size="4" />
</div>
<span class="current-page"><%= current_page + 1 %></span>
<span class="page-divider">/</span>
<span class="total-pages"><%= total_pages %></span>
</li>
<li class="nav-item next"><a class="nav-link next-page-link" href="#"><span class="nav-label">Next</span> <i class="icon fa fa-angle-right"></i></a></li>
</ol>
</nav>
</script>
<div class="container-paging-header"></div> <div class="container-paging-header"></div>
<div class="studio-xblock-wrapper" data-locator="locator-group-A"> <div class="studio-xblock-wrapper" data-locator="locator-group-A">
......
...@@ -17,6 +17,9 @@ from django.utils.translation import ugettext as _ ...@@ -17,6 +17,9 @@ from django.utils.translation import ugettext as _
<%static:include path="js/${template_name}.underscore" /> <%static:include path="js/${template_name}.underscore" />
</script> </script>
% endfor % endfor
<script type="text/template" id="image-modal-tpl">
<%static:include path="common/templates/image-modal.underscore" />
</script>
</%block> </%block>
<%block name="requirejs"> <%block name="requirejs">
......
...@@ -38,7 +38,7 @@ class @DiscussionSpecHelper ...@@ -38,7 +38,7 @@ class @DiscussionSpecHelper
@setUnderscoreFixtures = -> @setUnderscoreFixtures = ->
for templateName in ['thread-show'] for templateName in ['thread-show']
templateFixture = readFixtures('templates/discussion/' + templateName + '.underscore') templateFixture = readFixtures('common/templates/discussion/' + templateName + '.underscore')
appendSetFixtures($('<script>', { id: templateName + '-template', type: 'text/template' }) appendSetFixtures($('<script>', { id: templateName + '-template', type: 'text/template' })
.text(templateFixture)) .text(templateFixture))
appendSetFixtures(""" appendSetFixtures("""
......
define(["underscore", "js/views/baseview", "js/views/feedback_alert", "gettext", "js/views/paging_mixin"], define(["underscore", "backbone", "gettext", "common/js/components/views/paging_mixin"],
function(_, BaseView, AlertView, gettext, PagingMixin) { function(_, Backbone, gettext, PagingMixin) {
var PagingView = BaseView.extend(PagingMixin).extend({ var PagingView = Backbone.View.extend(PagingMixin).extend({
// takes a Backbone Paginator as a model // takes a Backbone Paginator as a model
sortableColumns: {}, sortableColumns: {},
...@@ -11,7 +11,7 @@ define(["underscore", "js/views/baseview", "js/views/feedback_alert", "gettext", ...@@ -11,7 +11,7 @@ define(["underscore", "js/views/baseview", "js/views/feedback_alert", "gettext",
filterColumn: '', filterColumn: '',
initialize: function() { initialize: function() {
BaseView.prototype.initialize.call(this); Backbone.View.prototype.initialize.call(this);
var collection = this.collection; var collection = this.collection;
collection.bind('add', _.bind(this.onPageRefresh, this)); collection.bind('add', _.bind(this.onPageRefresh, this));
collection.bind('remove', _.bind(this.onPageRefresh, this)); collection.bind('remove', _.bind(this.onPageRefresh, this));
......
define(["underscore", "js/views/baseview"], function(_, BaseView) { define(["underscore", "backbone", "text!common/templates/components/paging-footer.underscore"],
function(_, Backbone, paging_footer_template) {
var PagingFooter = BaseView.extend({ var PagingFooter = Backbone.View.extend({
events : { events : {
"click .next-page-link": "nextPage", "click .next-page-link": "nextPage",
"click .previous-page-link": "previousPage", "click .previous-page-link": "previousPage",
"change .page-number-input": "changePage" "change .page-number-input": "changePage"
}, },
initialize: function(options) { initialize: function(options) {
var view = options.view, var view = options.view,
collection = view.collection; collection = view.collection;
this.view = view; this.view = view;
this.template = this.loadTemplate('paging-footer'); collection.bind('add', _.bind(this.render, this));
collection.bind('add', _.bind(this.render, this)); collection.bind('remove', _.bind(this.render, this));
collection.bind('remove', _.bind(this.render, this)); collection.bind('reset', _.bind(this.render, this));
collection.bind('reset', _.bind(this.render, this)); this.render();
this.render(); },
},
render: function() { render: function() {
var view = this.view, var view = this.view,
collection = view.collection, collection = view.collection,
currentPage = collection.currentPage, currentPage = collection.currentPage,
lastPage = collection.totalPages - 1; lastPage = collection.totalPages - 1;
this.$el.html(this.template({ this.$el.html(_.template(paging_footer_template, {
current_page: collection.currentPage, current_page: collection.currentPage,
total_pages: collection.totalPages total_pages: collection.totalPages
})); }));
this.$(".previous-page-link").toggleClass("is-disabled", currentPage === 0).attr('aria-disabled', currentPage === 0);; this.$(".previous-page-link").toggleClass("is-disabled", currentPage === 0).attr('aria-disabled', currentPage === 0);;
this.$(".next-page-link").toggleClass("is-disabled", currentPage === lastPage).attr('aria-disabled', currentPage === lastPage); this.$(".next-page-link").toggleClass("is-disabled", currentPage === lastPage).attr('aria-disabled', currentPage === lastPage);
return this; return this;
}, },
changePage: function() { changePage: function() {
var view = this.view, var view = this.view,
collection = view.collection, collection = view.collection,
currentPage = collection.currentPage + 1, currentPage = collection.currentPage + 1,
pageInput = this.$("#page-number-input"), pageInput = this.$("#page-number-input"),
pageNumber = parseInt(pageInput.val(), 10); pageNumber = parseInt(pageInput.val(), 10);
if (pageNumber > collection.totalPages) { if (pageNumber > collection.totalPages) {
pageNumber = false; pageNumber = false;
} }
if (pageNumber <= 0) { if (pageNumber <= 0) {
pageNumber = false; pageNumber = false;
} }
// If we still have a page number by this point, // If we still have a page number by this point,
// and it's not the current page, load it. // and it's not the current page, load it.
if (pageNumber && pageNumber !== currentPage) { if (pageNumber && pageNumber !== currentPage) {
view.setPage(pageNumber - 1); view.setPage(pageNumber - 1);
} }
pageInput.val(""); // Clear the value as the label will show beneath it pageInput.val(""); // Clear the value as the label will show beneath it
}, },
nextPage: function() { nextPage: function() {
this.view.nextPage(); this.view.nextPage();
}, },
previousPage: function() { previousPage: function() {
this.view.previousPage(); this.view.previousPage();
} }
}); });
return PagingFooter; return PagingFooter;
}); // end define(); }); // end define();
define(["underscore", "gettext", "js/views/baseview"], function(_, gettext, BaseView) { define(["underscore", "backbone", "gettext", "text!common/templates/components/paging-header.underscore"],
function(_, Backbone, gettext, paging_header_template) {
var PagingHeader = BaseView.extend({ var PagingHeader = Backbone.View.extend({
events : { events : {
"click .next-page-link": "nextPage", "click .next-page-link": "nextPage",
"click .previous-page-link": "previousPage" "click .previous-page-link": "previousPage"
}, },
initialize: function(options) { initialize: function(options) {
var view = options.view, var view = options.view,
collection = view.collection; collection = view.collection;
this.view = view; this.view = view;
this.template = this.loadTemplate('paging-header'); collection.bind('add', _.bind(this.render, this));
collection.bind('add', _.bind(this.render, this)); collection.bind('remove', _.bind(this.render, this));
collection.bind('remove', _.bind(this.render, this)); collection.bind('reset', _.bind(this.render, this));
collection.bind('reset', _.bind(this.render, this)); },
},
render: function() { render: function() {
var view = this.view, var view = this.view,
collection = view.collection, collection = view.collection,
currentPage = collection.currentPage, currentPage = collection.currentPage,
lastPage = collection.totalPages - 1, lastPage = collection.totalPages - 1,
messageHtml = this.messageHtml(); messageHtml = this.messageHtml();
this.$el.html(this.template({ this.$el.html(_.template(paging_header_template, {
messageHtml: messageHtml messageHtml: messageHtml
})); }));
this.$(".previous-page-link").toggleClass("is-disabled", currentPage === 0).attr('aria-disabled', currentPage === 0); this.$(".previous-page-link").toggleClass("is-disabled", currentPage === 0).attr('aria-disabled', currentPage === 0);
this.$(".next-page-link").toggleClass("is-disabled", currentPage === lastPage).attr('aria-disabled', currentPage === lastPage); this.$(".next-page-link").toggleClass("is-disabled", currentPage === lastPage).attr('aria-disabled', currentPage === lastPage);
return this; return this;
}, },
messageHtml: function() { messageHtml: function() {
var message = ''; var message = '';
var asset_type = false; var asset_type = false;
if (this.view.collection.assetType) { if (this.view.collection.assetType) {
if (this.view.collection.sortDirection === 'asc') { if (this.view.collection.sortDirection === 'asc') {
// Translators: sample result: // Translators: sample result:
// "Showing 0-9 out of 25 total, filtered by Images, sorted by Date Added ascending" // "Showing 0-9 out of 25 total, filtered by Images, sorted by Date Added ascending"
message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, filtered by %(asset_type)s, sorted by %(sort_name)s ascending'); message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, filtered by %(asset_type)s, sorted by %(sort_name)s ascending');
} else { } else {
// Translators: sample result: // Translators: sample result:
// "Showing 0-9 out of 25 total, filtered by Images, sorted by Date Added descending" // "Showing 0-9 out of 25 total, filtered by Images, sorted by Date Added descending"
message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, filtered by %(asset_type)s, sorted by %(sort_name)s descending'); message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, filtered by %(asset_type)s, sorted by %(sort_name)s descending');
}
asset_type = this.filterNameLabel();
} }
asset_type = this.filterNameLabel(); else {
} if (this.view.collection.sortDirection === 'asc') {
else { // Translators: sample result:
if (this.view.collection.sortDirection === 'asc') { // "Showing 0-9 out of 25 total, sorted by Date Added ascending"
// Translators: sample result: message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s ascending');
// "Showing 0-9 out of 25 total, sorted by Date Added ascending" } else {
message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s ascending'); // Translators: sample result:
} else { // "Showing 0-9 out of 25 total, sorted by Date Added descending"
// Translators: sample result: message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s descending');
// "Showing 0-9 out of 25 total, sorted by Date Added descending" }
message = gettext('Showing %(current_item_range)s out of %(total_items_count)s, sorted by %(sort_name)s descending');
} }
}
return '<p>' + interpolate(message, { return '<p>' + interpolate(message, {
current_item_range: this.currentItemRangeLabel(), current_item_range: this.currentItemRangeLabel(),
total_items_count: this.totalItemsCountLabel(), total_items_count: this.totalItemsCountLabel(),
asset_type: asset_type, asset_type: asset_type,
sort_name: this.sortNameLabel() sort_name: this.sortNameLabel()
}, true) + "</p>"; }, true) + "</p>";
}, },
currentItemRangeLabel: function() { currentItemRangeLabel: function() {
var view = this.view, var view = this.view,
collection = view.collection, collection = view.collection,
start = collection.start, start = collection.start,
count = collection.size(), count = collection.size(),
end = start + count; end = start + count;
return interpolate('<span class="count-current-shown">%(start)s-%(end)s</span>', { return interpolate('<span class="count-current-shown">%(start)s-%(end)s</span>', {
start: Math.min(start + 1, end), start: Math.min(start + 1, end),
end: end end: end
}, true); }, true);
}, },
totalItemsCountLabel: function() { totalItemsCountLabel: function() {
var totalItemsLabel; var totalItemsLabel;
// Translators: turns into "25 total" to be used in other sentences, e.g. "Showing 0-9 out of 25 total". // Translators: turns into "25 total" to be used in other sentences, e.g. "Showing 0-9 out of 25 total".
totalItemsLabel = interpolate(gettext('%(total_items)s total'), { totalItemsLabel = interpolate(gettext('%(total_items)s total'), {
total_items: this.view.collection.totalCount total_items: this.view.collection.totalCount
}, true); }, true);
return interpolate('<span class="count-total">%(total_items_label)s</span>', { return interpolate('<span class="count-total">%(total_items_label)s</span>', {
total_items_label: totalItemsLabel total_items_label: totalItemsLabel
}, true); }, true);
}, },
sortNameLabel: function() { sortNameLabel: function() {
return interpolate('<span class="sort-order">%(sort_name)s</span>', { return interpolate('<span class="sort-order">%(sort_name)s</span>', {
sort_name: this.view.sortDisplayName() sort_name: this.view.sortDisplayName()
}, true); }, true);
}, },
filterNameLabel: function() { filterNameLabel: function() {
return interpolate('<span class="filter-column">%(filter_name)s</span>', { return interpolate('<span class="filter-column">%(filter_name)s</span>', {
filter_name: this.view.filterDisplayName() filter_name: this.view.filterDisplayName()
}, true); }, true);
}, },
nextPage: function() { nextPage: function() {
this.view.nextPage(); this.view.nextPage();
}, },
previousPage: function() { previousPage: function() {
this.view.previousPage(); this.view.previousPage();
} }
}); });
return PagingHeader; return PagingHeader;
}); // end define(); }); // end define();
define(["backbone.paginator", "backbone"], function(BackbonePaginator, Backbone) {
// This code was adapted from collections/asset.js.
var PagingCollection = BackbonePaginator.requestPager.extend({
model : Backbone.Model,
paginator_core: {
type: 'GET',
accepts: 'application/json',
dataType: 'json',
url: function() { return this.url; }
},
paginator_ui: {
firstPage: 0,
currentPage: 0,
perPage: 50
},
server_api: {
'page': function() { return this.currentPage; },
'page_size': function() { return this.perPage; },
'sort': function() { return this.sortField; },
'direction': function() { return this.sortDirection; },
'format': 'json'
},
parse: function(response) {
var totalCount = response.totalCount,
start = response.start,
currentPage = response.page,
pageSize = response.pageSize,
totalPages = Math.ceil(totalCount / pageSize);
this.totalCount = totalCount;
this.totalPages = Math.max(totalPages, 1); // Treat an empty collection as having 1 page...
this.currentPage = currentPage;
this.start = start;
return response.items;
}
});
return PagingCollection;
});
define([ "jquery", "js/common_helpers/ajax_helpers", "URI", define([ "jquery", "common/js/spec_helpers/ajax_helpers", "URI",
"js/views/paging", "js/views/paging_header", "js/views/paging_footer", "common/js/components/views/paging", "common/js/components/views/paging_header",
"js/models/asset", "js/collections/asset" ], "common/js/components/views/paging_footer", "common/js/spec/components/paging_collection"],
function ($, AjaxHelpers, URI, PagingView, PagingHeader, PagingFooter, AssetModel, AssetCollection) { function ($, AjaxHelpers, URI, PagingView, PagingHeader, PagingFooter, PagingCollection) {
var createMockAsset = function(index) { var createPageableItem = function(index) {
var id = 'asset_' + index; var id = 'item_' + index;
return { return {
id: id, id: id,
display_name: id, display_name: id,
...@@ -13,10 +13,10 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -13,10 +13,10 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
}; };
var mockFirstPage = { var mockFirstPage = {
assets: [ items: [
createMockAsset(1), createPageableItem(1),
createMockAsset(2), createPageableItem(2),
createMockAsset(3) createPageableItem(3)
], ],
pageSize: 3, pageSize: 3,
totalCount: 4, totalCount: 4,
...@@ -25,8 +25,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -25,8 +25,8 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
end: 2 end: 2
}; };
var mockSecondPage = { var mockSecondPage = {
assets: [ items: [
createMockAsset(4) createPageableItem(4)
], ],
pageSize: 3, pageSize: 3,
totalCount: 4, totalCount: 4,
...@@ -35,7 +35,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -35,7 +35,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
end: 4 end: 4
}; };
var mockEmptyPage = { var mockEmptyPage = {
assets: [], items: [],
pageSize: 3, pageSize: 3,
totalCount: 0, totalCount: 0,
page: 0, page: 0,
...@@ -43,7 +43,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -43,7 +43,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
end: 0 end: 0
}; };
var respondWithMockAssets = function(requests) { var respondWithMockItems = function(requests) {
var requestIndex = requests.length - 1; var requestIndex = requests.length - 1;
var request = requests[requestIndex]; var request = requests[requestIndex];
var url = new URI(request.url); var url = new URI(request.url);
...@@ -58,9 +58,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -58,9 +58,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
initialize : function() { initialize : function() {
this.registerSortableColumn('name-col', 'Name', 'name', 'asc'); this.registerSortableColumn('name-col', 'Name', 'name', 'asc');
this.registerSortableColumn('date-col', 'Date', 'date', 'desc'); this.registerSortableColumn('date-col', 'Date', 'date', 'desc');
this.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type');
this.setInitialSortColumn('date-col'); this.setInitialSortColumn('date-col');
this.setInitialFilterColumn('js-asset-type-col');
} }
}); });
...@@ -68,30 +66,25 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -68,30 +66,25 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
var pagingView; var pagingView;
beforeEach(function () { beforeEach(function () {
var assets = new AssetCollection(); pagingView = new MockPagingView({collection: new PagingCollection()});
assets.url = "assets_url";
var feedbackTpl = readFixtures('system-feedback.underscore');
setFixtures($("<script>", { id: "system-feedback-tpl", type: "text/template" }).text(feedbackTpl));
pagingView = new MockPagingView({collection: assets});
}); });
describe("PagingView", function () { describe("PagingView", function () {
describe("setPage", function () { describe("setPage", function () {
it('can set the current page', function () { it('can set the current page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
}); });
it('should not change page after a server error', function () { it('should not change page after a server error', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.setPage(1); pagingView.setPage(1);
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
...@@ -102,7 +95,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -102,7 +95,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move forward after a server error', function () { it('does not move forward after a server error', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.nextPage(); pagingView.nextPage();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
...@@ -111,16 +104,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -111,16 +104,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can move to the next page', function () { it('can move to the next page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.nextPage(); pagingView.nextPage();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
}); });
it('can not move forward from the final page', function () { it('can not move forward from the final page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.nextPage(); pagingView.nextPage();
expect(requests.length).toBe(1); expect(requests.length).toBe(1);
}); });
...@@ -131,16 +124,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -131,16 +124,16 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can move back a page', function () { it('can move back a page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.previousPage(); pagingView.previousPage();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
}); });
it('can not move back from the first page', function () { it('can not move back from the first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.previousPage(); pagingView.previousPage();
expect(requests.length).toBe(1); expect(requests.length).toBe(1);
}); });
...@@ -148,7 +141,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -148,7 +141,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move back after a server error', function () { it('does not move back after a server error', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingView.previousPage(); pagingView.previousPage();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
...@@ -161,21 +154,21 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -161,21 +154,21 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
expect(pagingView.collection.sortDirection).toBe('desc'); expect(pagingView.collection.sortDirection).toBe('desc');
pagingView.toggleSortOrder('date-col'); pagingView.toggleSortOrder('date-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.sortDirection).toBe('asc'); expect(pagingView.collection.sortDirection).toBe('asc');
pagingView.toggleSortOrder('date-col'); pagingView.toggleSortOrder('date-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.sortDirection).toBe('desc'); expect(pagingView.collection.sortDirection).toBe('desc');
}); });
it('sets the correct default sort direction for a column', function () { it('sets the correct default sort direction for a column', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.toggleSortOrder('name-col'); pagingView.toggleSortOrder('name-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.sortDisplayName()).toBe('Name'); expect(pagingView.sortDisplayName()).toBe('Name');
expect(pagingView.collection.sortDirection).toBe('asc'); expect(pagingView.collection.sortDirection).toBe('asc');
pagingView.toggleSortOrder('date-col'); pagingView.toggleSortOrder('date-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.sortDisplayName()).toBe('Date'); expect(pagingView.sortDisplayName()).toBe('Date');
expect(pagingView.collection.sortDirection).toBe('desc'); expect(pagingView.collection.sortDirection).toBe('desc');
}); });
...@@ -185,7 +178,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -185,7 +178,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('returns the registered info for a column', function () { it('returns the registered info for a column', function () {
pagingView.registerSortableColumn('test-col', 'Test Column', 'testField', 'asc'); pagingView.registerSortableColumn('test-col', 'Test Column', 'testField', 'asc');
pagingView.registerFilterableColumn('js-asset-type-col', gettext('Type'), 'asset_type');
var sortInfo = pagingView.sortableColumnInfo('test-col'); var sortInfo = pagingView.sortableColumnInfo('test-col');
expect(sortInfo.displayName).toBe('Test Column'); expect(sortInfo.displayName).toBe('Test Column');
expect(sortInfo.fieldName).toBe('testField'); expect(sortInfo.fieldName).toBe('testField');
...@@ -204,8 +196,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -204,8 +196,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
var pagingHeader; var pagingHeader;
beforeEach(function () { beforeEach(function () {
var pagingHeaderTpl = readFixtures('paging-header.underscore');
appendSetFixtures($("<script>", { id: "paging-header-tpl", type: "text/template" }).text(pagingHeaderTpl));
pagingHeader = new PagingHeader({view: pagingView}); pagingHeader = new PagingHeader({view: pagingView});
}); });
...@@ -219,7 +209,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -219,7 +209,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move forward if a server error occurs', function () { it('does not move forward if a server error occurs', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingHeader.$('.next-page-link').click(); pagingHeader.$('.next-page-link').click();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
...@@ -228,23 +218,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -228,23 +218,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can move to the next page', function () { it('can move to the next page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingHeader.$('.next-page-link').click(); pagingHeader.$('.next-page-link').click();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
}); });
it('should be enabled when there is at least one more page', function () { it('should be enabled when there is at least one more page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.next-page-link')).not.toHaveClass('is-disabled'); expect(pagingHeader.$('.next-page-link')).not.toHaveClass('is-disabled');
}); });
it('should be disabled on the final page', function () { it('should be disabled on the final page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.next-page-link')).toHaveClass('is-disabled'); expect(pagingHeader.$('.next-page-link')).toHaveClass('is-disabled');
}); });
...@@ -266,7 +256,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -266,7 +256,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move back if a server error occurs', function () { it('does not move back if a server error occurs', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingHeader.$('.previous-page-link').click(); pagingHeader.$('.previous-page-link').click();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
...@@ -275,23 +265,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -275,23 +265,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can go back a page', function () { it('can go back a page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingHeader.$('.previous-page-link').click(); pagingHeader.$('.previous-page-link').click();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
}); });
it('should be disabled on the first page', function () { it('should be disabled on the first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.previous-page-link')).toHaveClass('is-disabled'); expect(pagingHeader.$('.previous-page-link')).toHaveClass('is-disabled');
}); });
it('should be enabled on the second page', function () { it('should be enabled on the second page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.previous-page-link')).not.toHaveClass('is-disabled'); expect(pagingHeader.$('.previous-page-link')).not.toHaveClass('is-disabled');
}); });
...@@ -308,7 +298,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -308,7 +298,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
var requests = AjaxHelpers.requests(this), var requests = AjaxHelpers.requests(this),
message; message;
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
message = pagingHeader.$('.meta').html().trim(); message = pagingHeader.$('.meta').html().trim();
expect(message).toBe('<p>Showing <span class="count-current-shown">1-3</span>' + expect(message).toBe('<p>Showing <span class="count-current-shown">1-3</span>' +
' out of <span class="count-total">4 total</span>, ' + ' out of <span class="count-total">4 total</span>, ' +
...@@ -320,7 +310,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -320,7 +310,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
message; message;
pagingView.setPage(0); pagingView.setPage(0);
pagingView.toggleSortOrder('name-col'); pagingView.toggleSortOrder('name-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
message = pagingHeader.$('.meta').html().trim(); message = pagingHeader.$('.meta').html().trim();
expect(message).toBe('<p>Showing <span class="count-current-shown">1-3</span>' + expect(message).toBe('<p>Showing <span class="count-current-shown">1-3</span>' +
' out of <span class="count-total">4 total</span>, ' + ' out of <span class="count-total">4 total</span>, ' +
...@@ -328,18 +318,18 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -328,18 +318,18 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
}); });
}); });
describe("Asset count label", function () { describe("Item count label", function () {
it('should show correct count on first page', function () { it('should show correct count on first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.count-current-shown')).toHaveHtml('1-3'); expect(pagingHeader.$('.count-current-shown')).toHaveHtml('1-3');
}); });
it('should show correct count on second page', function () { it('should show correct count on second page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.count-current-shown')).toHaveHtml('4-4'); expect(pagingHeader.$('.count-current-shown')).toHaveHtml('4-4');
}); });
...@@ -351,18 +341,18 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -351,18 +341,18 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
}); });
}); });
describe("Asset total label", function () { describe("Item total label", function () {
it('should show correct total on the first page', function () { it('should show correct total on the first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.count-total')).toHaveText('4 total'); expect(pagingHeader.$('.count-total')).toHaveText('4 total');
}); });
it('should show correct total on the second page', function () { it('should show correct total on the second page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.count-total')).toHaveText('4 total'); expect(pagingHeader.$('.count-total')).toHaveText('4 total');
}); });
...@@ -378,14 +368,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -378,14 +368,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should show correct initial sort order', function () { it('should show correct initial sort order', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.sort-order')).toHaveText('Date'); expect(pagingHeader.$('.sort-order')).toHaveText('Date');
}); });
it('should show updated sort order', function () { it('should show updated sort order', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.toggleSortOrder('name-col'); pagingView.toggleSortOrder('name-col');
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingHeader.$('.sort-order')).toHaveText('Name'); expect(pagingHeader.$('.sort-order')).toHaveText('Name');
}); });
}); });
...@@ -395,8 +385,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -395,8 +385,6 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
var pagingFooter; var pagingFooter;
beforeEach(function () { beforeEach(function () {
var pagingFooterTpl = readFixtures('paging-footer.underscore');
appendSetFixtures($("<script>", { id: "paging-footer-tpl", type: "text/template" }).text(pagingFooterTpl));
pagingFooter = new PagingFooter({view: pagingView}); pagingFooter = new PagingFooter({view: pagingView});
}); });
...@@ -410,7 +398,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -410,7 +398,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move forward if a server error occurs', function () { it('does not move forward if a server error occurs', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.next-page-link').click(); pagingFooter.$('.next-page-link').click();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
...@@ -419,23 +407,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -419,23 +407,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can move to the next page', function () { it('can move to the next page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.next-page-link').click(); pagingFooter.$('.next-page-link').click();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
}); });
it('should be enabled when there is at least one more page', function () { it('should be enabled when there is at least one more page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.next-page-link')).not.toHaveClass('is-disabled'); expect(pagingFooter.$('.next-page-link')).not.toHaveClass('is-disabled');
}); });
it('should be disabled on the final page', function () { it('should be disabled on the final page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.next-page-link')).toHaveClass('is-disabled'); expect(pagingFooter.$('.next-page-link')).toHaveClass('is-disabled');
}); });
...@@ -457,7 +445,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -457,7 +445,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('does not move back if a server error occurs', function () { it('does not move back if a server error occurs', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.previous-page-link').click(); pagingFooter.$('.previous-page-link').click();
requests[1].respond(500); requests[1].respond(500);
expect(pagingView.collection.currentPage).toBe(1); expect(pagingView.collection.currentPage).toBe(1);
...@@ -466,23 +454,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -466,23 +454,23 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('can go back a page', function () { it('can go back a page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.previous-page-link').click(); pagingFooter.$('.previous-page-link').click();
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
}); });
it('should be disabled on the first page', function () { it('should be disabled on the first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.previous-page-link')).toHaveClass('is-disabled'); expect(pagingFooter.$('.previous-page-link')).toHaveClass('is-disabled');
}); });
it('should be enabled on the second page', function () { it('should be enabled on the second page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.previous-page-link')).not.toHaveClass('is-disabled'); expect(pagingFooter.$('.previous-page-link')).not.toHaveClass('is-disabled');
}); });
...@@ -498,14 +486,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -498,14 +486,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should show 1 on the first page', function () { it('should show 1 on the first page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.current-page')).toHaveText('1'); expect(pagingFooter.$('.current-page')).toHaveText('1');
}); });
it('should show 2 on the second page', function () { it('should show 2 on the second page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(1); pagingView.setPage(1);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.current-page')).toHaveText('2'); expect(pagingFooter.$('.current-page')).toHaveText('2');
}); });
...@@ -521,11 +509,11 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -521,11 +509,11 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should show the correct value with more than one page', function () { it('should show the correct value with more than one page', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.total-pages')).toHaveText('2'); expect(pagingFooter.$('.total-pages')).toHaveText('2');
}); });
it('should show page 1 when there are no assets', function () { it('should show page 1 when there are no pageable items', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
AjaxHelpers.respondWithJson(requests, mockEmptyPage); AjaxHelpers.respondWithJson(requests, mockEmptyPage);
...@@ -543,14 +531,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -543,14 +531,14 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should initially have a blank page input', function () { it('should initially have a blank page input', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
expect(pagingFooter.$('.page-number-input')).toHaveValue(''); expect(pagingFooter.$('.page-number-input')).toHaveValue('');
}); });
it('should handle invalid page requests', function () { it('should handle invalid page requests', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.page-number-input').val('abc'); pagingFooter.$('.page-number-input').val('abc');
pagingFooter.$('.page-number-input').trigger('change'); pagingFooter.$('.page-number-input').trigger('change');
expect(pagingView.collection.currentPage).toBe(0); expect(pagingView.collection.currentPage).toBe(0);
...@@ -560,7 +548,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -560,7 +548,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should switch pages via the input field', function () { it('should switch pages via the input field', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.page-number-input').val('2'); pagingFooter.$('.page-number-input').val('2');
pagingFooter.$('.page-number-input').trigger('change'); pagingFooter.$('.page-number-input').trigger('change');
AjaxHelpers.respondWithJson(requests, mockSecondPage); AjaxHelpers.respondWithJson(requests, mockSecondPage);
...@@ -571,7 +559,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI", ...@@ -571,7 +559,7 @@ define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
it('should handle AJAX failures when switching pages via the input field', function () { it('should handle AJAX failures when switching pages via the input field', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
pagingView.setPage(0); pagingView.setPage(0);
respondWithMockAssets(requests); respondWithMockItems(requests);
pagingFooter.$('.page-number-input').val('2'); pagingFooter.$('.page-number-input').val('2');
pagingFooter.$('.page-number-input').trigger('change'); pagingFooter.$('.page-number-input').trigger('change');
requests[1].respond(500); requests[1].respond(500);
......
(function(requirejs, define) {
requirejs.config({
paths: {
'gettext': 'js/test/i18n',
'jquery': 'js/vendor/jquery.min',
'jquery.ui': 'js/vendor/jquery-ui.min',
'jquery.flot': 'js/vendor/flot/jquery.flot.min',
'jquery.form': 'js/vendor/jquery.form',
'jquery.markitup': 'js/vendor/markitup/jquery.markitup',
'jquery.leanModal': 'js/vendor/jquery.leanModal.min',
'jquery.ajaxQueue': 'js/vendor/jquery.ajaxQueue',
'jquery.smoothScroll': 'js/vendor/jquery.smooth-scroll.min',
'jquery.scrollTo': 'js/vendor/jquery.scrollTo-1.4.2-min',
'jquery.timepicker': 'js/vendor/timepicker/jquery.timepicker',
'jquery.cookie': 'js/vendor/jquery.cookie',
'jquery.qtip': 'js/vendor/jquery.qtip.min',
'jquery.fileupload': 'js/vendor/jQuery-File-Upload/js/jquery.fileupload',
'jquery.iframe-transport': 'js/vendor/jQuery-File-Upload/js/jquery.iframe-transport',
'jquery.inputnumber': 'js/vendor/html5-input-polyfills/number-polyfill',
'jquery.immediateDescendents': 'coffee/src/jquery.immediateDescendents',
'jquery.simulate': 'js/vendor/jquery.simulate',
'jquery.url': 'js/vendor/url.min',
'sinon': 'js/vendor/sinon-1.7.1',
'text': 'js/vendor/requirejs/text',
'underscore': 'js/vendor/underscore-min',
'underscore.string': 'js/vendor/underscore.string.min',
'backbone': 'js/vendor/backbone-min',
'backbone.associations': 'js/vendor/backbone-associations-min',
'backbone.paginator': 'js/vendor/backbone.paginator.min',
"backbone-super": "js/vendor/backbone-super",
'jasmine-jquery': 'js/vendor/jasmine-jquery',
'jasmine-imagediff': 'js/vendor/jasmine-imagediff',
'jasmine-stealth': 'js/vendor/jasmine-stealth',
'jasmine.async': 'js/vendor/jasmine.async',
'URI': 'js/vendor/URI.min'
},
shim: {
'gettext': {
exports: 'gettext'
},
'jquery.ui': {
deps: ['jquery'],
exports: 'jQuery.ui'
},
'jquery.flot': {
deps: ['jquery'],
exports: 'jQuery.flot'
},
'jquery.form': {
deps: ['jquery'],
exports: 'jQuery.fn.ajaxForm'
},
'jquery.markitup': {
deps: ['jquery'],
exports: 'jQuery.fn.markitup'
},
'jquery.leanModal': {
deps: ['jquery'],
exports: 'jQuery.fn.leanModal'
},
'jquery.smoothScroll': {
deps: ['jquery'],
exports: 'jQuery.fn.smoothScroll'
},
'jquery.ajaxQueue': {
deps: ['jquery'],
exports: 'jQuery.fn.ajaxQueue'
},
'jquery.scrollTo': {
deps: ['jquery'],
exports: 'jQuery.fn.scrollTo'
},
'jquery.cookie': {
deps: ['jquery'],
exports: 'jQuery.fn.cookie'
},
'jquery.qtip': {
deps: ['jquery'],
exports: 'jQuery.fn.qtip'
},
'jquery.fileupload': {
deps: ['jquery.iframe-transport'],
exports: 'jQuery.fn.fileupload'
},
'jquery.inputnumber': {
deps: ['jquery'],
exports: 'jQuery.fn.inputNumber'
},
'jquery.simulate': {
deps: ['jquery'],
exports: 'jQuery.fn.simulate'
},
'jquery.url': {
deps: ['jquery'],
exports: 'jQuery.fn.url'
},
'datepair': {
deps: ['jquery.ui', 'jquery.timepicker']
},
'underscore': {
deps: ['underscore.string'],
exports: '_',
init: function(UnderscoreString) {
/* Mix non-conflicting functions from underscore.string
* (all but include, contains, and reverse) into the
* Underscore namespace. This allows the login, register,
* and password reset templates to render independent of the
* access view.
*/
_.mixin(UnderscoreString.exports());
/* Since the access view is not using RequireJS, we also
* expose underscore.string at _.str, so that the access
* view can perform the mixin on its own.
*/
_.str = UnderscoreString;
}
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.associations': {
deps: ['backbone'],
exports: 'Backbone.Associations'
},
'backbone.paginator': {
deps: ['backbone'],
exports: 'Backbone.Paginator'
},
"backbone-super": {
deps: ["backbone"]
},
'URI': {
exports: 'URI'
},
'jasmine-jquery': {
deps: ['jasmine']
},
'jasmine-imagediff': {
deps: ['jasmine']
},
'jasmine-stealth': {
deps: ['jasmine']
},
'jasmine.async': {
deps: ['jasmine'],
exports: 'AsyncSpec'
},
"sinon": {
exports: "sinon"
}
}
});
define([
// Run the common tests that use RequireJS.
'common-requirejs/include/common/js/spec/components/paging_spec.js'
]);
}).call(this, requirejs, define);
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
define, window, process, Packages, define, window, process, Packages,
java, location, Components, FileUtils */ java, location, Components, FileUtils */
// Added by edX: we namespace requirejs and its associated functions. var requirejs_text_function = function (module) {
var namespaced_define = window.define !== undefined ? define : RequireJS.define;
namespaced_define(['module'], function (module) {
'use strict'; 'use strict';
var text, fs, Cc, Ci, xpcIsWindows, var text, fs, Cc, Ci, xpcIsWindows,
...@@ -210,7 +207,7 @@ namespaced_define(['module'], function (module) { ...@@ -210,7 +207,7 @@ namespaced_define(['module'], function (module) {
if (buildMap.hasOwnProperty(moduleName)) { if (buildMap.hasOwnProperty(moduleName)) {
var content = text.jsEscape(buildMap[moduleName]); var content = text.jsEscape(buildMap[moduleName]);
write.asModule(pluginName + "!" + moduleName, write.asModule(pluginName + "!" + moduleName,
"namespaced_define(function () { return '" + "define(function () { return '" +
content + content +
"';});\n"); "';});\n");
} }
...@@ -391,4 +388,12 @@ namespaced_define(['module'], function (module) { ...@@ -391,4 +388,12 @@ namespaced_define(['module'], function (module) {
}; };
} }
return text; return text;
}); };
if (define !== undefined) {
define(['module'], requirejs_text_function);
}
else {
// Added by edX: we namespace requirejs and its associated functions.
RequireJS.define(['module'], requirejs_text_function);
}
...@@ -82,4 +82,4 @@ spec_paths: ...@@ -82,4 +82,4 @@ spec_paths:
fixture_paths: fixture_paths:
- js/fixtures - js/fixtures
- js/capa/fixtures - js/capa/fixtures
- templates/discussion - common/templates
---
# Common JavaScript tests, using RequireJS.
#
#
# To run all the tests and print results to the console:
#
# js-test-tool run TEST_SUITE --use-firefox
#
# where `TEST_SUITE` is this file.
#
#
# To run the tests in your default browser ("dev mode"):
#
# js-test-tool dev TEST_SUITE
#
test_suite_name: common-requirejs
test_runner: jasmine_requirejs
# Path prepended to source files in the coverage report (optional)
# For example, if the source path
# is "src/source.js" (relative to this YAML file)
# and the prepend path is "base/dir"
# then the coverage report will show
# "base/dir/src/source.js"
prepend_path: common/static
# Paths to library JavaScript files (optional)
lib_paths:
- js/vendor/jquery.min.js
- js/vendor/jasmine-jquery.js
- js/vendor/jasmine-imagediff.js
- js/vendor/jquery.truncate.js
- js/vendor/underscore-min.js
- js/vendor/underscore.string.min.js
- js/vendor/backbone-min.js
- js/vendor/backbone.paginator.min.js
- js/vendor/jquery.timeago.js
- js/vendor/URI.min.js
- coffee/src/ajax_prefix.js
- js/test/add_ajax_prefix.js
- js/test/i18n.js
- coffee/src/jquery.immediateDescendents.js
- js/vendor/requirejs/text.js
- js/vendor/sinon-1.7.1.js
# Paths to source JavaScript files
src_paths:
- common/js
# Paths to spec (test) JavaScript files
spec_paths:
- common/js/spec
- js/spec/main_requirejs.js
# Paths to fixture files (optional)
# The fixture path will be set automatically when using jasmine-jquery.
# (https://github.com/velesin/jasmine-jquery)
#
# You can then access fixtures using paths relative to
# the test suite description:
#
# loadFixtures('path/to/fixture/fixture.html');
#
fixture_paths:
- common/templates
requirejs:
paths:
main: js/spec/main_requirejs
# Because require.js is responsible for loading all dependencies, we exclude
# all files from being included in <script> tags
exclude_from_page:
- .*
../../templates/js/discussion
\ No newline at end of file
...@@ -498,6 +498,7 @@ TEMPLATE_DIRS = [ ...@@ -498,6 +498,7 @@ TEMPLATE_DIRS = [
COMMON_ROOT / 'templates', COMMON_ROOT / 'templates',
COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates', COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates', COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
COMMON_ROOT / 'static', # required to statically include common Underscore templates
] ]
TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATE_CONTEXT_PROCESSORS = (
...@@ -1571,7 +1572,7 @@ STATICFILES_IGNORE_PATTERNS = ( ...@@ -1571,7 +1572,7 @@ STATICFILES_IGNORE_PATTERNS = (
# Symlinks used by js-test-tool # Symlinks used by js-test-tool
"xmodule_js", "xmodule_js",
"common_static", "common",
) )
PIPELINE_UGLIFYJS_BINARY = 'node_modules/.bin/uglifyjs' PIPELINE_UGLIFYJS_BINARY = 'node_modules/.bin/uglifyjs'
......
../../common/static/common
\ No newline at end of file
../../../common/static/js/spec_helpers
\ No newline at end of file
define(['js/common_helpers/ajax_helpers', 'js/ccx/schedule'], define(['common/js/spec_helpers/ajax_helpers', 'js/ccx/schedule'],
function(AjaxHelpers) { function(AjaxHelpers) {
describe("edx.ccx.schedule.ScheduleView", function() { describe("edx.ccx.schedule.ScheduleView", function() {
var view = null; var view = null;
......
define(['js/common_helpers/template_helpers', 'js/common_helpers/ajax_helpers', 'js/dashboard/donation'], define(['common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers', 'js/dashboard/donation'],
function(TemplateHelpers, AjaxHelpers) { function(TemplateHelpers, AjaxHelpers) {
'use strict'; 'use strict';
......
...@@ -2,8 +2,8 @@ define([ ...@@ -2,8 +2,8 @@ define([
'jquery', 'jquery',
'backbone', 'backbone',
'logger', 'logger',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/discovery/app', 'js/discovery/app',
'js/discovery/collection', 'js/discovery/collection',
'js/discovery/form', 'js/discovery/form',
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/spec/edxnotes/helpers', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'js/spec/edxnotes/helpers',
'annotator_1.2.9', 'logger', 'js/edxnotes/views/notes_factory' 'annotator_1.2.9', 'logger', 'js/edxnotes/views/notes_factory'
], function($, _, AjaxHelpers, Helpers, Annotator, Logger, NotesFactory) { ], function($, _, AjaxHelpers, Helpers, Annotator, Logger, NotesFactory) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'logger', 'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'logger',
'js/edxnotes/models/note', 'js/edxnotes/views/note_item', 'js/edxnotes/models/note', 'js/edxnotes/views/note_item',
'js/spec/edxnotes/custom_matchers' 'js/spec/edxnotes/custom_matchers'
], function( ], function(
......
define([ define([
'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'js/common_helpers/ajax_helpers', 'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'common/js/spec_helpers/ajax_helpers',
'js/spec/edxnotes/helpers', 'js/spec/edxnotes/custom_matchers' 'js/spec/edxnotes/helpers', 'js/spec/edxnotes/custom_matchers'
], function(Annotator, NotesFactory, AjaxHelpers, Helpers, customMatchers) { ], function(Annotator, NotesFactory, AjaxHelpers, Helpers, customMatchers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/template_helpers', 'jquery', 'underscore', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'js/spec/edxnotes/helpers', 'common/js/spec_helpers/ajax_helpers', 'js/spec/edxnotes/helpers',
'js/edxnotes/views/page_factory', 'js/spec/edxnotes/custom_matchers' 'js/edxnotes/views/page_factory', 'js/spec/edxnotes/custom_matchers'
], function($, _, TemplateHelpers, AjaxHelpers, Helpers, NotesFactory, customMatchers) { ], function($, _, TemplateHelpers, AjaxHelpers, Helpers, NotesFactory, customMatchers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/edxnotes/views/search_box', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'js/edxnotes/views/search_box',
'js/edxnotes/collections/notes', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/edxnotes/collections/notes', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function($, _, AjaxHelpers, SearchBoxView, NotesCollection, customMatchers) { ], function($, _, AjaxHelpers, SearchBoxView, NotesCollection, customMatchers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'js/common_helpers/template_helpers', 'js/edxnotes/collections/tabs', 'jquery', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) { ], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'backbone', 'js/common_helpers/template_helpers', 'js/edxnotes/collections/tabs', 'jquery', 'backbone', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
'js/edxnotes/views/tabs_list', 'js/edxnotes/views/tab_view', 'js/edxnotes/views/tabs_list', 'js/edxnotes/views/tab_view',
'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function( ], function(
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers',
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs', 'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs',
'js/edxnotes/views/tabs/course_structure', 'js/spec/edxnotes/custom_matchers', 'js/edxnotes/views/tabs/course_structure', 'js/spec/edxnotes/custom_matchers',
'jasmine-jquery' 'jasmine-jquery'
......
define([ define([
'jquery', 'js/common_helpers/template_helpers', 'js/edxnotes/collections/notes', 'jquery', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/notes',
'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/recent_activity', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/recent_activity',
'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function( ], function(
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/template_helpers', 'js/common_helpers/ajax_helpers', 'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers',
'logger', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/search_results', 'logger', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/search_results',
'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function( ], function(
......
define([ define([
'jquery', 'underscore', 'js/common_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers',
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs', 'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs',
'js/edxnotes/views/tabs/tags', 'js/spec/edxnotes/custom_matchers', 'js/edxnotes/views/tabs/tags', 'js/spec/edxnotes/custom_matchers',
'jasmine-jquery' 'jasmine-jquery'
......
define([ define([
'jquery', 'js/common_helpers/template_helpers', 'js/edxnotes/collections/tabs', 'jquery', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) { ], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'annotator_1.2.9', 'js/common_helpers/ajax_helpers', 'js/edxnotes/views/visibility_decorator', 'jquery', 'annotator_1.2.9', 'common/js/spec_helpers/ajax_helpers', 'js/edxnotes/views/visibility_decorator',
'js/edxnotes/views/toggle_notes_factory', 'js/spec/edxnotes/helpers', 'js/edxnotes/views/toggle_notes_factory', 'js/spec/edxnotes/helpers',
'js/spec/edxnotes/custom_matchers', 'jasmine-jquery' 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
], function( ], function(
......
define(['backbone', 'jquery', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/groups/views/cohorts', 'js/groups/collections/cohort', 'js/groups/models/content_group', 'js/groups/views/cohorts', 'js/groups/collections/cohort', 'js/groups/models/content_group',
'js/groups/models/course_cohort_settings', 'js/utils/animation', 'js/vendor/jquery.qubit', 'js/groups/models/course_cohort_settings', 'js/utils/animation', 'js/vendor/jquery.qubit',
'js/groups/views/course_cohort_settings_notification', 'js/groups/models/cohort_discussions', 'js/groups/views/course_cohort_settings_notification', 'js/groups/models/cohort_discussions',
......
define(['jquery', 'coffee/src/instructor_dashboard/student_admin', 'js/common_helpers/ajax_helpers'], define(['jquery', 'coffee/src/instructor_dashboard/student_admin', 'common/js/spec_helpers/ajax_helpers'],
function ($, StudentAdmin, AjaxHelpers) { function ($, StudentAdmin, AjaxHelpers) {
//'coffee/src/instructor_dashboard/student_admin' //'coffee/src/instructor_dashboard/student_admin'
'use strict'; 'use strict';
......
...@@ -3,7 +3,7 @@ define([ ...@@ -3,7 +3,7 @@ define([
'sinon', 'sinon',
'backbone', 'backbone',
'logger', 'logger',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/search/base/models/search_result', 'js/search/base/models/search_result',
'js/search/base/collections/search_collection', 'js/search/base/collections/search_collection',
'js/search/base/routers/search_router', 'js/search/base/routers/search_router',
......
define(['js/common_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'], define(['common/js/spec_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'],
function(AjaxHelpers) { function(AjaxHelpers) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'jquery',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/student_account/views/AccessView', 'js/student_account/views/AccessView',
'js/student_account/views/FormView', 'js/student_account/views/FormView',
'js/student_account/enrollment', 'js/student_account/enrollment',
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/views/fields_helpers', 'js/spec/views/fields_helpers',
'js/spec/student_account/helpers', 'js/spec/student_account/helpers',
'js/spec/student_account/account_settings_fields_helpers', 'js/spec/student_account/account_settings_fields_helpers',
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/views/fields_helpers', 'js/spec/views/fields_helpers',
'string_utils'], 'string_utils'],
function (Backbone, $, _, AjaxHelpers, TemplateHelpers, FieldViewsSpecHelpers) { function (Backbone, $, _, AjaxHelpers, TemplateHelpers, FieldViewsSpecHelpers) {
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/views/fields', 'js/views/fields',
'js/spec/views/fields_helpers', 'js/spec/views/fields_helpers',
'js/spec/student_account/account_settings_fields_helpers', 'js/spec/student_account/account_settings_fields_helpers',
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/student_account/helpers', 'js/spec/student_account/helpers',
'js/views/fields', 'js/views/fields',
'js/student_account/models/user_account_model', 'js/student_account/models/user_account_model',
......
define(['js/common_helpers/ajax_helpers', 'js/student_account/emailoptin'], define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'],
function( AjaxHelpers, EmailOptInInterface ) { function( AjaxHelpers, EmailOptInInterface ) {
'use strict'; 'use strict';
......
define(['js/common_helpers/ajax_helpers', 'js/student_account/enrollment'], define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
function( AjaxHelpers, EnrollmentInterface ) { function( AjaxHelpers, EnrollmentInterface ) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'jquery',
'underscore', 'underscore',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/student_account/models/LoginModel', 'js/student_account/models/LoginModel',
'js/student_account/views/LoginView', 'js/student_account/views/LoginView',
'js/student_account/models/PasswordResetModel' 'js/student_account/models/PasswordResetModel'
......
define([ define([
'jquery', 'jquery',
'underscore', 'underscore',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/student_account/models/PasswordResetModel', 'js/student_account/models/PasswordResetModel',
'js/student_account/views/PasswordResetView', 'js/student_account/views/PasswordResetView',
], function($, _, TemplateHelpers, AjaxHelpers, PasswordResetModel, PasswordResetView) { ], function($, _, TemplateHelpers, AjaxHelpers, PasswordResetModel, PasswordResetView) {
......
define([ define([
'jquery', 'jquery',
'underscore', 'underscore',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/student_account/models/RegisterModel', 'js/student_account/models/RegisterModel',
'js/student_account/views/RegisterView' 'js/student_account/views/RegisterView'
], function($, _, TemplateHelpers, AjaxHelpers, RegisterModel, RegisterView) { ], function($, _, TemplateHelpers, AjaxHelpers, RegisterModel, RegisterView) {
......
define(['js/common_helpers/ajax_helpers', 'js/student_account/shoppingcart'], define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'],
function(AjaxHelpers, ShoppingCartInterface) { function(AjaxHelpers, ShoppingCartInterface) {
'use strict'; 'use strict';
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/student_account/helpers', 'js/spec/student_account/helpers',
'js/spec/student_profile/helpers', 'js/spec/student_profile/helpers',
'js/views/fields', 'js/views/fields',
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/student_account/helpers', 'js/spec/student_account/helpers',
'js/student_account/models/user_account_model', 'js/student_account/models/user_account_model',
'js/student_profile/views/learner_profile_fields', 'js/student_profile/views/learner_profile_fields',
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/spec/student_account/helpers', 'js/spec/student_account/helpers',
'js/spec/student_profile/helpers', 'js/spec/student_profile/helpers',
'js/views/fields', 'js/views/fields',
......
define([ define([
'jquery', 'jquery',
'backbone', 'backbone',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/verify_student/views/image_input_view', 'js/verify_student/views/image_input_view',
'js/verify_student/models/verification_model' 'js/verify_student/models/verification_model'
], function( $, Backbone, TemplateHelpers, AjaxHelpers, ImageInputView, VerificationModel ) { ], function( $, Backbone, TemplateHelpers, AjaxHelpers, ImageInputView, VerificationModel ) {
......
...@@ -2,8 +2,8 @@ define([ ...@@ -2,8 +2,8 @@ define([
'jquery', 'jquery',
'underscore', 'underscore',
'backbone', 'backbone',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/verify_student/views/make_payment_step_view' 'js/verify_student/views/make_payment_step_view'
], ],
function( $, _, Backbone, AjaxHelpers, TemplateHelpers, MakePaymentStepView ) { function( $, _, Backbone, AjaxHelpers, TemplateHelpers, MakePaymentStepView ) {
......
define(['jquery', 'js/common_helpers/template_helpers', 'js/verify_student/views/pay_and_verify_view'], define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/views/pay_and_verify_view'],
function( $, TemplateHelpers, PayAndVerifyView ) { function( $, TemplateHelpers, PayAndVerifyView ) {
'use strict'; 'use strict';
......
...@@ -2,8 +2,8 @@ define([ ...@@ -2,8 +2,8 @@ define([
'jquery', 'jquery',
'underscore', 'underscore',
'backbone', 'backbone',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/verify_student/views/review_photos_step_view', 'js/verify_student/views/review_photos_step_view',
'js/verify_student/models/verification_model' 'js/verify_student/models/verification_model'
], ],
......
define([ define([
'jquery', 'jquery',
'backbone', 'backbone',
'js/common_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/verify_student/views/webcam_photo_view', 'js/verify_student/views/webcam_photo_view',
'js/verify_student/models/verification_model' 'js/verify_student/models/verification_model'
], ],
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/views/fields', 'js/views/fields',
'string_utils'], 'string_utils'],
function (Backbone, $, _, AjaxHelpers, TemplateHelpers, FieldViews) { function (Backbone, $, _, AjaxHelpers, TemplateHelpers, FieldViews) {
......
define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
'js/views/fields', 'js/views/fields',
'js/spec/views/fields_helpers', 'js/spec/views/fields_helpers',
'string_utils'], 'string_utils'],
......
define(['backbone', 'jquery', 'js/views/file_uploader', 'js/common_helpers/template_helpers', define(['backbone', 'jquery', 'js/views/file_uploader', 'common/js/spec_helpers/template_helpers',
'js/common_helpers/ajax_helpers', 'js/models/notification', 'string_utils'], 'common/js/spec_helpers/ajax_helpers', 'js/models/notification', 'string_utils'],
function (Backbone, $, FileUploaderView, TemplateHelpers, AjaxHelpers, NotificationModel) { function (Backbone, $, FileUploaderView, TemplateHelpers, AjaxHelpers, NotificationModel) {
describe("FileUploaderView", function () { describe("FileUploaderView", function () {
var verifyTitle, verifyInputLabel, verifyInputTip, verifySubmitButton, verifyExtensions, verifyText, var verifyTitle, verifyInputLabel, verifyInputTip, verifySubmitButton, verifyExtensions, verifyText,
......
define(['backbone', 'jquery', 'js/models/notification', 'js/views/notification', 'js/common_helpers/template_helpers'], define(['backbone', 'jquery', 'js/models/notification', 'js/views/notification', 'common/js/spec_helpers/template_helpers'],
function (Backbone, $, NotificationModel, NotificationView, TemplateHelpers) { function (Backbone, $, NotificationModel, NotificationView, TemplateHelpers) {
describe("NotificationView", function () { describe("NotificationView", function () {
var createNotification, verifyTitle, verifyMessage, verifyDetails, verifyAction, notificationView; var createNotification, verifyTitle, verifyMessage, verifyDetails, verifyAction, notificationView;
......
...@@ -64,7 +64,7 @@ lib_paths: ...@@ -64,7 +64,7 @@ lib_paths:
# Paths to source JavaScript files # Paths to source JavaScript files
src_paths: src_paths:
- js - js
- js/common_helpers - common/js
- teams/js - teams/js
# Paths to spec (test) JavaScript files # Paths to spec (test) JavaScript files
...@@ -97,6 +97,7 @@ fixture_paths: ...@@ -97,6 +97,7 @@ fixture_paths:
- js/fixtures/search - js/fixtures/search
- templates/search - templates/search
- templates/discovery - templates/discovery
- common/templates
requirejs: requirejs:
paths: paths:
......
...@@ -22,7 +22,7 @@ ${page_title_breadcrumbs(course_name())} ...@@ -22,7 +22,7 @@ ${page_title_breadcrumbs(course_name())}
<%block name="header_extras"> <%block name="header_extras">
% for template_name in ["image-modal"]: % for template_name in ["image-modal"]:
<script type="text/template" id="${template_name}-tpl"> <script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" /> <%static:include path="common/templates/${template_name}.underscore" />
</script> </script>
% endfor % endfor
<% <%
......
...@@ -22,7 +22,7 @@ ${page_title_breadcrumbs(course_name())} ...@@ -22,7 +22,7 @@ ${page_title_breadcrumbs(course_name())}
<%block name="header_extras"> <%block name="header_extras">
% for template_name in ["image-modal"]: % for template_name in ["image-modal"]:
<script type="text/template" id="${template_name}-tpl"> <script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" /> <%static:include path="common/templates/${template_name}.underscore" />
</script> </script>
% endfor % endfor
......
...@@ -50,7 +50,7 @@ from django_comment_client.permissions import has_permission ...@@ -50,7 +50,7 @@ from django_comment_client.permissions import has_permission
% for template_name in ['thread-show']: % for template_name in ['thread-show']:
<script aria-hidden="true" type="text/template" id="${template_name}-template"> <script aria-hidden="true" type="text/template" id="${template_name}-template">
<%static:include path="js/discussion/${template_name}.underscore" /> <%static:include path="common/templates/discussion/${template_name}.underscore" />
</script> </script>
% endfor % endfor
......
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
<%namespace name='static' file='static_content.html'/> <%namespace name='static' file='static_content.html'/>
% for template_name in ["paging-header", "paging-footer"]:
<script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" />
</script>
% endfor
<div class="xblock-container-paging-parameters" <div class="xblock-container-paging-parameters"
data-start="${first_displayed}" data-start="${first_displayed}"
data-displayed="${displayed_children}" data-displayed="${displayed_children}"
......
...@@ -109,6 +109,7 @@ class Env(object): ...@@ -109,6 +109,7 @@ class Env(object):
REPO_ROOT / 'cms/static/js_test_squire.yml', REPO_ROOT / 'cms/static/js_test_squire.yml',
REPO_ROOT / 'common/lib/xmodule/xmodule/js/js_test.yml', REPO_ROOT / 'common/lib/xmodule/xmodule/js/js_test.yml',
REPO_ROOT / 'common/static/js_test.yml', REPO_ROOT / 'common/static/js_test.yml',
REPO_ROOT / 'common/static/js_test_requirejs.yml',
] ]
JS_TEST_ID_KEYS = [ JS_TEST_ID_KEYS = [
...@@ -118,6 +119,7 @@ class Env(object): ...@@ -118,6 +119,7 @@ class Env(object):
'cms-squire', 'cms-squire',
'xmodule', 'xmodule',
'common', 'common',
'common-requirejs'
] ]
JS_REPORT_DIR = REPORT_DIR / 'javascript' JS_REPORT_DIR = REPORT_DIR / 'javascript'
......
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