eslint --fix
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
* inlined in the build config.
|
||||
*/
|
||||
shim: {
|
||||
'xmodule': {
|
||||
xmodule: {
|
||||
deps: [
|
||||
'jquery', 'underscore', 'codemirror', 'tinymce',
|
||||
'jquery.tinymce', 'jquery.qtip', 'jquery.scrollTo', 'jquery.flot',
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
message = JSON.parse(jqXHR.responseText).error;
|
||||
}
|
||||
msg = new NotificationView.Error({
|
||||
'title': gettext("Studio's having trouble saving your work"),
|
||||
'message': message
|
||||
title: gettext("Studio's having trouble saving your work"),
|
||||
message: message
|
||||
});
|
||||
console.log('Studio AJAX Error', { // eslint-disable-line no-console
|
||||
url: event.currentTarget.URL,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/modal',
|
||||
'common/js/components/views/feedback_notification'],
|
||||
'common/js/components/views/feedback_notification'],
|
||||
function($, Backbone, XBlock, URI, gettext, ModalUtils, NotificationView) {
|
||||
'use strict';
|
||||
|
||||
@@ -149,7 +149,7 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
|
||||
};
|
||||
|
||||
return v1;
|
||||
})(XBlock.Runtime.v1);
|
||||
}(XBlock.Runtime.v1));
|
||||
|
||||
PreviewRuntime.v1 = (function(_super) {
|
||||
__extends(v1, _super);
|
||||
@@ -161,7 +161,7 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
|
||||
v1.prototype.handlerPrefix = '/preview/xblock';
|
||||
|
||||
return v1;
|
||||
})(BaseRuntime.v1);
|
||||
}(BaseRuntime.v1));
|
||||
|
||||
StudioRuntime.v1 = (function(_super) {
|
||||
__extends(v1, _super);
|
||||
@@ -173,7 +173,7 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
|
||||
v1.prototype.handlerPrefix = '/xblock';
|
||||
|
||||
return v1;
|
||||
})(BaseRuntime.v1);
|
||||
}(BaseRuntime.v1));
|
||||
|
||||
// Install the runtime's into the global namespace
|
||||
window.BaseRuntime = BaseRuntime;
|
||||
|
||||
@@ -25,8 +25,7 @@ require([
|
||||
ModuleUtils,
|
||||
IframeUtils,
|
||||
DropdownMenuView
|
||||
)
|
||||
{
|
||||
) {
|
||||
var $body;
|
||||
|
||||
domReady(function() {
|
||||
|
||||
@@ -31,8 +31,7 @@ function(Backbone, gettext, Certificate) {
|
||||
// otherwise return empty array
|
||||
if (typeof certificate_info === 'object') {
|
||||
return_array = certificate_info;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.error(
|
||||
interpolate(
|
||||
gettext('Could not parse certificate JSON. %(message)s'), {message: ex.message}, true
|
||||
|
||||
@@ -11,7 +11,7 @@ define(['jquery'], function($) { // eslint-disable-line no-unused-vars
|
||||
compare: function(actual, values) {
|
||||
var passed = _.every(values, function(value, key) {
|
||||
return actual.get(key) === value;
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
return {
|
||||
pass: passed
|
||||
|
||||
@@ -131,8 +131,8 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
it('should parse a JSON object collection into a Backbone model collection', function() {
|
||||
var course_title = 'Test certificate course title override 2';
|
||||
var CERTIFICATE_JSON_OBJECT = [{
|
||||
'course_title': course_title,
|
||||
'signatories': '[]'
|
||||
course_title: course_title,
|
||||
signatories: '[]'
|
||||
}];
|
||||
this.collection.parse(CERTIFICATE_JSON_OBJECT);
|
||||
var model = this.collection.at(1);
|
||||
|
||||
@@ -49,8 +49,7 @@ function($, _, str, gettext, BaseView, SignatoryModel, SignatoryDetailsView, Vie
|
||||
return self.model.set('editing', true);
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.model.set('editing', true);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@ function($, _, Backbone, gettext,
|
||||
'change .certificate-course-title-input': 'setCourseTitle',
|
||||
'focus .input-text': 'onFocus',
|
||||
'blur .input-text': 'onBlur',
|
||||
'submit': 'setAndClose',
|
||||
submit: 'setAndClose',
|
||||
'click .action-cancel': 'cancel',
|
||||
'click .action-add-signatory': 'addSignatory'
|
||||
},
|
||||
|
||||
@@ -23,8 +23,8 @@ function(gettext, ListItemView, CertificateDetailsView, CertificateEditorView) {
|
||||
attributes: function() {
|
||||
// Retrieves the defined attribute set
|
||||
return {
|
||||
'id': this.model.get('id'),
|
||||
'tabindex': -1
|
||||
id: this.model.get('id'),
|
||||
tabindex: -1
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -76,10 +76,10 @@ function($, _, str, Backbone, gettext, TemplateUtils, ViewUtils, BaseView, Signa
|
||||
actionableModel.setOriginalAttributes();
|
||||
dfd.resolve();
|
||||
self.closeSignatoryEditView();
|
||||
}.bind(this)
|
||||
}
|
||||
});
|
||||
return dfd;
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
closeSignatoryEditView: function(event) {
|
||||
|
||||
@@ -144,8 +144,7 @@ function($, _, Backbone, gettext,
|
||||
if (model.isNew()) {
|
||||
model.collection.remove(model);
|
||||
self.eventAgg.trigger('onSignatoryRemoved', model);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
deleting.show();
|
||||
model.destroy({
|
||||
wait: true,
|
||||
@@ -200,8 +199,7 @@ function($, _, Backbone, gettext,
|
||||
$(selector).addClass('error');
|
||||
$(selector).append("<span class='message-error'>" + errorMessage + '</span>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Remove the error message.
|
||||
$(selector).removeClass('error');
|
||||
$(selector + '>span.message-error').remove();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
define(['js/base', 'cms/js/main', 'js/src/logger', 'datepair', 'accessibility',
|
||||
'ieshim', 'tooltip_manager', 'lang_edx', 'js/models/course']);
|
||||
'ieshim', 'tooltip_manager', 'lang_edx', 'js/models/course']);
|
||||
|
||||
@@ -22,10 +22,10 @@ define(['jquery.cookie', 'utility', 'common/js/components/utils/view_utils'], fu
|
||||
|
||||
$('form#login_form').submit(function(event) {
|
||||
event.preventDefault();
|
||||
var submitButton = $('#submit'),
|
||||
var $submitButton = $('#submit'),
|
||||
deferred = new $.Deferred(),
|
||||
promise = deferred.promise();
|
||||
ViewUtils.disableElementWhileRunning(submitButton, function() { return promise; });
|
||||
ViewUtils.disableElementWhileRunning($submitButton, function() { return promise; });
|
||||
var submit_data = $('#login_form').serialize();
|
||||
|
||||
postJSON('/login_post', submit_data, function(json) {
|
||||
|
||||
@@ -16,7 +16,7 @@ function(_, gettext, ManageUsersAndRoles) {
|
||||
// Roles order are important: first role is considered initial role (the role added to user when (s)he's added
|
||||
// Last role is considered an admin role (unrestricted access + ability to manage other users' permissions)
|
||||
// Changing roles is performed in promote-demote fashion, so moves only to adjacent roles is allowed
|
||||
var roles = [{key: 'staff', name: gettext('Staff')}, {key: 'instructor', 'name': gettext('Admin')}];
|
||||
var roles = [{key: 'staff', name: gettext('Staff')}, {key: 'instructor', name: gettext('Admin')}];
|
||||
|
||||
var options = {
|
||||
el: $('#content'),
|
||||
|
||||
@@ -19,7 +19,7 @@ function(_, gettext, ManageUsersAndRoles) {
|
||||
var roles = [
|
||||
{key: 'library_user', name: gettext('Library User')},
|
||||
{key: 'staff', name: gettext('Staff')},
|
||||
{key: 'instructor', 'name': gettext('Admin')}
|
||||
{key: 'instructor', name: gettext('Admin')}
|
||||
];
|
||||
|
||||
var options = {
|
||||
|
||||
@@ -24,17 +24,16 @@ define([
|
||||
editor.render();
|
||||
|
||||
$('#deprecated-settings').click(function() {
|
||||
var wrapperDeprecatedSetting = $('.wrapper-deprecated-setting'),
|
||||
deprecatedSettingsLabel = $('.deprecated-settings-label');
|
||||
var $wrapperDeprecatedSetting = $('.wrapper-deprecated-setting'),
|
||||
$deprecatedSettingsLabel = $('.deprecated-settings-label');
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
wrapperDeprecatedSetting.addClass('is-set');
|
||||
deprecatedSettingsLabel.text(gettext('Hide Deprecated Settings'));
|
||||
$wrapperDeprecatedSetting.addClass('is-set');
|
||||
$deprecatedSettingsLabel.text(gettext('Hide Deprecated Settings'));
|
||||
editor.render_deprecated = true;
|
||||
}
|
||||
else {
|
||||
wrapperDeprecatedSetting.removeClass('is-set');
|
||||
deprecatedSettingsLabel.text(gettext('Show Deprecated Settings'));
|
||||
} else {
|
||||
$wrapperDeprecatedSetting.removeClass('is-set');
|
||||
$deprecatedSettingsLabel.text(gettext('Show Deprecated Settings'));
|
||||
editor.render_deprecated = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['backbone'], function(Backbone) {
|
||||
var Course = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'name': ''
|
||||
name: ''
|
||||
},
|
||||
validate: function(attrs, options) {
|
||||
if (!attrs.name) {
|
||||
|
||||
@@ -5,8 +5,8 @@ define(['backbone'], function(Backbone) {
|
||||
url: '',
|
||||
|
||||
defaults: {
|
||||
'updates': null, // UpdateCollection
|
||||
'handouts': null // HandoutCollection
|
||||
updates: null, // UpdateCollection
|
||||
handouts: null // HandoutCollection
|
||||
}
|
||||
});
|
||||
return CourseInfo;
|
||||
|
||||
@@ -2,16 +2,16 @@ define(['backbone', 'jquery', 'jquery.ui'], function(Backbone, $) {
|
||||
// course update -- biggest kludge here is the lack of a real id to map updates to originals
|
||||
var CourseUpdate = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'date': $.datepicker.formatDate('MM d, yy', new Date()),
|
||||
'content': '',
|
||||
'push_notification_enabled': false,
|
||||
'push_notification_selected': false
|
||||
date: $.datepicker.formatDate('MM d, yy', new Date()),
|
||||
content: '',
|
||||
push_notification_enabled: false,
|
||||
push_notification_selected: false
|
||||
},
|
||||
validate: function(attrs) {
|
||||
var date_exists = (attrs.date !== null && attrs.date !== '');
|
||||
var date_is_valid_string = ($.datepicker.formatDate('MM d, yy', new Date(attrs.date)) === attrs.date);
|
||||
if (!(date_exists && date_is_valid_string)) {
|
||||
return {'date_required': gettext('Action required: Enter a valid date.')};
|
||||
return {date_required: gettext('Action required: Enter a valid date.')};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
define(['backbone'], function(Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'explicit_url': ''
|
||||
explicit_url: ''
|
||||
},
|
||||
url: function() {
|
||||
return this.get('explicit_url');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
var LicenseModel = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'type': null,
|
||||
'options': {},
|
||||
'custom': false // either `false`, or a string
|
||||
type: null,
|
||||
options: {},
|
||||
custom: false // either `false`, or a string
|
||||
},
|
||||
|
||||
initialize: function(attributes) {
|
||||
@@ -55,16 +55,16 @@ define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
if (spaceIndex == -1) {
|
||||
// if there's no space, it's a license type without options
|
||||
return this.set({
|
||||
'type': string,
|
||||
'options': {},
|
||||
'custom': false
|
||||
type: string,
|
||||
options: {},
|
||||
custom: false
|
||||
}, options);
|
||||
} else {
|
||||
// if there is a space, it's a custom license
|
||||
return this.set({
|
||||
'type': null,
|
||||
'options': {},
|
||||
'custom': string
|
||||
type: null,
|
||||
options: {},
|
||||
custom: string
|
||||
}, options);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
});
|
||||
|
||||
return this.set({
|
||||
'type': type, 'options': optionsObj, 'custom': false
|
||||
type: type, options: optionsObj, custom: false
|
||||
}, options);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,11 +9,11 @@ define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
},
|
||||
toUrl: function(overrides) {
|
||||
return;
|
||||
(overrides && overrides['tag'] ? overrides['tag'] : this.get('tag')) + '://' +
|
||||
(overrides && overrides['org'] ? overrides['org'] : this.get('org')) + '/' +
|
||||
(overrides && overrides['course'] ? overrides['course'] : this.get('course')) + '/' +
|
||||
(overrides && overrides['category'] ? overrides['category'] : this.get('category')) + '/' +
|
||||
(overrides && overrides['name'] ? overrides['name'] : this.get('name')) + '/';
|
||||
(overrides && overrides.tag ? overrides.tag : this.get('tag')) + '://' +
|
||||
(overrides && overrides.org ? overrides.org : this.get('org')) + '/' +
|
||||
(overrides && overrides.course ? overrides.course : this.get('course')) + '/' +
|
||||
(overrides && overrides.category ? overrides.category : this.get('category')) + '/' +
|
||||
(overrides && overrides.name ? overrides.name : this.get('name')) + '/';
|
||||
},
|
||||
_tagPattern: /[^:]+/g,
|
||||
_fieldPattern: new RegExp('[^/]+', 'g'),
|
||||
@@ -27,8 +27,7 @@ define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
category: payload[3],
|
||||
name: payload[4]
|
||||
};
|
||||
}
|
||||
else if (_.isString(payload)) {
|
||||
} else if (_.isString(payload)) {
|
||||
this._tagPattern.lastIndex = 0; // odd regex behavior requires this to be reset sometimes
|
||||
var foundTag = this._tagPattern.exec(payload);
|
||||
if (foundTag) {
|
||||
@@ -40,18 +39,15 @@ define(['backbone', 'underscore'], function(Backbone, _) {
|
||||
category: this.getNextField(payload),
|
||||
name: this.getNextField(payload)
|
||||
};
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
else {
|
||||
} else return null;
|
||||
} else {
|
||||
return payload;
|
||||
}
|
||||
},
|
||||
getNextField: function(payload) {
|
||||
try {
|
||||
return this._fieldPattern.exec(payload)[0];
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ define(['backbone'], function(Backbone) {
|
||||
*/
|
||||
var Metadata = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'field_name': null,
|
||||
'display_name': null,
|
||||
'value': null,
|
||||
'explicitly_set': null,
|
||||
'default_value': null,
|
||||
'options': null,
|
||||
'type': null
|
||||
field_name: null,
|
||||
display_name: null,
|
||||
value: null,
|
||||
explicitly_set: null,
|
||||
default_value: null,
|
||||
options: null,
|
||||
type: null
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
||||
@@ -3,10 +3,10 @@ define(['backbone', 'js/utils/module'], function(Backbone, ModuleUtils) {
|
||||
urlRoot: ModuleUtils.urlRoot,
|
||||
|
||||
defaults: {
|
||||
'id': null,
|
||||
'data': null,
|
||||
'metadata': null,
|
||||
'children': null
|
||||
id: null,
|
||||
data: null,
|
||||
metadata: null,
|
||||
children: null
|
||||
}
|
||||
});
|
||||
return ModuleInfo;
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['backbone', 'gettext', 'common/js/components/views/feedback_notification
|
||||
function(Backbone, gettext, NotificationView, ModuleUtils) {
|
||||
var Section = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'name': ''
|
||||
name: ''
|
||||
},
|
||||
validate: function(attrs, options) {
|
||||
if (!attrs.name) {
|
||||
|
||||
@@ -90,7 +90,7 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js
|
||||
set_videosource: function(newsource) {
|
||||
// newsource either is <video youtube="speed:key, *"/> or just the "speed:key, *" string
|
||||
// returns the videosource for the preview which iss the key whose speed is closest to 1
|
||||
if (_.isEmpty(newsource) && !_.isEmpty(this.get('intro_video'))) this.set({'intro_video': null}, {validate: true});
|
||||
if (_.isEmpty(newsource) && !_.isEmpty(this.get('intro_video'))) this.set({intro_video: null}, {validate: true});
|
||||
// TODO remove all whitespace w/in string
|
||||
else {
|
||||
if (this.get('intro_video') !== newsource) this.set('intro_video', newsource, {validate: true});
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
define(['backbone', 'underscore', 'gettext'], function(Backbone, _, gettext) {
|
||||
var CourseGrader = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'type': '', // must be unique w/in collection (ie. w/in course)
|
||||
'min_count': 1,
|
||||
'drop_count': 0,
|
||||
'short_label': '', // what to use in place of type if space is an issue
|
||||
'weight': 0 // int 0..100
|
||||
type: '', // must be unique w/in collection (ie. w/in course)
|
||||
min_count: 1,
|
||||
drop_count: 0,
|
||||
short_label: '', // what to use in place of type if space is an issue
|
||||
weight: 0 // int 0..100
|
||||
},
|
||||
parse: function(attrs) {
|
||||
// round off values while converting them to integer
|
||||
if (attrs['weight']) {
|
||||
if (attrs.weight) {
|
||||
attrs.weight = Math.round(attrs.weight);
|
||||
}
|
||||
if (attrs['min_count']) {
|
||||
if (attrs.min_count) {
|
||||
attrs.min_count = Math.round(attrs.min_count);
|
||||
}
|
||||
if (attrs['drop_count']) {
|
||||
if (attrs.drop_count) {
|
||||
attrs.drop_count = Math.round(attrs.drop_count);
|
||||
}
|
||||
return attrs;
|
||||
@@ -23,12 +23,11 @@ define(['backbone', 'underscore', 'gettext'], function(Backbone, _, gettext) {
|
||||
validate: function(attrs) {
|
||||
var errors = {};
|
||||
if (_.has(attrs, 'type')) {
|
||||
if (_.isEmpty(attrs['type'])) {
|
||||
if (_.isEmpty(attrs.type)) {
|
||||
errors.type = gettext('The assignment type must have a name.');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// FIXME somehow this.collection is unbound sometimes. I can't track down when
|
||||
var existing = this.collection && this.collection.some(function(other) { return (other.cid != this.cid) && (other.get('type') == attrs['type']); }, this);
|
||||
var existing = this.collection && this.collection.some(function(other) { return (other.cid != this.cid) && (other.get('type') == attrs.type); }, this);
|
||||
if (existing) {
|
||||
errors.type = gettext("There's already another assignment type with this name.");
|
||||
}
|
||||
@@ -38,8 +37,7 @@ define(['backbone', 'underscore', 'gettext'], function(Backbone, _, gettext) {
|
||||
var intWeight = Math.round(attrs.weight); // see if this ensures value saved is int
|
||||
if (!isFinite(intWeight) || /\D+/.test(attrs.weight) || intWeight < 0 || intWeight > 100) {
|
||||
errors.weight = gettext('Please enter an integer between 0 and 100.');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
attrs.weight = intWeight;
|
||||
if (this.collection && attrs.weight > 0) {
|
||||
// FIXME b/c saves don't update the models if validation fails, we should
|
||||
@@ -48,21 +46,20 @@ define(['backbone', 'underscore', 'gettext'], function(Backbone, _, gettext) {
|
||||
// if ((this.collection.sumWeights() + attrs.weight - this.get('weight')) > 100)
|
||||
// errors.weight = "The weights cannot add to more than 100.";
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
if (_.has(attrs, 'min_count')) {
|
||||
var intMinCount = Math.round(attrs.min_count);
|
||||
if (!isFinite(intMinCount) || /\D+/.test(attrs.min_count) || intMinCount < 1) {
|
||||
errors.min_count = gettext('Please enter an integer greater than 0.');
|
||||
}
|
||||
else attrs.min_count = intMinCount;
|
||||
} else attrs.min_count = intMinCount;
|
||||
}
|
||||
if (_.has(attrs, 'drop_count')) {
|
||||
var dropCount = attrs.drop_count;
|
||||
var intDropCount = Math.round(dropCount);
|
||||
if (!isFinite(intDropCount) || /\D+/.test(dropCount) || (_.isString(dropCount) && _.isEmpty(dropCount.trim())) || intDropCount < 0) {
|
||||
errors.drop_count = gettext('Please enter non-negative integer.');
|
||||
}
|
||||
else attrs.drop_count = intDropCount;
|
||||
} else attrs.drop_count = intDropCount;
|
||||
}
|
||||
if (_.has(attrs, 'min_count') && _.has(attrs, 'drop_count') && !_.has(errors, 'min_count') && !_.has(errors, 'drop_count') && attrs.drop_count > attrs.min_count) {
|
||||
var template = _.template(
|
||||
|
||||
@@ -8,21 +8,20 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'],
|
||||
minimum_grade_credit: null // either null or percentage
|
||||
},
|
||||
parse: function(attributes) {
|
||||
if (attributes['graders']) {
|
||||
if (attributes.graders) {
|
||||
var graderCollection;
|
||||
// interesting race condition: if {parse:true} when newing, then parse called before .attributes created
|
||||
if (this.attributes && this.has('graders')) {
|
||||
graderCollection = this.get('graders');
|
||||
graderCollection.reset(attributes.graders, {parse: true});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
graderCollection = new CourseGraderCollection(attributes.graders, {parse: true});
|
||||
}
|
||||
attributes.graders = graderCollection;
|
||||
}
|
||||
// If grace period is unset or equal to 00:00 on the server,
|
||||
// it's received as null
|
||||
if (attributes['grace_period'] === null) {
|
||||
if (attributes.grace_period === null) {
|
||||
attributes.grace_period = {
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
@@ -37,15 +36,9 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'],
|
||||
},
|
||||
gracePeriodToDate: function() {
|
||||
var newDate = new Date();
|
||||
if (this.has('grace_period') && this.get('grace_period')['hours'])
|
||||
newDate.setHours(this.get('grace_period')['hours']);
|
||||
else newDate.setHours(0);
|
||||
if (this.has('grace_period') && this.get('grace_period')['minutes'])
|
||||
newDate.setMinutes(this.get('grace_period')['minutes']);
|
||||
else newDate.setMinutes(0);
|
||||
if (this.has('grace_period') && this.get('grace_period')['seconds'])
|
||||
newDate.setSeconds(this.get('grace_period')['seconds']);
|
||||
else newDate.setSeconds(0);
|
||||
if (this.has('grace_period') && this.get('grace_period').hours) { newDate.setHours(this.get('grace_period').hours); } else newDate.setHours(0);
|
||||
if (this.has('grace_period') && this.get('grace_period').minutes) { newDate.setMinutes(this.get('grace_period').minutes); } else newDate.setMinutes(0);
|
||||
if (this.has('grace_period') && this.get('grace_period').seconds) { newDate.setSeconds(this.get('grace_period').seconds); } else newDate.setSeconds(0);
|
||||
|
||||
return newDate;
|
||||
},
|
||||
@@ -69,9 +62,9 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'],
|
||||
},
|
||||
validate: function(attrs) {
|
||||
if (_.has(attrs, 'grace_period')) {
|
||||
if (attrs['grace_period'] === null) {
|
||||
if (attrs.grace_period === null) {
|
||||
return {
|
||||
'grace_period': gettext('Grace period must be specified in HH:MM format.')
|
||||
grace_period: gettext('Grace period must be specified in HH:MM format.')
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -80,7 +73,7 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'],
|
||||
var minimum_grade_cutoff = _.min(_.values(attrs.grade_cutoffs));
|
||||
if (isNaN(attrs.minimum_grade_credit) || attrs.minimum_grade_credit === null || attrs.minimum_grade_credit < minimum_grade_cutoff) {
|
||||
return {
|
||||
'minimum_grade_credit': interpolate(
|
||||
minimum_grade_credit: interpolate(
|
||||
gettext('Not able to set passing grade to less than %(minimum_grade_cutoff)s%.'),
|
||||
{minimum_grade_cutoff: minimum_grade_cutoff * 100},
|
||||
true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['backbone', 'underscore', 'gettext', 'js/models/chapter', 'js/collections/chapter',
|
||||
'backbone.associations', 'cms/js/main'],
|
||||
'backbone.associations', 'cms/js/main'],
|
||||
function(Backbone, _, gettext, ChapterModel, ChapterCollection) {
|
||||
var Textbook = Backbone.AssociatedModel.extend({
|
||||
defaults: function() {
|
||||
@@ -40,7 +40,7 @@ define(['backbone', 'underscore', 'gettext', 'js/models/chapter', 'js/collection
|
||||
delete ret.tab_title;
|
||||
}
|
||||
if ('url' in ret && !('chapters' in ret)) {
|
||||
ret.chapters = {'url': ret.url};
|
||||
ret.chapters = {url: ret.url};
|
||||
delete ret.url;
|
||||
}
|
||||
_.each(ret.chapters, function(chapter, i) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
define(['backbone', 'underscore', 'gettext'], function(Backbone, _, gettext) {
|
||||
var FileUpload = Backbone.Model.extend({
|
||||
defaults: {
|
||||
'title': '',
|
||||
'message': '',
|
||||
'selectedFile': null,
|
||||
'uploading': false,
|
||||
'uploadedBytes': 0,
|
||||
'totalBytes': 0,
|
||||
'finished': false,
|
||||
'mimeTypes': [],
|
||||
'fileFormats': []
|
||||
title: '',
|
||||
message: '',
|
||||
selectedFile: null,
|
||||
uploading: false,
|
||||
uploadedBytes: 0,
|
||||
totalBytes: 0,
|
||||
finished: false,
|
||||
mimeTypes: [],
|
||||
fileFormats: []
|
||||
},
|
||||
validate: function(attrs, options) {
|
||||
if (attrs.selectedFile && !this.checkTypeValidity(attrs.selectedFile)) {
|
||||
|
||||
@@ -14,6 +14,6 @@ define(['jquery'],
|
||||
};
|
||||
|
||||
return {
|
||||
'validateIntegerRange': validateIntegerRange
|
||||
validateIntegerRange: validateIntegerRange
|
||||
};
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['js/models/custom_sync_xblock_info'],
|
||||
function(CustomSyncXBlockInfo) {
|
||||
var XBlockContainerInfo = CustomSyncXBlockInfo.extend({
|
||||
urlRoots: {
|
||||
'read': '/xblock/container'
|
||||
read: '/xblock/container'
|
||||
}
|
||||
});
|
||||
return XBlockContainerInfo;
|
||||
|
||||
@@ -3,7 +3,7 @@ define(['js/models/custom_sync_xblock_info'],
|
||||
var XBlockOutlineInfo = CustomSyncXBlockInfo.extend({
|
||||
|
||||
urlRoots: {
|
||||
'read': '/xblock/outline'
|
||||
read: '/xblock/outline'
|
||||
},
|
||||
|
||||
createChild: function(response) {
|
||||
|
||||
@@ -23,10 +23,10 @@ define(['jquery', 'js/factories/xblock_validation', 'common/js/spec_helpers/temp
|
||||
var noContainerContent = 'no-container-content';
|
||||
|
||||
var notConfiguredMessages = {
|
||||
'empty': false,
|
||||
'summary': {'text': 'my summary', 'type': 'not-configured'},
|
||||
'messages': [],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
summary: {text: 'my summary', type: 'not-configured'},
|
||||
messages: [],
|
||||
xblock_id: 'id'
|
||||
};
|
||||
// Root is false, will not add noContainerContent.
|
||||
XBlockValidationFactory(notConfiguredMessages, true, false, false, $messageDiv);
|
||||
@@ -42,10 +42,10 @@ define(['jquery', 'js/factories/xblock_validation', 'common/js/spec_helpers/temp
|
||||
|
||||
beforeEach(function() {
|
||||
messagesWithSummary = {
|
||||
'empty': false,
|
||||
'summary': {'text': 'my summary'},
|
||||
'messages': [{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
summary: {text: 'my summary'},
|
||||
messages: [{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
xblock_id: 'id'
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -2,54 +2,54 @@ define(['js/models/component_template'],
|
||||
function(ComponentTemplate) {
|
||||
describe('ComponentTemplates', function() {
|
||||
var mockTemplateJSON = {
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'formularesponse.yaml',
|
||||
'display_name': 'Math Expression Input'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'formularesponse.yaml',
|
||||
display_name: 'Math Expression Input'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Blank Advanced Problem'
|
||||
category: 'problem',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Blank Advanced Problem'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'checkboxes.yaml',
|
||||
'display_name': 'Checkboxes'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'checkboxes.yaml',
|
||||
display_name: 'Checkboxes'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'multiple_choice.yaml',
|
||||
'display_name': 'Multiple Choice'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'multiple_choice.yaml',
|
||||
display_name: 'Multiple Choice'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'drag_and_drop.yaml',
|
||||
'display_name': 'Drag and Drop'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'drag_and_drop.yaml',
|
||||
display_name: 'Drag and Drop'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'problem_with_hint.yaml',
|
||||
'display_name': 'Problem with Adaptive Hint'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'problem_with_hint.yaml',
|
||||
display_name: 'Problem with Adaptive Hint'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'imageresponse.yaml',
|
||||
'display_name': 'Image Mapped Input'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'imageresponse.yaml',
|
||||
display_name: 'Image Mapped Input'
|
||||
}, {
|
||||
'category': 'openassessment',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Peer Assessment'
|
||||
category: 'openassessment',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Peer Assessment'
|
||||
}, {
|
||||
'category': 'problem',
|
||||
'boilerplate_name': 'an_easy_problem.yaml',
|
||||
'display_name': 'An Easy Problem'
|
||||
category: 'problem',
|
||||
boilerplate_name: 'an_easy_problem.yaml',
|
||||
display_name: 'An Easy Problem'
|
||||
}, {
|
||||
'category': 'word_cloud',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Word Cloud'
|
||||
category: 'word_cloud',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Word Cloud'
|
||||
}, { // duplicate display name to verify sort behavior
|
||||
'category': 'word_cloud',
|
||||
'boilerplate_name': 'alternate_word_cloud.yaml',
|
||||
'display_name': 'Word Cloud'
|
||||
category: 'word_cloud',
|
||||
boilerplate_name: 'alternate_word_cloud.yaml',
|
||||
display_name: 'Word Cloud'
|
||||
}],
|
||||
'type': 'problem',
|
||||
'support_legend': {'show_legend': false}
|
||||
type: 'problem',
|
||||
support_legend: {show_legend: false}
|
||||
};
|
||||
|
||||
it('orders templates correctly', function() {
|
||||
@@ -60,16 +60,16 @@ define(['js/models/component_template'],
|
||||
componentTemplate.parse(mockTemplateJSON);
|
||||
for (i = 0; i < componentTemplate.templates.length; i++) {
|
||||
template = componentTemplate.templates[i];
|
||||
templateName = template['display_name'];
|
||||
templateName = template.display_name;
|
||||
if (lastTemplate) {
|
||||
if (!firstComparison || lastTemplate['boilerplate_name']) {
|
||||
expect(lastTemplate['display_name'] < templateName).toBeTruthy();
|
||||
if (!firstComparison || lastTemplate.boilerplate_name) {
|
||||
expect(lastTemplate.display_name < templateName).toBeTruthy();
|
||||
}
|
||||
firstComparison = false;
|
||||
} else {
|
||||
// If the first template is blank, make sure that it has the correct category
|
||||
if (!template['boilerplate_name']) {
|
||||
expect(template['category']).toBe('problem');
|
||||
if (!template.boilerplate_name) {
|
||||
expect(template.category).toBe('problem');
|
||||
}
|
||||
lastTemplate = template;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['js/models/explicit_url'],
|
||||
function(Model) {
|
||||
describe('Model ', function() {
|
||||
it('allows url to be passed in constructor', function() {
|
||||
expect(new Model({'explicit_url': '/fancy/url'}).url()).toBe('/fancy/url');
|
||||
expect(new Model({explicit_url: '/fancy/url'}).url()).toBe('/fancy/url');
|
||||
});
|
||||
it('returns empty string if url not set', function() {
|
||||
expect(new Model().url()).toBe('');
|
||||
|
||||
@@ -86,45 +86,45 @@ define([
|
||||
|
||||
it('should match server model to client model', function() {
|
||||
var serverModelSpec = {
|
||||
'id': 10,
|
||||
'name': 'My Group Configuration',
|
||||
'description': 'Some description',
|
||||
'version': 2,
|
||||
'scheme': 'random',
|
||||
'groups': [
|
||||
id: 10,
|
||||
name: 'My Group Configuration',
|
||||
description: 'Some description',
|
||||
version: 2,
|
||||
scheme: 'random',
|
||||
groups: [
|
||||
{
|
||||
'version': 1,
|
||||
'name': 'Group 1',
|
||||
'usage': []
|
||||
version: 1,
|
||||
name: 'Group 1',
|
||||
usage: []
|
||||
}, {
|
||||
'version': 1,
|
||||
'name': 'Group 2',
|
||||
'usage': []
|
||||
version: 1,
|
||||
name: 'Group 2',
|
||||
usage: []
|
||||
}
|
||||
]
|
||||
},
|
||||
clientModelSpec = {
|
||||
'id': 10,
|
||||
'name': 'My Group Configuration',
|
||||
'description': 'Some description',
|
||||
'scheme': 'random',
|
||||
'showGroups': false,
|
||||
'editing': false,
|
||||
'version': 2,
|
||||
'groups': [
|
||||
id: 10,
|
||||
name: 'My Group Configuration',
|
||||
description: 'Some description',
|
||||
scheme: 'random',
|
||||
showGroups: false,
|
||||
editing: false,
|
||||
version: 2,
|
||||
groups: [
|
||||
{
|
||||
'version': 1,
|
||||
'order': 0,
|
||||
'name': 'Group 1',
|
||||
'usage': []
|
||||
version: 1,
|
||||
order: 0,
|
||||
name: 'Group 1',
|
||||
usage: []
|
||||
}, {
|
||||
'version': 1,
|
||||
'order': 1,
|
||||
'name': 'Group 2',
|
||||
'usage': []
|
||||
version: 1,
|
||||
order: 1,
|
||||
name: 'Group 2',
|
||||
usage: []
|
||||
}
|
||||
],
|
||||
'usage': []
|
||||
usage: []
|
||||
},
|
||||
model = new GroupConfigurationModel(
|
||||
serverModelSpec, {parse: true}
|
||||
|
||||
@@ -9,22 +9,22 @@ define(['js/models/license'], function(LicenseModel) {
|
||||
|
||||
it('accepts normal arguments', function() {
|
||||
var model = new LicenseModel({
|
||||
'type': 'creative-commons',
|
||||
'options': {'fake-boolean': true, 'version': 'your momma'}
|
||||
type: 'creative-commons',
|
||||
options: {'fake-boolean': true, version: 'your momma'}
|
||||
});
|
||||
expect(model.get('type')).toEqual('creative-commons');
|
||||
expect(model.get('options')).toEqual({'fake-boolean': true, 'version': 'your momma'});
|
||||
expect(model.get('options')).toEqual({'fake-boolean': true, version: 'your momma'});
|
||||
});
|
||||
|
||||
it('accepts a license string argument', function() {
|
||||
var model = new LicenseModel({'asString': 'all-rights-reserved'});
|
||||
var model = new LicenseModel({asString: 'all-rights-reserved'});
|
||||
expect(model.get('type')).toEqual('all-rights-reserved');
|
||||
expect(model.get('options')).toEqual({});
|
||||
expect(model.get('custom')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('accepts a custom license argument', function() {
|
||||
var model = new LicenseModel({'asString': 'Mozilla Public License 2.0'});
|
||||
var model = new LicenseModel({asString: 'Mozilla Public License 2.0'});
|
||||
expect(model.get('type')).toBeNull();
|
||||
expect(model.get('options')).toEqual({});
|
||||
expect(model.get('custom')).toEqual('Mozilla Public License 2.0');
|
||||
@@ -39,7 +39,7 @@ define(['js/models/license'], function(LicenseModel) {
|
||||
it('can parse license strings', function() {
|
||||
this.model.setFromString('creative-commons: BY');
|
||||
expect(this.model.get('type')).toEqual('creative-commons');
|
||||
expect(this.model.get('options')).toEqual({'BY': true});
|
||||
expect(this.model.get('options')).toEqual({BY: true});
|
||||
expect(this.model.get('custom')).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -54,17 +54,17 @@ define(['js/models/license'], function(LicenseModel) {
|
||||
|
||||
it('can stringify a license with options', function() {
|
||||
this.model.set({
|
||||
'type': 'abc',
|
||||
'options': {'ping': 'pong', 'bing': true, 'buzz': true, 'beep': false}}
|
||||
type: 'abc',
|
||||
options: {ping: 'pong', bing: true, buzz: true, beep: false}}
|
||||
);
|
||||
expect(this.model.toString()).toEqual('abc: ping=pong bing buzz');
|
||||
});
|
||||
|
||||
it('can stringify a custom license', function() {
|
||||
this.model.set({
|
||||
'type': "doesn't matter",
|
||||
'options': {'ignore': 'me'},
|
||||
'custom': 'this is my super cool license'
|
||||
type: "doesn't matter",
|
||||
options: {ignore: 'me'},
|
||||
custom: 'this is my super cool license'
|
||||
});
|
||||
expect(this.model.toString()).toEqual('this is my super cool license');
|
||||
});
|
||||
|
||||
@@ -2,48 +2,48 @@ define(['backbone', 'js/models/xblock_info'],
|
||||
function(Backbone, XBlockInfo) {
|
||||
describe('XblockInfo isEditableOnCourseOutline', function() {
|
||||
it('works correct', function() {
|
||||
expect(new XBlockInfo({'category': 'chapter'}).isEditableOnCourseOutline()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'course'}).isEditableOnCourseOutline()).toBe(false);
|
||||
expect(new XBlockInfo({'category': 'sequential'}).isEditableOnCourseOutline()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'vertical'}).isEditableOnCourseOutline()).toBe(true);
|
||||
expect(new XBlockInfo({category: 'chapter'}).isEditableOnCourseOutline()).toBe(true);
|
||||
expect(new XBlockInfo({category: 'course'}).isEditableOnCourseOutline()).toBe(false);
|
||||
expect(new XBlockInfo({category: 'sequential'}).isEditableOnCourseOutline()).toBe(true);
|
||||
expect(new XBlockInfo({category: 'vertical'}).isEditableOnCourseOutline()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('XblockInfo actions state and header visibility ', function() {
|
||||
it('works correct to hide icons e.g. trash icon, drag when actions are not required', function() {
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'deletable': false}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {deletable: false}})
|
||||
.isDeletable()).toBe(false);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'draggable': false}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {draggable: false}})
|
||||
.isDraggable()).toBe(false);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'childAddable': false}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {childAddable: false}})
|
||||
.isChildAddable()).toBe(false);
|
||||
});
|
||||
|
||||
it('works correct to show icons e.g. trash icon, drag when actions are required', function() {
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'deletable': true}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {deletable: true}})
|
||||
.isDeletable()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'draggable': true}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {draggable: true}})
|
||||
.isDraggable()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {'childAddable': true}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {childAddable: true}})
|
||||
.isChildAddable()).toBe(true);
|
||||
});
|
||||
|
||||
it('displays icons e.g. trash icon, drag when actions are undefined', function() {
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {}})
|
||||
.isDeletable()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {}})
|
||||
.isDraggable()).toBe(true);
|
||||
expect(new XBlockInfo({'category': 'chapter', 'actions': {}})
|
||||
expect(new XBlockInfo({category: 'chapter', actions: {}})
|
||||
.isChildAddable()).toBe(true);
|
||||
});
|
||||
|
||||
it('works correct to hide header content', function() {
|
||||
expect(new XBlockInfo({'category': 'sequential', 'is_header_visible': false})
|
||||
expect(new XBlockInfo({category: 'sequential', is_header_visible: false})
|
||||
.isHeaderVisible()).toBe(false);
|
||||
});
|
||||
|
||||
it('works correct to show header content when is_header_visible is not defined', function() {
|
||||
expect(new XBlockInfo({'category': 'sequential', 'actions': {'deletable': true}})
|
||||
expect(new XBlockInfo({category: 'sequential', actions: {deletable: true}})
|
||||
.isHeaderVisible()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,18 +12,18 @@ define(['js/models/xblock_validation'],
|
||||
describe('XBlockValidationModel', function() {
|
||||
it('handles empty variable', function() {
|
||||
verifyModel(new XBlockValidationModel({parse: true}), true, {}, [], null);
|
||||
verifyModel(new XBlockValidationModel({'empty': true}, {parse: true}), true, {}, [], null);
|
||||
verifyModel(new XBlockValidationModel({empty: true}, {parse: true}), true, {}, [], null);
|
||||
|
||||
// It is assumed that the "empty" state on the JSON object passed in is correct
|
||||
// (no attempt is made to correct other variables based on empty==true).
|
||||
verifyModel(
|
||||
new XBlockValidationModel(
|
||||
{'empty': true, 'messages': [{'text': 'Bad JSON case'}], 'xblock_id': 'id'},
|
||||
{empty: true, messages: [{text: 'Bad JSON case'}], xblock_id: 'id'},
|
||||
{parse: true}
|
||||
),
|
||||
true,
|
||||
{},
|
||||
[{'text': 'Bad JSON case'}], 'id'
|
||||
[{text: 'Bad JSON case'}], 'id'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -31,36 +31,36 @@ define(['js/models/xblock_validation'],
|
||||
// Single warning message.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
xblock_id: 'id'
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'This component has validation issues.', 'type': 'warning'},
|
||||
{text: 'This component has validation issues.', type: 'warning'},
|
||||
[],
|
||||
'id'
|
||||
);
|
||||
// Two messages that compute to a "warning" state in the summary.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'messages': [{'text': 'one', 'type': 'not-configured'}, {'text': 'two', 'type': 'warning'}],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
messages: [{text: 'one', type: 'not-configured'}, {text: 'two', type: 'warning'}],
|
||||
xblock_id: 'id'
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'This component has validation issues.', 'type': 'warning'},
|
||||
[{'text': 'one', 'type': 'not-configured'}, {'text': 'two', 'type': 'warning'}],
|
||||
{text: 'This component has validation issues.', type: 'warning'},
|
||||
[{text: 'one', type: 'not-configured'}, {text: 'two', type: 'warning'}],
|
||||
'id'
|
||||
);
|
||||
// Two messages, with one of them "error", resulting in an "error" state in the summary.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'messages': [{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
messages: [{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
xblock_id: 'id'
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'This component has validation issues.', 'type': 'error'},
|
||||
[{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
{text: 'This component has validation issues.', type: 'error'},
|
||||
[{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
'id'
|
||||
);
|
||||
});
|
||||
@@ -69,51 +69,51 @@ define(['js/models/xblock_validation'],
|
||||
// Summary already present (both text and type), no messages.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'xblock_id': 'id',
|
||||
'summary': {'text': 'my summary', 'type': 'custom type'}
|
||||
empty: false,
|
||||
xblock_id: 'id',
|
||||
summary: {text: 'my summary', type: 'custom type'}
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'my summary', 'type': 'custom type'},
|
||||
{text: 'my summary', type: 'custom type'},
|
||||
[],
|
||||
'id'
|
||||
);
|
||||
// Summary text present, but not type (will get default value of warning).
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'xblock_id': 'id',
|
||||
'summary': {'text': 'my summary'}
|
||||
empty: false,
|
||||
xblock_id: 'id',
|
||||
summary: {text: 'my summary'}
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'my summary', 'type': 'warning'},
|
||||
{text: 'my summary', type: 'warning'},
|
||||
[],
|
||||
'id'
|
||||
);
|
||||
// Summary type present, but not text.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'summary': {'type': 'custom type'},
|
||||
'messages': [{'text': 'one', 'type': 'not-configured'}, {'text': 'two', 'type': 'warning'}],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
summary: {type: 'custom type'},
|
||||
messages: [{text: 'one', type: 'not-configured'}, {text: 'two', type: 'warning'}],
|
||||
xblock_id: 'id'
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'This component has validation issues.', 'type': 'custom type'},
|
||||
[{'text': 'one', 'type': 'not-configured'}, {'text': 'two', 'type': 'warning'}],
|
||||
{text: 'This component has validation issues.', type: 'custom type'},
|
||||
[{text: 'one', type: 'not-configured'}, {text: 'two', type: 'warning'}],
|
||||
'id'
|
||||
);
|
||||
// Summary text present, type will be computed as error.
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'summary': {'text': 'my summary'},
|
||||
'messages': [{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
'xblock_id': 'id'
|
||||
empty: false,
|
||||
summary: {text: 'my summary'},
|
||||
messages: [{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
xblock_id: 'id'
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'my summary', 'type': 'error'},
|
||||
[{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
{text: 'my summary', type: 'error'},
|
||||
[{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
'id'
|
||||
);
|
||||
});
|
||||
@@ -121,29 +121,29 @@ define(['js/models/xblock_validation'],
|
||||
it('clears messages if showSummaryOnly is true', function() {
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'xblock_id': 'id',
|
||||
'summary': {'text': 'my summary'},
|
||||
'messages': [{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
'showSummaryOnly': true
|
||||
empty: false,
|
||||
xblock_id: 'id',
|
||||
summary: {text: 'my summary'},
|
||||
messages: [{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
showSummaryOnly: true
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'my summary', 'type': 'error'},
|
||||
{text: 'my summary', type: 'error'},
|
||||
[],
|
||||
'id'
|
||||
);
|
||||
|
||||
verifyModel(
|
||||
new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'xblock_id': 'id',
|
||||
'summary': {'text': 'my summary'},
|
||||
'messages': [{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
'showSummaryOnly': false
|
||||
empty: false,
|
||||
xblock_id: 'id',
|
||||
summary: {text: 'my summary'},
|
||||
messages: [{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
showSummaryOnly: false
|
||||
}, {parse: true}),
|
||||
false,
|
||||
{'text': 'my summary', 'type': 'error'},
|
||||
[{'text': 'one', 'type': 'warning'}, {'text': 'two', 'type': 'error'}],
|
||||
{text: 'my summary', type: 'error'},
|
||||
[{text: 'one', type: 'warning'}, {text: 'two', type: 'error'}],
|
||||
'id'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['sinon', 'js/utils/drag_and_drop', 'common/js/components/views/feedback_notification',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'jquery', 'underscore'],
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'jquery', 'underscore'],
|
||||
function(sinon, ContentDragger, Notification, AjaxHelpers, $, _) {
|
||||
'use strict';
|
||||
describe('Overview drag and drop functionality', function() {
|
||||
@@ -312,7 +312,7 @@ define(['sinon', 'js/utils/drag_and_drop', 'common/js/components/views/feedback_
|
||||
});
|
||||
it('should send an update on reorder from one parent to another', function() {
|
||||
var requests, request, savingOptions;
|
||||
requests = AjaxHelpers['requests'](this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
ContentDragger.dragState.dropDestination = $('#unit-4');
|
||||
ContentDragger.dragState.attachMethod = 'after';
|
||||
ContentDragger.dragState.parentList = $('#subsection-2');
|
||||
@@ -343,7 +343,7 @@ define(['sinon', 'js/utils/drag_and_drop', 'common/js/components/views/feedback_
|
||||
expect($('#subsection-2').data('refresh')).toHaveBeenCalled();
|
||||
});
|
||||
it('should send an update on reorder within the same parent', function() {
|
||||
var requests = AjaxHelpers['requests'](this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
request;
|
||||
ContentDragger.dragState.dropDestination = $('#unit-2');
|
||||
ContentDragger.dragState.attachMethod = 'after';
|
||||
|
||||
@@ -191,8 +191,8 @@ function($, _, Squire) {
|
||||
|
||||
options = this.uploadSpies.constructor.calls.mostRecent().args[0];
|
||||
options.onSuccess({
|
||||
'asset': {
|
||||
'url': 'http://example.org/test_3'
|
||||
asset: {
|
||||
url: 'http://example.org/test_3'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
|
||||
object: testData,
|
||||
string: JSON.stringify(testData)
|
||||
},
|
||||
transcripts, container;
|
||||
transcripts, $container;
|
||||
|
||||
var waitsForDisplayName = function(collection) {
|
||||
return jasmine.waitUntil(function() {
|
||||
@@ -62,12 +62,12 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
|
||||
|
||||
beforeEach(function() {
|
||||
var tpl = sandbox({
|
||||
'class': 'wrapper-comp-settings basic_metadata_edit',
|
||||
'data-metadata': JSON.stringify(metadataDict['object'])
|
||||
class: 'wrapper-comp-settings basic_metadata_edit',
|
||||
'data-metadata': JSON.stringify(metadataDict.object)
|
||||
});
|
||||
|
||||
appendSetFixtures(tpl);
|
||||
container = $('.basic_metadata_edit');
|
||||
$container = $('.basic_metadata_edit');
|
||||
|
||||
spyOn(Utils, 'command');
|
||||
});
|
||||
@@ -81,7 +81,7 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
|
||||
spyOn(MetadataView, 'Editor');
|
||||
|
||||
transcripts = new Editor({
|
||||
el: container
|
||||
el: $container
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
|
||||
|
||||
it('MetadataView.Editor is initialized', function() {
|
||||
expect(MetadataView.Editor).toHaveBeenCalledWith({
|
||||
el: container,
|
||||
el: $container,
|
||||
collection: transcripts.collection
|
||||
});
|
||||
});
|
||||
@@ -161,7 +161,7 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
|
||||
spyOn(MetadataView, 'Editor');
|
||||
|
||||
transcripts = new Editor({
|
||||
el: container
|
||||
el: $container
|
||||
});
|
||||
|
||||
metadataCollection = new MetadataCollection(
|
||||
|
||||
@@ -227,7 +227,7 @@ function($, _, Utils, _str) {
|
||||
|
||||
describe('Method: parseLink', function() {
|
||||
var resultDataDict = {
|
||||
'html5': {
|
||||
html5: {
|
||||
link: html5LinksList.mp4[0],
|
||||
resp: {
|
||||
mode: 'html5',
|
||||
@@ -235,7 +235,7 @@ function($, _, Utils, _str) {
|
||||
type: 'mp4'
|
||||
}
|
||||
},
|
||||
'youtube': {
|
||||
youtube: {
|
||||
link: ytLinksList[0],
|
||||
resp: {
|
||||
mode: 'youtube',
|
||||
@@ -243,7 +243,7 @@ function($, _, Utils, _str) {
|
||||
type: 'youtube'
|
||||
}
|
||||
},
|
||||
'incorrect': {
|
||||
incorrect: {
|
||||
link: 'http://example.com',
|
||||
resp: {
|
||||
mode: 'incorrect'
|
||||
|
||||
@@ -68,7 +68,7 @@ function($, _, AjaxHelpers, Utils, VideoList, MetadataModel, AbstractEditor) {
|
||||
|
||||
beforeEach(function() {
|
||||
var tpl = sandbox({
|
||||
'class': 'component',
|
||||
class: 'component',
|
||||
'data-locator': component_locator
|
||||
});
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ function($, _, Squire) {
|
||||
),
|
||||
modelStub = {
|
||||
default_value: {
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt'
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt'
|
||||
},
|
||||
display_name: 'Transcript Translation',
|
||||
explicitly_set: false,
|
||||
@@ -30,10 +30,10 @@ function($, _, Squire) {
|
||||
{code: 'uk', label: 'Ukrainian'}
|
||||
],
|
||||
value: {
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt',
|
||||
'uk': 'uk.srt',
|
||||
'fr': 'fr.srt'
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt',
|
||||
uk: 'uk.srt',
|
||||
fr: 'fr.srt'
|
||||
}
|
||||
},
|
||||
self, injector;
|
||||
@@ -210,10 +210,10 @@ function($, _, Squire) {
|
||||
|
||||
it('returns the initial value upon initialization', function() {
|
||||
expect(this.view).assertValueInView({
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt',
|
||||
'uk': 'uk.srt',
|
||||
'fr': 'fr.srt'
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt',
|
||||
uk: 'uk.srt',
|
||||
fr: 'fr.srt'
|
||||
});
|
||||
|
||||
expect(this.view).verifyButtons(true, true, true);
|
||||
@@ -221,9 +221,9 @@ function($, _, Squire) {
|
||||
|
||||
it('updates its value correctly', function() {
|
||||
expect(this.view).assertCanUpdateView({
|
||||
'ru': 'ru.srt',
|
||||
'uk': 'uk.srt',
|
||||
'fr': 'fr.srt'
|
||||
ru: 'ru.srt',
|
||||
uk: 'uk.srt',
|
||||
fr: 'fr.srt'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -231,11 +231,11 @@ function($, _, Squire) {
|
||||
var options;
|
||||
|
||||
setValue(this.view, {
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt',
|
||||
'uk': 'uk.srt',
|
||||
'fr': 'fr.srt',
|
||||
'zh': ''
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt',
|
||||
uk: 'uk.srt',
|
||||
fr: 'fr.srt',
|
||||
zh: ''
|
||||
});
|
||||
|
||||
expect(this.view).verifyButtons(true, false, true);
|
||||
@@ -246,23 +246,23 @@ function($, _, Squire) {
|
||||
expect(this.uploadSpies.show).toHaveBeenCalled();
|
||||
|
||||
options = this.uploadSpies.constructor.calls.mostRecent().args[0];
|
||||
options.onSuccess({'filename': 'zh.srt'});
|
||||
options.onSuccess({filename: 'zh.srt'});
|
||||
|
||||
expect(this.view).verifyButtons(true, true, true);
|
||||
|
||||
expect(this.view.getValueFromEditor()).toEqual({
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt',
|
||||
'uk': 'uk.srt',
|
||||
'fr': 'fr.srt',
|
||||
'zh': 'zh.srt'
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt',
|
||||
uk: 'uk.srt',
|
||||
fr: 'fr.srt',
|
||||
zh: 'zh.srt'
|
||||
});
|
||||
});
|
||||
|
||||
it('has a clear method to revert to the model default', function() {
|
||||
setValue(this.view, {
|
||||
'fr': 'en.srt',
|
||||
'uk': 'ru.srt'
|
||||
fr: 'en.srt',
|
||||
uk: 'ru.srt'
|
||||
});
|
||||
|
||||
this.view.$el.find('.create-setting').click();
|
||||
@@ -270,15 +270,15 @@ function($, _, Squire) {
|
||||
this.view.clear();
|
||||
|
||||
expect(this.view).assertClear({
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt'
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt'
|
||||
});
|
||||
|
||||
expect(this.view.$el.find('.create-setting')).not.toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('has an update model method', function() {
|
||||
expect(this.view).assertUpdateModel(null, {'fr': 'fr.srt'});
|
||||
expect(this.view).assertUpdateModel(null, {fr: 'fr.srt'});
|
||||
});
|
||||
|
||||
it('can add an entry', function() {
|
||||
@@ -289,9 +289,9 @@ function($, _, Squire) {
|
||||
|
||||
it('can remove an entry', function() {
|
||||
setValue(this.view, {
|
||||
'en': 'en.srt',
|
||||
'ru': 'ru.srt',
|
||||
'fr': ''
|
||||
en: 'en.srt',
|
||||
ru: 'ru.srt',
|
||||
fr: ''
|
||||
});
|
||||
expect(_.keys(this.view.model.get('value')).length).toEqual(3);
|
||||
this.view.$el.find('.remove-setting').last().click();
|
||||
@@ -307,15 +307,15 @@ function($, _, Squire) {
|
||||
|
||||
it('only allows unique keys', function() {
|
||||
expect(this.view).verifyKeysUnique(
|
||||
{'ru': 'ru.srt'}, {'ru': 'ru.srt'}, {'key': 'ru', 'value': ''}
|
||||
{ru: 'ru.srt'}, {ru: 'ru.srt'}, {key: 'ru', value: ''}
|
||||
);
|
||||
|
||||
expect(this.view).verifyKeysUnique(
|
||||
{'ru': 'en.srt'}, {'ru': 'ru.srt'}, {'key': 'ru', 'value': 'ru.srt'}
|
||||
{ru: 'en.srt'}, {ru: 'ru.srt'}, {key: 'ru', value: 'ru.srt'}
|
||||
);
|
||||
|
||||
expect(this.view).verifyKeysUnique(
|
||||
{'ru': 'ru.srt'}, {'ru': 'ru.srt'}, {'key': '', 'value': ''}
|
||||
{ru: 'ru.srt'}, {ru: 'ru.srt'}, {key: '', value: ''}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'js/views/assets',
|
||||
'js/collections/asset', 'common/js/spec_helpers/view_helpers'],
|
||||
'js/collections/asset', 'common/js/spec_helpers/view_helpers'],
|
||||
function($, AjaxHelpers, URI, AssetsView, AssetCollection, ViewHelpers) {
|
||||
describe('Assets', function() {
|
||||
var assetsView, mockEmptyAssetsResponse, mockAssetUploadResponse, mockFileUpload,
|
||||
@@ -57,34 +57,34 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'j
|
||||
end: 2,
|
||||
assets: [
|
||||
{
|
||||
'display_name': 'test.jpg',
|
||||
'url': '/c4x/A/CS102/asset/test.jpg',
|
||||
'date_added': 'Nov 07, 2014 at 17:47 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.jpg',
|
||||
'portable_url': '/static/test.jpg',
|
||||
'thumbnail': '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
display_name: 'test.jpg',
|
||||
url: '/c4x/A/CS102/asset/test.jpg',
|
||||
date_added: 'Nov 07, 2014 at 17:47 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.jpg',
|
||||
portable_url: '/static/test.jpg',
|
||||
thumbnail: '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
},
|
||||
{
|
||||
'display_name': 'test.pdf',
|
||||
'url': '/c4x/A/CS102/asset/test.pdf',
|
||||
'date_added': 'Oct 20, 2014 at 11:00 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.pdf',
|
||||
'portable_url': '/static/test.pdf',
|
||||
'thumbnail': null,
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.pdf'
|
||||
display_name: 'test.pdf',
|
||||
url: '/c4x/A/CS102/asset/test.pdf',
|
||||
date_added: 'Oct 20, 2014 at 11:00 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.pdf',
|
||||
portable_url: '/static/test.pdf',
|
||||
thumbnail: null,
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.pdf'
|
||||
},
|
||||
{
|
||||
'display_name': 'test.odt',
|
||||
'url': '/c4x/A/CS102/asset/test.odt',
|
||||
'date_added': 'Oct 20, 2014 at 11:00 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.odt',
|
||||
'portable_url': '/static/test.odt',
|
||||
'thumbnail': null,
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.odt'
|
||||
display_name: 'test.odt',
|
||||
url: '/c4x/A/CS102/asset/test.odt',
|
||||
date_added: 'Oct 20, 2014 at 11:00 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.odt',
|
||||
portable_url: '/static/test.odt',
|
||||
thumbnail: null,
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.odt'
|
||||
}
|
||||
],
|
||||
pageSize: 2,
|
||||
@@ -98,14 +98,14 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'j
|
||||
end: 1,
|
||||
assets: [
|
||||
{
|
||||
'display_name': 'test.jpg',
|
||||
'url': '/c4x/A/CS102/asset/test.jpg',
|
||||
'date_added': 'Nov 07, 2014 at 17:47 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.jpg',
|
||||
'portable_url': '/static/test.jpg',
|
||||
'thumbnail': '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
display_name: 'test.jpg',
|
||||
url: '/c4x/A/CS102/asset/test.jpg',
|
||||
date_added: 'Nov 07, 2014 at 17:47 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.jpg',
|
||||
portable_url: '/static/test.jpg',
|
||||
thumbnail: '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
}
|
||||
],
|
||||
pageSize: 1,
|
||||
@@ -133,7 +133,7 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'j
|
||||
};
|
||||
|
||||
var event = {};
|
||||
event.target = {'value': 'dummy.jpg'};
|
||||
event.target = {value: 'dummy.jpg'};
|
||||
|
||||
describe('AssetsView', function() {
|
||||
var setup;
|
||||
@@ -366,43 +366,44 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'j
|
||||
end: 1,
|
||||
assets: [
|
||||
{
|
||||
'display_name': 'test.jpg',
|
||||
'url': '/c4x/A/CS102/asset/test.jpg',
|
||||
'date_added': 'Nov 07, 2014 at 17:47 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.jpg',
|
||||
'portable_url': '/static/test.jpg',
|
||||
'thumbnail': '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
display_name: 'test.jpg',
|
||||
url: '/c4x/A/CS102/asset/test.jpg',
|
||||
date_added: 'Nov 07, 2014 at 17:47 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.jpg',
|
||||
portable_url: '/static/test.jpg',
|
||||
thumbnail: '/c4x/A/CS102/thumbnail/test.jpg',
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.jpg'
|
||||
},
|
||||
{
|
||||
'display_name': 'test.pdf',
|
||||
'url': '/c4x/A/CS102/asset/test.pdf',
|
||||
'date_added': 'Oct 20, 2014 at 11:00 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.pdf',
|
||||
'portable_url': '/static/test.pdf',
|
||||
'thumbnail': null,
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.pdf'
|
||||
display_name: 'test.pdf',
|
||||
url: '/c4x/A/CS102/asset/test.pdf',
|
||||
date_added: 'Oct 20, 2014 at 11:00 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.pdf',
|
||||
portable_url: '/static/test.pdf',
|
||||
thumbnail: null,
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.pdf'
|
||||
}
|
||||
],
|
||||
pageSize: 2,
|
||||
totalCount: 3,
|
||||
start: 0,
|
||||
page: 0
|
||||
}, secondPageAssets = {
|
||||
},
|
||||
secondPageAssets = {
|
||||
sort: 'uploadDate',
|
||||
end: 2,
|
||||
assets: [
|
||||
{
|
||||
'display_name': 'test.odt',
|
||||
'url': '/c4x/A/CS102/asset/test.odt',
|
||||
'date_added': 'Oct 20, 2014 at 11:00 UTC',
|
||||
'id': '/c4x/A/CS102/asset/test.odt',
|
||||
'portable_url': '/static/test.odt',
|
||||
'thumbnail': null,
|
||||
'locked': false,
|
||||
'external_url': 'localhost:8000/c4x/A/CS102/asset/test.odt'
|
||||
display_name: 'test.odt',
|
||||
url: '/c4x/A/CS102/asset/test.odt',
|
||||
date_added: 'Oct 20, 2014 at 11:00 UTC',
|
||||
id: '/c4x/A/CS102/asset/test.odt',
|
||||
portable_url: '/static/test.odt',
|
||||
thumbnail: null,
|
||||
locked: false,
|
||||
external_url: 'localhost:8000/c4x/A/CS102/asset/test.odt'
|
||||
}
|
||||
],
|
||||
pageSize: 2,
|
||||
|
||||
@@ -54,7 +54,7 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/spec_
|
||||
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockContainerHTML,
|
||||
'resources': []
|
||||
resources: []
|
||||
});
|
||||
|
||||
$('body').append(containerView.$el);
|
||||
|
||||
@@ -80,8 +80,8 @@ define([
|
||||
};
|
||||
var setUsageInfo = function(model) {
|
||||
model.set('usage', [
|
||||
{'label': 'label1', 'url': 'url1'},
|
||||
{'label': 'label2', 'url': 'url2'}
|
||||
{label: 'label1', url: 'url1'},
|
||||
{label: 'label2', url: 'url2'}
|
||||
]);
|
||||
};
|
||||
var assertHideValidationContent = function(view) {
|
||||
@@ -193,7 +193,7 @@ define([
|
||||
compare: function(actual, values) {
|
||||
var passed = _.every(values, function(value, key) {
|
||||
return actual.get(key) === value;
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
return {
|
||||
pass: passed
|
||||
@@ -314,11 +314,11 @@ define([
|
||||
it('should show validation warning icon and message appropriately', function() {
|
||||
this.model.set('usage', [
|
||||
{
|
||||
'label': 'label1',
|
||||
'url': 'url1',
|
||||
'validation': {
|
||||
'text': 'Warning message',
|
||||
'type': 'warning'
|
||||
label: 'label1',
|
||||
url: 'url1',
|
||||
validation: {
|
||||
text: 'Warning message',
|
||||
type: 'warning'
|
||||
}
|
||||
}
|
||||
]);
|
||||
@@ -332,11 +332,11 @@ define([
|
||||
it('should show validation error icon and message appropriately', function() {
|
||||
this.model.set('usage', [
|
||||
{
|
||||
'label': 'label1',
|
||||
'url': 'url1',
|
||||
'validation': {
|
||||
'text': 'Error message',
|
||||
'type': 'error'
|
||||
label: 'label1',
|
||||
url: 'url1',
|
||||
validation: {
|
||||
text: 'Error message',
|
||||
type: 'error'
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -51,7 +51,7 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
|
||||
var ccBtn = this.view.$('li[data-license=creative-commons] button');
|
||||
ccBtn.click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
var arrBtn = this.view.$('li[data-license=all-rights-reserved] button');
|
||||
arrBtn.click();
|
||||
@@ -59,7 +59,7 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
|
||||
});
|
||||
|
||||
it('renders license options', function() {
|
||||
this.model.set({'type': 'creative-commons'});
|
||||
this.model.set({type: 'creative-commons'});
|
||||
expect(this.view.$('ul.license-options li[data-option=BY]'))
|
||||
.toContainText('Attribution');
|
||||
expect(this.view.$('ul.license-options li[data-option=NC]'))
|
||||
@@ -74,19 +74,19 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
|
||||
it('toggles boolean options on click', function() {
|
||||
this.view.$('li[data-license=creative-commons] button').click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
// toggle NC option
|
||||
this.view.$('li[data-option=NC]').click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': false, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: false, ND: true, SA: false}
|
||||
);
|
||||
});
|
||||
|
||||
it("doesn't toggle disabled options", function() {
|
||||
this.view.$('li[data-license=creative-commons] button').click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
var BY = this.view.$('li[data-option=BY]');
|
||||
expect(BY).toHaveClass('is-disabled');
|
||||
@@ -94,14 +94,14 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
|
||||
BY.click();
|
||||
// no change
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
});
|
||||
|
||||
it("doesn't allow simultaneous conflicting options", function() {
|
||||
this.view.$('li[data-license=creative-commons] button').click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
// SA and ND conflict
|
||||
var SA = this.view.$('li[data-option=SA]');
|
||||
@@ -109,14 +109,14 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
|
||||
SA.click();
|
||||
// ND should no longer be selected
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': false, 'SA': true}
|
||||
{ver: '4.0', BY: true, NC: true, ND: false, SA: true}
|
||||
);
|
||||
|
||||
// try to turn on ND option
|
||||
ND = this.view.$('li[data-option=ND]');
|
||||
ND.click();
|
||||
expect(this.model.get('options')).toEqual(
|
||||
{'ver': '4.0', 'BY': true, 'NC': true, 'ND': true, 'SA': false}
|
||||
{ver: '4.0', BY: true, NC: true, ND: true, SA: false}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
define(['jquery', 'js/factories/login', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/components/utils/view_utils'],
|
||||
'common/js/components/utils/view_utils'],
|
||||
function($, LoginFactory, AjaxHelpers, ViewUtils) {
|
||||
'use strict';
|
||||
describe('Studio Login Page', function() {
|
||||
var submitButton;
|
||||
var $submitButton;
|
||||
|
||||
beforeEach(function() {
|
||||
loadFixtures('mock/login.underscore');
|
||||
var login_factory = new LoginFactory('/home/');
|
||||
submitButton = $('#submit');
|
||||
$submitButton = $('#submit');
|
||||
});
|
||||
|
||||
it('disable the submit button once it is clicked', function() {
|
||||
spyOn(ViewUtils, 'redirect').and.callFake(function() {});
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
expect(submitButton).not.toHaveClass('is-disabled');
|
||||
submitButton.click();
|
||||
AjaxHelpers.respondWithJson(requests, {'success': true});
|
||||
expect(submitButton).toHaveClass('is-disabled');
|
||||
expect($submitButton).not.toHaveClass('is-disabled');
|
||||
$submitButton.click();
|
||||
AjaxHelpers.respondWithJson(requests, {success: true});
|
||||
expect($submitButton).toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('It will not disable the submit button if there are errors in ajax request', function() {
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
expect(submitButton).not.toHaveClass('is-disabled');
|
||||
submitButton.click();
|
||||
expect(submitButton).toHaveClass('is-disabled');
|
||||
expect($submitButton).not.toHaveClass('is-disabled');
|
||||
$submitButton.click();
|
||||
expect($submitButton).toHaveClass('is-disabled');
|
||||
AjaxHelpers.respondWithError(requests, {});
|
||||
expect(submitButton).not.toHaveClass('is-disabled');
|
||||
expect($submitButton).not.toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
var model, modal, showModal;
|
||||
|
||||
showModal = function(requests, mockHtml, options) {
|
||||
var xblockElement = $('.xblock');
|
||||
return EditHelpers.showEditModal(requests, xblockElement, model, mockHtml, options);
|
||||
var $xblockElement = $('.xblock');
|
||||
return EditHelpers.showEditModal(requests, $xblockElement, model, mockHtml, options);
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/view_helpers',
|
||||
'js/views/modals/move_xblock_modal', 'js/models/xblock_info'],
|
||||
'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/view_helpers',
|
||||
'js/views/modals/move_xblock_modal', 'js/models/xblock_info'],
|
||||
function($, _, AjaxHelpers, TemplateHelpers, ViewHelpers, MoveXBlockModal, XBlockInfo) {
|
||||
'use strict';
|
||||
describe('MoveXBlockModal', function() {
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
success: jasmine.any(Function)
|
||||
});
|
||||
this.moduleEdit.clickEditButton({
|
||||
'preventDefault': jasmine.createSpy('event.preventDefault')
|
||||
preventDefault: jasmine.createSpy('event.preventDefault')
|
||||
});
|
||||
mockXBlockEditorHtml = readFixtures('mock/mock-xblock-editor.underscore');
|
||||
$.ajax.calls.mostRecent().args[0].success({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/spec_helpers/edit_helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/view_helpers',
|
||||
'js/views/modals/move_xblock_modal', 'js/views/pages/container', 'edx-ui-toolkit/js/utils/html-utils',
|
||||
'edx-ui-toolkit/js/utils/string-utils', 'js/models/xblock_info'],
|
||||
'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/view_helpers',
|
||||
'js/views/modals/move_xblock_modal', 'js/views/pages/container', 'edx-ui-toolkit/js/utils/html-utils',
|
||||
'edx-ui-toolkit/js/utils/string-utils', 'js/models/xblock_info'],
|
||||
function($, _, AjaxHelpers, EditHelpers, TemplateHelpers, ViewHelpers, MoveXBlockModal, ContainerPage, HtmlUtils,
|
||||
StringUtils, XBlockInfo) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'URI', 'js/models/xblock_info',
|
||||
'js/views/paged_container', 'js/views/paging_header',
|
||||
'common/js/components/views/paging_footer', 'js/views/xblock'],
|
||||
'js/views/paged_container', 'js/views/paging_header',
|
||||
'common/js/components/views/paging_footer', 'js/views/xblock'],
|
||||
function($, _, AjaxHelpers, URI, XBlockInfo, PagedContainer, PagingHeader, PagingFooter, XBlockView) {
|
||||
var htmlResponseTpl = _.template('' +
|
||||
'<div class="xblock-container-paging-parameters" ' +
|
||||
@@ -54,7 +54,7 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
|
||||
var respondWithMockPage = function(requests, mockPage) {
|
||||
var request = AjaxHelpers.currentRequest(requests);
|
||||
if (typeof mockPage == 'undefined') {
|
||||
if (typeof mockPage === 'undefined') {
|
||||
var url = new URI(request.url);
|
||||
var queryParameters = url.query(true); // Returns an object with each query parameter stored as a value
|
||||
var page = queryParameters.page_number;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-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',
|
||||
'js/collections/component_template', 'jquery.simulate'],
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec_helpers/edit_helpers',
|
||||
'js/views/pages/container', 'js/views/pages/paged_container', 'js/models/xblock_info',
|
||||
'js/collections/component_template', 'jquery.simulate'],
|
||||
function($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, ContainerPage, PagedContainerPage,
|
||||
XBlockInfo, ComponentTemplates) {
|
||||
'use strict';
|
||||
@@ -57,7 +57,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
respondWithHtml = function(html) {
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests,
|
||||
{html: html, 'resources': []}
|
||||
{html: html, resources: []}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -179,7 +179,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
handleContainerPageRefresh(requests);
|
||||
|
||||
// Respond to the subsequent xblock info fetch request.
|
||||
AjaxHelpers.respondWithJson(requests, {'display_name': updatedDisplayName});
|
||||
AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName});
|
||||
|
||||
// Expect the title to have been updated
|
||||
expect(displayNameElement.text().trim()).toBe(updatedDisplayName);
|
||||
@@ -194,7 +194,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
// This is the response for the change operation.
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
AjaxHelpers.respondWithJson(requests, {'display_name': updatedDisplayName});
|
||||
AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName});
|
||||
EditHelpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
expect(containerPage.model.get('display_name')).toBe(updatedDisplayName);
|
||||
});
|
||||
@@ -249,8 +249,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
resources: []
|
||||
});
|
||||
expect(EditHelpers.isShowingModal()).toBeTruthy();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
expect(accessButtons.length).toBe(0);
|
||||
}
|
||||
});
|
||||
@@ -288,7 +287,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
});
|
||||
|
||||
it('can save changes to settings', function() {
|
||||
var editButtons, modal, mockUpdatedXBlockHtml;
|
||||
var editButtons, $modal, mockUpdatedXBlockHtml;
|
||||
mockUpdatedXBlockHtml = readFixtures('mock/mock-updated-xblock.underscore');
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
editButtons = containerPage.$('.wrapper-xblock .edit-button');
|
||||
@@ -300,14 +299,14 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
resources: []
|
||||
});
|
||||
|
||||
modal = $('.edit-xblock-modal');
|
||||
expect(modal.length).toBe(1);
|
||||
$modal = $('.edit-xblock-modal');
|
||||
expect($modal.length).toBe(1);
|
||||
// Click on the settings tab
|
||||
modal.find('.settings-button').click();
|
||||
$modal.find('.settings-button').click();
|
||||
// Change the display name's text
|
||||
modal.find('.setting-input').text('Mock Update');
|
||||
$modal.find('.setting-input').text('Mock Update');
|
||||
// Press the save button
|
||||
modal.find('.action-save').click();
|
||||
$modal.find('.action-save').click();
|
||||
// Respond to the save
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
id: model.id
|
||||
@@ -323,7 +322,8 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
|
||||
describe('xblock operations', function() {
|
||||
var getGroupElement,
|
||||
NUM_COMPONENTS_PER_GROUP = 3, GROUP_TO_TEST = 'A',
|
||||
NUM_COMPONENTS_PER_GROUP = 3,
|
||||
GROUP_TO_TEST = 'A',
|
||||
allComponentsInGroup = _.map(
|
||||
_.range(NUM_COMPONENTS_PER_GROUP),
|
||||
function(index) {
|
||||
@@ -473,13 +473,13 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
|
||||
// verify content of request
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'duplicate_source_locator': 'locator-component-' + GROUP_TO_TEST + (componentIndex + 1),
|
||||
'parent_locator': 'locator-group-' + GROUP_TO_TEST
|
||||
duplicate_source_locator: 'locator-component-' + GROUP_TO_TEST + (componentIndex + 1),
|
||||
parent_locator: 'locator-group-' + GROUP_TO_TEST
|
||||
});
|
||||
|
||||
// send the response
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'locator-duplicated-component'
|
||||
locator: 'locator-duplicated-component'
|
||||
});
|
||||
|
||||
// expect parent container to be refreshed
|
||||
@@ -505,8 +505,8 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
renderContainerPage(this, mockBadContainerXBlockHtml);
|
||||
containerPage.$('.duplicate-button').first().click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'duplicate_source_locator': 'locator-broken-javascript',
|
||||
'parent_locator': 'locator-container'
|
||||
duplicate_source_locator: 'locator-broken-javascript',
|
||||
parent_locator: 'locator-container'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -515,7 +515,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickDuplicate(0);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
AjaxHelpers.respondWithJson(requests, {'locator': 'new_item'});
|
||||
AjaxHelpers.respondWithJson(requests, {locator: 'new_item'});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
@@ -593,9 +593,9 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickNewComponent(0);
|
||||
EditHelpers.verifyXBlockRequest(requests, {
|
||||
'category': 'discussion',
|
||||
'type': 'discussion',
|
||||
'parent_locator': 'locator-group-A'
|
||||
category: 'discussion',
|
||||
type: 'discussion',
|
||||
parent_locator: 'locator-group-A'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -607,14 +607,14 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
// to add children or allow authors to add children.
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
$('.add-xblock-component-button').each(function() {
|
||||
var htmlAsLink = $($(this).prop('outerHTML').replace(/(<\/?)button/g, '$1a'));
|
||||
$(this).replaceWith(htmlAsLink);
|
||||
var $htmlAsLink = $($(this).prop('outerHTML').replace(/(<\/?)button/g, '$1a'));
|
||||
$(this).replaceWith($htmlAsLink);
|
||||
});
|
||||
$('.add-xblock-component-button').first().click();
|
||||
EditHelpers.verifyXBlockRequest(requests, {
|
||||
'category': 'discussion',
|
||||
'type': 'discussion',
|
||||
'parent_locator': 'locator-group-A'
|
||||
category: 'discussion',
|
||||
type: 'discussion',
|
||||
parent_locator: 'locator-group-A'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -650,23 +650,23 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
xblockCount = containerPage.$('.studio-xblock-wrapper').length;
|
||||
containerPage.$('.new-component-html button')[templateIndex].click();
|
||||
EditHelpers.verifyXBlockRequest(requests, expectedRequest);
|
||||
AjaxHelpers.respondWithJson(requests, {'locator': 'new_item'});
|
||||
AjaxHelpers.respondWithJson(requests, {locator: 'new_item'});
|
||||
respondWithHtml(mockXBlockHtml);
|
||||
expect(containerPage.$('.studio-xblock-wrapper').length).toBe(xblockCount + 1);
|
||||
};
|
||||
|
||||
it('can add an HTML component without a template', function() {
|
||||
verifyCreateHtmlComponent(this, 0, {
|
||||
'category': 'html',
|
||||
'parent_locator': 'locator-group-A'
|
||||
category: 'html',
|
||||
parent_locator: 'locator-group-A'
|
||||
});
|
||||
});
|
||||
|
||||
it('can add an HTML component with a template', function() {
|
||||
verifyCreateHtmlComponent(this, 1, {
|
||||
'category': 'html',
|
||||
'boilerplate': 'announcement.yaml',
|
||||
'parent_locator': 'locator-group-A'
|
||||
category: 'html',
|
||||
boilerplate: 'announcement.yaml',
|
||||
parent_locator: 'locator-group-A'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -680,30 +680,31 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
it('does show the support legend if show_legend is true', function() {
|
||||
var templates = new ComponentTemplates([
|
||||
{
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'html',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Text'
|
||||
category: 'html',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Text'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'announcement.yaml',
|
||||
'display_name': 'Announcement'
|
||||
category: 'html',
|
||||
boilerplate_name: 'announcement.yaml',
|
||||
display_name: 'Announcement'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'raw.yaml',
|
||||
'display_name': 'Raw HTML'
|
||||
category: 'html',
|
||||
boilerplate_name: 'raw.yaml',
|
||||
display_name: 'Raw HTML'
|
||||
}],
|
||||
'type': 'html',
|
||||
'support_legend': {
|
||||
'show_legend': true,
|
||||
'documentation_label': 'Documentation Label:',
|
||||
'allow_unsupported_xblocks': false
|
||||
type: 'html',
|
||||
support_legend: {
|
||||
show_legend: true,
|
||||
documentation_label: 'Documentation Label:',
|
||||
allow_unsupported_xblocks: false
|
||||
}
|
||||
}],
|
||||
{
|
||||
parse: true
|
||||
}), supportDocumentation;
|
||||
}),
|
||||
supportDocumentation;
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {}, templates);
|
||||
showTemplatePicker();
|
||||
supportDocumentation = containerPage.$('.support-documentation');
|
||||
@@ -721,30 +722,31 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
it('does show unsupported level if enabled', function() {
|
||||
var templates = new ComponentTemplates([
|
||||
{
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'html',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Text'
|
||||
category: 'html',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Text'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'announcement.yaml',
|
||||
'display_name': 'Announcement'
|
||||
category: 'html',
|
||||
boilerplate_name: 'announcement.yaml',
|
||||
display_name: 'Announcement'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'raw.yaml',
|
||||
'display_name': 'Raw HTML'
|
||||
category: 'html',
|
||||
boilerplate_name: 'raw.yaml',
|
||||
display_name: 'Raw HTML'
|
||||
}],
|
||||
'type': 'html',
|
||||
'support_legend': {
|
||||
'show_legend': true,
|
||||
'documentation_label': 'Documentation Label:',
|
||||
'allow_unsupported_xblocks': true
|
||||
type: 'html',
|
||||
support_legend: {
|
||||
show_legend: true,
|
||||
documentation_label: 'Documentation Label:',
|
||||
allow_unsupported_xblocks: true
|
||||
}
|
||||
}],
|
||||
{
|
||||
parse: true
|
||||
}), supportDocumentation;
|
||||
}),
|
||||
supportDocumentation;
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {}, templates);
|
||||
showTemplatePicker();
|
||||
supportDocumentation = containerPage.$('.support-documentation');
|
||||
@@ -759,33 +761,34 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
it('does render support level indicators if present in JSON', function() {
|
||||
var templates = new ComponentTemplates([
|
||||
{
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'html',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Text',
|
||||
'support_level': 'fs'
|
||||
category: 'html',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Text',
|
||||
support_level: 'fs'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'announcement.yaml',
|
||||
'display_name': 'Announcement',
|
||||
'support_level': 'ps'
|
||||
category: 'html',
|
||||
boilerplate_name: 'announcement.yaml',
|
||||
display_name: 'Announcement',
|
||||
support_level: 'ps'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'raw.yaml',
|
||||
'display_name': 'Raw HTML',
|
||||
'support_level': 'us'
|
||||
category: 'html',
|
||||
boilerplate_name: 'raw.yaml',
|
||||
display_name: 'Raw HTML',
|
||||
support_level: 'us'
|
||||
}],
|
||||
'type': 'html',
|
||||
'support_legend': {
|
||||
'show_legend': true,
|
||||
'documentation_label': 'Documentation Label:',
|
||||
'allow_unsupported_xblocks': true
|
||||
type: 'html',
|
||||
support_legend: {
|
||||
show_legend: true,
|
||||
documentation_label: 'Documentation Label:',
|
||||
allow_unsupported_xblocks: true
|
||||
}
|
||||
}],
|
||||
{
|
||||
parse: true
|
||||
}), supportLevelIndicators, getScreenReaderText;
|
||||
}),
|
||||
supportLevelIndicators, getScreenReaderText;
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {}, templates);
|
||||
showTemplatePicker();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec_helpers/edit_helpers',
|
||||
'common/js/components/views/feedback_prompt', 'js/views/pages/container',
|
||||
'js/views/pages/container_subviews', 'js/models/xblock_info', 'js/views/utils/xblock_utils',
|
||||
'js/models/course'],
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec_helpers/edit_helpers',
|
||||
'common/js/components/views/feedback_prompt', 'js/views/pages/container',
|
||||
'js/views/pages/container_subviews', 'js/models/xblock_info', 'js/views/utils/xblock_utils',
|
||||
'js/models/course'],
|
||||
function($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, Prompt, ContainerPage, ContainerSubviews,
|
||||
XBlockInfo, XBlockUtils, Course) {
|
||||
var VisibilityState = XBlockUtils.VisibilityState;
|
||||
@@ -10,7 +10,8 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
describe('Container Subviews', function() {
|
||||
var model, containerPage, requests, createContainerPage, renderContainerPage,
|
||||
respondWithHtml, fetch,
|
||||
disabledCss = 'is-disabled', defaultXBlockInfo, createXBlockInfo,
|
||||
disabledCss = 'is-disabled',
|
||||
defaultXBlockInfo, createXBlockInfo,
|
||||
mockContainerPage = readFixtures('mock/mock-container-page.underscore'),
|
||||
mockContainerXBlockHtml = readFixtures('mock/mock-empty-container-xblock.underscore');
|
||||
|
||||
@@ -75,7 +76,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
respondWithHtml = function(html, options) {
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests,
|
||||
{html: html, 'resources': []}
|
||||
{html: html, resources: []}
|
||||
);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
AjaxHelpers.respondWithJson(requests, createXBlockInfo(options));
|
||||
@@ -143,7 +144,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
promptSpies.constructor.calls.mostRecent().args[0].actions.primary.click(promptSpies);
|
||||
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/locator-container',
|
||||
{'publish': 'discard_changes'}
|
||||
{publish: 'discard_changes'}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -230,11 +231,11 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Publishing/);
|
||||
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/locator-container',
|
||||
{'publish': 'make_public'}
|
||||
{publish: 'make_public'}
|
||||
);
|
||||
|
||||
// Response to publish call
|
||||
AjaxHelpers.respondWithJson(requests, {'id': 'locator-container', 'data': null, 'metadata': {}});
|
||||
AjaxHelpers.respondWithJson(requests, {id: 'locator-container', data: null, metadata: {}});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
@@ -279,7 +280,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
numRequests = requests.length;
|
||||
|
||||
// Respond with success.
|
||||
AjaxHelpers.respondWithJson(requests, {'id': 'locator-container'});
|
||||
AjaxHelpers.respondWithJson(requests, {id: 'locator-container'});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
// Verify other requests are sent to the server to update page state.
|
||||
@@ -359,7 +360,7 @@ define(['jquery', 'underscore', 'underscore.string', 'edx-ui-toolkit/js/utils/sp
|
||||
it('renders correctly when the release date is not set', function() {
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
fetch({
|
||||
visibility_state: VisibilityState.unscheduled, 'released_to_students': false,
|
||||
visibility_state: VisibilityState.unscheduled, released_to_students: false,
|
||||
release_date: null, release_date_from: null
|
||||
});
|
||||
expect(containerPage.$(releaseDateTitleCss).text()).toContain('Release:');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/components/utils/view_utils',
|
||||
'js/views/pages/course_outline', 'js/models/xblock_outline_info', 'js/utils/date_utils',
|
||||
'js/spec_helpers/edit_helpers', 'common/js/spec_helpers/template_helpers', 'js/models/course'],
|
||||
'js/views/pages/course_outline', 'js/models/xblock_outline_info', 'js/utils/date_utils',
|
||||
'js/spec_helpers/edit_helpers', 'common/js/spec_helpers/template_helpers', 'js/models/course'],
|
||||
function($, AjaxHelpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils,
|
||||
EditHelpers, TemplateHelpers, Course) {
|
||||
describe('CourseOutlinePage', function() {
|
||||
@@ -113,14 +113,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createMockIndexJSON = function(option) {
|
||||
if (option) {
|
||||
return JSON.stringify({
|
||||
'developer_message': 'Course has been successfully reindexed.',
|
||||
'user_message': 'Course has been successfully reindexed.'
|
||||
developer_message: 'Course has been successfully reindexed.',
|
||||
user_message: 'Course has been successfully reindexed.'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return JSON.stringify({
|
||||
'developer_message': 'Could not reindex course.',
|
||||
'user_message': 'Could not reindex course.'
|
||||
developer_message: 'Could not reindex course.',
|
||||
user_message: 'Could not reindex course.'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -281,7 +280,7 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
]);
|
||||
mockCourseEntranceExamJSON = createMockCourseJSON({}, [
|
||||
createMockSectionJSON({}, [
|
||||
createMockSubsectionJSON({'is_header_visible': false}, [
|
||||
createMockSubsectionJSON({is_header_visible: false}, [
|
||||
createMockVerticalJSON()
|
||||
])
|
||||
])
|
||||
@@ -352,13 +351,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
outlinePage.$('.nav-actions .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
category: 'chapter',
|
||||
display_name: 'Section',
|
||||
parent_locator: 'mock-course'
|
||||
});
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'mock-section',
|
||||
'courseKey': 'slashes:MockCourse'
|
||||
locator: 'mock-section',
|
||||
courseKey: 'slashes:MockCourse'
|
||||
});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
AjaxHelpers.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
@@ -371,13 +370,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createCourseOutlinePage(this, mockSingleSectionCourseJSON);
|
||||
outlinePage.$('.nav-actions .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
category: 'chapter',
|
||||
display_name: 'Section',
|
||||
parent_locator: 'mock-course'
|
||||
});
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'mock-section-2',
|
||||
'courseKey': 'slashes:MockCourse'
|
||||
locator: 'mock-section-2',
|
||||
courseKey: 'slashes:MockCourse'
|
||||
});
|
||||
// Expect the UI to just fetch the new section and repaint it
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section-2');
|
||||
@@ -502,13 +501,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
$('.no-content .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
category: 'chapter',
|
||||
display_name: 'Section',
|
||||
parent_locator: 'mock-course'
|
||||
});
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'mock-section',
|
||||
'courseKey': 'slashes:MockCourse'
|
||||
locator: 'mock-section',
|
||||
courseKey: 'slashes:MockCourse'
|
||||
});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
AjaxHelpers.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
@@ -521,9 +520,9 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
$('.no-content .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
category: 'chapter',
|
||||
display_name: 'Section',
|
||||
parent_locator: 'mock-course'
|
||||
});
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
AjaxHelpers.expectNoRequests(requests);
|
||||
@@ -580,7 +579,7 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
expect('.status-highlights-enabled-value.button').toExist();
|
||||
expect('.status-highlights-enabled-value.text').not.toExist();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expectServerHandshake = function() {
|
||||
// POST to update course
|
||||
@@ -857,13 +856,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
getItemsOfType('section').find('> .outline-content > .add-subsection .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'sequential',
|
||||
'display_name': 'Subsection',
|
||||
'parent_locator': 'mock-section'
|
||||
category: 'sequential',
|
||||
display_name: 'Subsection',
|
||||
parent_locator: 'mock-section'
|
||||
});
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'new-mock-subsection',
|
||||
'courseKey': 'slashes:MockCourse'
|
||||
locator: 'new-mock-subsection',
|
||||
courseKey: 'slashes:MockCourse'
|
||||
});
|
||||
// Note: verification of the server response and the UI's handling of it
|
||||
// is handled in the acceptance tests.
|
||||
@@ -881,7 +880,7 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
// This is the response for the change operation.
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
AjaxHelpers.respondWithJson(requests, {'display_name': updatedDisplayName});
|
||||
AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName});
|
||||
EditHelpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
sectionModel = outlinePage.model.get('child_info').children[0];
|
||||
expect(sectionModel.get('display_name')).toBe(updatedDisplayName);
|
||||
@@ -911,8 +910,8 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
selectBasicSettings();
|
||||
$('.wrapper-modal-window .action-save').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-section', {
|
||||
'metadata': {
|
||||
'start': '2015-01-02T00:00:00.000Z'
|
||||
metadata: {
|
||||
start: '2015-01-02T00:00:00.000Z'
|
||||
}
|
||||
});
|
||||
expect(requests[0].requestHeaders['X-HTTP-Method-Override']).toBe('PATCH');
|
||||
@@ -963,16 +962,17 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
createMockVerticalJSON({has_changes: true})
|
||||
])
|
||||
])
|
||||
]), modalWindow;
|
||||
]),
|
||||
modalWindow;
|
||||
|
||||
createCourseOutlinePage(this, mockCourseJSON, false);
|
||||
getItemHeaders('section').first().find('.publish-button').click();
|
||||
modalWindow = $('.wrapper-modal-window');
|
||||
expect(modalWindow.find('.outline-unit').length).toBe(3);
|
||||
expect(_.compact(_.map(modalWindow.find('.outline-unit').text().split('\n'), $.trim))).toEqual(
|
||||
$modalWindow = $('.wrapper-modal-window');
|
||||
expect($modalWindow.find('.outline-unit').length).toBe(3);
|
||||
expect(_.compact(_.map($modalWindow.find('.outline-unit').text().split('\n'), $.trim))).toEqual(
|
||||
['Unit 100', 'Unit 50', 'Unit 1']
|
||||
);
|
||||
expect(modalWindow.find('.outline-subsection').length).toBe(2);
|
||||
expect($modalWindow.find('.outline-subsection').length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1081,11 +1081,11 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
staff_only_message: true,
|
||||
is_prereq: false,
|
||||
show_correctness: 'never',
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': false,
|
||||
'default_time_limit_minutes': 150,
|
||||
'hide_after_due': true
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: false,
|
||||
default_time_limit_minutes: 150,
|
||||
hide_after_due: true
|
||||
}, [
|
||||
createMockVerticalJSON({
|
||||
has_changes: true,
|
||||
@@ -1112,13 +1112,13 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
redirectSpy = spyOn(ViewUtils, 'redirect');
|
||||
getItemsOfType('subsection').find('> .outline-content > .add-unit .button-new').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'vertical',
|
||||
'display_name': 'Unit',
|
||||
'parent_locator': 'mock-subsection'
|
||||
category: 'vertical',
|
||||
display_name: 'Unit',
|
||||
parent_locator: 'mock-subsection'
|
||||
});
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'new-mock-unit',
|
||||
'courseKey': 'slashes:MockCourse'
|
||||
locator: 'new-mock-unit',
|
||||
courseKey: 'slashes:MockCourse'
|
||||
});
|
||||
expect(redirectSpy).toHaveBeenCalledWith('/container/new-mock-unit?action=new');
|
||||
});
|
||||
@@ -1254,19 +1254,19 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
selectTimedExam('02:30');
|
||||
$('.wrapper-modal-window .action-save').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-subsection', {
|
||||
'graderType': 'Lab',
|
||||
'publish': 'republish',
|
||||
'isPrereq': false,
|
||||
'metadata': {
|
||||
'visible_to_staff_only': null,
|
||||
'start': '2014-07-09T00:00:00.000Z',
|
||||
'due': '2014-07-10T00:00:00.000Z',
|
||||
'exam_review_rules': '',
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_enabled': false,
|
||||
'default_time_limit_minutes': 150,
|
||||
'hide_after_due': true
|
||||
graderType: 'Lab',
|
||||
publish: 'republish',
|
||||
isPrereq: false,
|
||||
metadata: {
|
||||
visible_to_staff_only: null,
|
||||
start: '2014-07-09T00:00:00.000Z',
|
||||
due: '2014-07-10T00:00:00.000Z',
|
||||
exam_review_rules: '',
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_enabled: false,
|
||||
default_time_limit_minutes: 150,
|
||||
hide_after_due: true
|
||||
}
|
||||
});
|
||||
expect(requests[0].requestHeaders['X-HTTP-Method-Override']).toBe('PATCH');
|
||||
@@ -1383,11 +1383,11 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': false,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': false,
|
||||
'default_time_limit_minutes': 150,
|
||||
'hide_after_due': false
|
||||
is_time_limited: false,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: false,
|
||||
default_time_limit_minutes: 150,
|
||||
hide_after_due: false
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1412,11 +1412,11 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': false,
|
||||
'default_time_limit_minutes': 10,
|
||||
'hide_after_due': true
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: false,
|
||||
default_time_limit_minutes: 10,
|
||||
hide_after_due: true
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1441,11 +1441,11 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': false,
|
||||
'default_time_limit_minutes': 10,
|
||||
'hide_after_due': false
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: false,
|
||||
default_time_limit_minutes: 10,
|
||||
hide_after_due: false
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1471,10 +1471,10 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': true,
|
||||
'is_proctored_exam': true,
|
||||
'default_time_limit_minutes': 150
|
||||
is_time_limited: true,
|
||||
is_practice_exam: true,
|
||||
is_proctored_exam: true,
|
||||
default_time_limit_minutes: 150
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1499,10 +1499,10 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': true,
|
||||
'default_time_limit_minutes': 150
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: true,
|
||||
default_time_limit_minutes: 150
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1527,11 +1527,11 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
has_changes: true,
|
||||
'is_time_limited': true,
|
||||
'is_practice_exam': false,
|
||||
'is_proctored_exam': false,
|
||||
'default_time_limit_minutes': 150,
|
||||
'hide_after_due': true
|
||||
is_time_limited: true,
|
||||
is_practice_exam: false,
|
||||
is_proctored_exam: false,
|
||||
default_time_limit_minutes: 150,
|
||||
hide_after_due: true
|
||||
}, [
|
||||
])
|
||||
])
|
||||
@@ -1845,16 +1845,17 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
]),
|
||||
createMockSubsectionJSON({}, [createMockVerticalJSON])
|
||||
])
|
||||
]), modalWindow;
|
||||
]),
|
||||
$modalWindow;
|
||||
|
||||
createCourseOutlinePage(this, mockCourseJSON, false);
|
||||
getItemHeaders('subsection').first().find('.publish-button').click();
|
||||
modalWindow = $('.wrapper-modal-window');
|
||||
expect(modalWindow.find('.outline-unit').length).toBe(2);
|
||||
expect(_.compact(_.map(modalWindow.find('.outline-unit').text().split('\n'), $.trim))).toEqual(
|
||||
$modalWindow = $('.wrapper-modal-window');
|
||||
expect($modalWindow.find('.outline-unit').length).toBe(2);
|
||||
expect(_.compact(_.map($modalWindow.find('.outline-unit').text().split('\n'), $.trim))).toEqual(
|
||||
['Unit 100', 'Unit 50']
|
||||
);
|
||||
expect(modalWindow.find('.outline-subsection')).not.toExist();
|
||||
expect($modalWindow.find('.outline-subsection')).not.toExist();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/spec_helpers/view_helpers',
|
||||
'js/views/course_rerun', 'js/views/utils/create_course_utils', 'common/js/components/utils/view_utils',
|
||||
'jquery.simulate'],
|
||||
'js/views/course_rerun', 'js/views/utils/create_course_utils', 'common/js/components/utils/view_utils',
|
||||
'jquery.simulate'],
|
||||
function($, AjaxHelpers, ViewHelpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) {
|
||||
describe('Create course rerun page', function() {
|
||||
var selectors = {
|
||||
@@ -108,34 +108,34 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
});
|
||||
|
||||
it('shows an error message when non URL characters are entered', function() {
|
||||
var input = $(selectors.org);
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
type(input, '%');
|
||||
expect(input.parent()).toHaveClass(classes.error);
|
||||
var $input = $(selectors.org);
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
type($input, '%');
|
||||
expect($input.parent()).toHaveClass(classes.error);
|
||||
});
|
||||
|
||||
it('does not show an error message when tabbing into a field', function() {
|
||||
var input = $(selectors.number);
|
||||
input.val('');
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
input.simulate('keyup', {keyCode: $.simulate.keyCode.TAB});
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
var $input = $(selectors.number);
|
||||
$input.val('');
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
$input.simulate('keyup', {keyCode: $.simulate.keyCode.TAB});
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
});
|
||||
|
||||
it('shows an error message when a required field is empty', function() {
|
||||
var input = $(selectors.org);
|
||||
input.val('');
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
input.simulate('keyup', {keyCode: $.simulate.keyCode.ENTER});
|
||||
expect(input.parent()).toHaveClass(classes.error);
|
||||
var $input = $(selectors.org);
|
||||
$input.val('');
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
$input.simulate('keyup', {keyCode: $.simulate.keyCode.ENTER});
|
||||
expect($input.parent()).toHaveClass(classes.error);
|
||||
});
|
||||
|
||||
it('shows an error message when spaces are entered and unicode is allowed', function() {
|
||||
var input = $(selectors.org);
|
||||
var $input = $(selectors.org);
|
||||
$(selectors.allowUnicode).val('True');
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
type(input, ' ');
|
||||
expect(input.parent()).toHaveClass(classes.error);
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
type($input, ' ');
|
||||
expect($input.parent()).toHaveClass(classes.error);
|
||||
});
|
||||
|
||||
it('shows an error message when total length exceeds 65 characters', function() {
|
||||
@@ -148,10 +148,10 @@ define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/j
|
||||
|
||||
describe('Name field', function() {
|
||||
it('does not show an error message when non URL characters are entered', function() {
|
||||
var input = $(selectors.name);
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
type(input, '%');
|
||||
expect(input.parent()).not.toHaveClass(classes.error);
|
||||
var $input = $(selectors.name);
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
type($input, '%');
|
||||
expect($input.parent()).not.toHaveClass(classes.error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['jquery',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/view_helpers', 'js/index',
|
||||
'common/js/components/utils/view_utils'],
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/view_helpers', 'js/index',
|
||||
'common/js/components/utils/view_utils'],
|
||||
function($, AjaxHelpers, ViewHelpers, IndexUtils, ViewUtils) {
|
||||
describe('Course listing page', function() {
|
||||
var mockIndexPageHTML = readFixtures('mock/mock-index-page.underscore');
|
||||
|
||||
@@ -9,10 +9,10 @@ function($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
var team_member_fixture = readFixtures('team-member.underscore');
|
||||
|
||||
function setRole(email, role) {
|
||||
var user_li = $('li.user-item[data-email="' + email + '"]');
|
||||
var role_action = $('li.action-role a.make-' + role, user_li);
|
||||
expect(role_action).toBeVisible();
|
||||
role_action.click();
|
||||
var $user_li = $('li.user-item[data-email="' + email + '"]');
|
||||
var $role_action = $('li.action-role a.make-' + role, $user_li);
|
||||
expect($role_action).toBeVisible();
|
||||
$role_action.click();
|
||||
}
|
||||
|
||||
function getUrl(email) {
|
||||
@@ -56,7 +56,7 @@ function($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
$('.user-email-input').val(email);
|
||||
$('.form-create.create-user .action-primary').click();
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', getUrl(email), {role: 'library_user'});
|
||||
AjaxHelpers.respondWithJson(requests, {'result': 'ok'});
|
||||
AjaxHelpers.respondWithJson(requests, {result: 'ok'});
|
||||
expect(reloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ function($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
var reloadSpy = spyOn(ViewUtils, 'reload');
|
||||
setRole('staff@example.com', 'staff');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', getUrl(email), {role: 'staff'});
|
||||
AjaxHelpers.respondWithJson(requests, {'result': 'ok'});
|
||||
AjaxHelpers.respondWithJson(requests, {result: 'ok'});
|
||||
expect(reloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ function($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
ViewHelpers.confirmPrompt(promptSpy);
|
||||
ViewHelpers.verifyPromptHidden(promptSpy);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', getUrl(email), {role: null});
|
||||
AjaxHelpers.respondWithJson(requests, {'result': 'ok'});
|
||||
AjaxHelpers.respondWithJson(requests, {result: 'ok'});
|
||||
expect(reloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(
|
||||
['jquery', 'underscore', 'backbone', 'js/views/previous_video_upload_list',
|
||||
'common/js/spec_helpers/template_helpers', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'],
|
||||
'common/js/spec_helpers/template_helpers', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'],
|
||||
function($, _, Backbone, PreviousVideoUploadListView, TemplateHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe('PreviousVideoUploadListView', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(
|
||||
['jquery', 'underscore', 'backbone', 'js/views/previous_video_upload', 'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers'],
|
||||
'common/js/spec_helpers/view_helpers'],
|
||||
function($, _, Backbone, PreviousVideoUploadView, TemplateHelpers, ViewHelpers) {
|
||||
'use strict';
|
||||
describe('PreviousVideoUploadView', function() {
|
||||
|
||||
@@ -47,7 +47,7 @@ define([
|
||||
language: '',
|
||||
learning_info: [''],
|
||||
instructor_info: {
|
||||
'instructors': [{'name': '', 'title': '', 'organization': '', 'image': '', 'bio': ''}]
|
||||
instructors: [{name: '', title: '', organization: '', image: '', bio: ''}]
|
||||
},
|
||||
self_paced: false
|
||||
},
|
||||
@@ -69,7 +69,7 @@ define([
|
||||
|
||||
this.model = new CourseDetailsModel($.extend(true, {}, modelData, {
|
||||
instructor_info: {
|
||||
'instructors': [{'name': '', 'title': '', 'organization': '', 'image': '', 'bio': ''}]
|
||||
instructors: [{name: '', title: '', organization: '', image: '', bio: ''}]
|
||||
}}), {parse: true});
|
||||
this.model.urlRoot = urlRoot;
|
||||
this.view = new MainView({
|
||||
@@ -326,13 +326,13 @@ define([
|
||||
expectedJson = $.extend(true, {}, modelData, {
|
||||
instructor_info: {
|
||||
instructors:
|
||||
[{
|
||||
'name': 'test_name',
|
||||
'title': 'test_title',
|
||||
'organization': 'test_org',
|
||||
'image': 'test_image',
|
||||
'bio': 'test_bio'
|
||||
}]
|
||||
[{
|
||||
name: 'test_name',
|
||||
title: 'test_title',
|
||||
organization: 'test_org',
|
||||
image: 'test_image',
|
||||
bio: 'test_bio'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers', 'common/js/components/utils/view_utils', 'js/models/course',
|
||||
'js/views/unit_outline', 'js/models/xblock_info'],
|
||||
'common/js/spec_helpers/view_helpers', 'common/js/components/utils/view_utils', 'js/models/course',
|
||||
'js/views/unit_outline', 'js/models/xblock_info'],
|
||||
function($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils,
|
||||
Course, UnitOutlineView, XBlockInfo) {
|
||||
'use strict';
|
||||
|
||||
@@ -76,7 +76,8 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
});
|
||||
|
||||
it('saves any custom metadata', function() {
|
||||
var requests = AjaxHelpers.requests(this), request, response;
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
request, response;
|
||||
editor.render();
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXModuleEditorHtml,
|
||||
@@ -92,7 +93,8 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
});
|
||||
|
||||
it('can render a module with only settings', function() {
|
||||
var requests = AjaxHelpers.requests(this), mockXModuleEditorHtml;
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
mockXModuleEditorHtml;
|
||||
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-settings-only-editor.underscore');
|
||||
|
||||
editor.render();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/components/utils/view_utils',
|
||||
'js/views/xblock', 'js/models/xblock_info', 'xmodule', 'cms/js/main', 'xblock/cms.runtime.v1'],
|
||||
'js/views/xblock', 'js/models/xblock_info', 'xmodule', 'cms/js/main', 'xblock/cms.runtime.v1'],
|
||||
function($, URI, AjaxHelpers, ViewUtils, XBlockView, XBlockInfo) {
|
||||
'use strict';
|
||||
describe('XBlockView', function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'edx-ui-toolkit/js/utils/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) {
|
||||
describe('XBlockStringFieldEditorView', function() {
|
||||
var initialDisplayName, updatedDisplayName, getXBlockInfo, getFieldEditorView;
|
||||
|
||||
@@ -32,14 +32,15 @@ define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', '
|
||||
});
|
||||
|
||||
it('can add additional classes', function() {
|
||||
var noContainerContent = 'no-container-content', notConfiguredModel, nonRootView, rootView;
|
||||
var noContainerContent = 'no-container-content',
|
||||
notConfiguredModel, nonRootView, rootView;
|
||||
|
||||
expect(view.getAdditionalClasses()).toBe('');
|
||||
expect(view.$('.validation')).not.toHaveClass(noContainerContent);
|
||||
|
||||
notConfiguredModel = new XBlockValidationModel({
|
||||
'empty': false, 'summary': {'text': 'Not configured', 'type': model.NOT_CONFIGURED},
|
||||
'xblock_id': 'id'
|
||||
empty: false, summary: {text: 'Not configured', type: model.NOT_CONFIGURED},
|
||||
xblock_id: 'id'
|
||||
},
|
||||
{parse: true}
|
||||
);
|
||||
@@ -60,19 +61,19 @@ define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', '
|
||||
|
||||
beforeEach(function() {
|
||||
model = new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'summary': {
|
||||
'text': 'Summary message', 'type': 'error',
|
||||
'action_label': 'Summary Action', 'action_class': 'edit-button'
|
||||
empty: false,
|
||||
summary: {
|
||||
text: 'Summary message', type: 'error',
|
||||
action_label: 'Summary Action', action_class: 'edit-button'
|
||||
},
|
||||
'messages': [
|
||||
messages: [
|
||||
{
|
||||
'text': 'First message', 'type': 'warning',
|
||||
'action_label': 'First Message Action', 'action_runtime_event': 'fix-up'
|
||||
text: 'First message', type: 'warning',
|
||||
action_label: 'First Message Action', action_runtime_event: 'fix-up'
|
||||
},
|
||||
{'text': 'Second message', 'type': 'error'}
|
||||
{text: 'Second message', type: 'error'}
|
||||
],
|
||||
'xblock_id': 'id'
|
||||
xblock_id: 'id'
|
||||
});
|
||||
view = new XBlockValidationView({model: model});
|
||||
view.render();
|
||||
@@ -111,10 +112,11 @@ define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', '
|
||||
|
||||
it('renders a summary only', function() {
|
||||
var summaryOnlyModel = new XBlockValidationModel({
|
||||
'empty': false,
|
||||
'summary': {'text': 'Summary message', 'type': 'warning'},
|
||||
'xblock_id': 'id'
|
||||
}), summaryOnlyView, details;
|
||||
empty: false,
|
||||
summary: {text: 'Summary message', type: 'warning'},
|
||||
xblock_id: 'id'
|
||||
}),
|
||||
summaryOnlyView, details;
|
||||
|
||||
summaryOnlyView = new XBlockValidationView({model: summaryOnlyModel});
|
||||
summaryOnlyView.render();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Provides helper methods for invoking Studio modal windows in Jasmine tests.
|
||||
*/
|
||||
define(['jquery', 'common/js/components/views/feedback_notification', 'common/js/components/views/feedback_prompt',
|
||||
'common/js/spec_helpers/template_helpers'],
|
||||
'common/js/spec_helpers/template_helpers'],
|
||||
function($, NotificationView, Prompt, TemplateHelpers) {
|
||||
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
|
||||
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
|
||||
@@ -72,17 +72,17 @@ define(['jquery', 'common/js/components/views/feedback_notification', 'common/js
|
||||
};
|
||||
|
||||
return {
|
||||
'installViewTemplates': installViewTemplates,
|
||||
'createNotificationSpy': createNotificationSpy,
|
||||
'verifyNotificationShowing': verifyNotificationShowing,
|
||||
'verifyNotificationHidden': verifyNotificationHidden,
|
||||
'confirmPrompt': confirmPrompt,
|
||||
'createPromptSpy': createPromptSpy,
|
||||
'verifyPromptShowing': verifyPromptShowing,
|
||||
'verifyPromptHidden': verifyPromptHidden,
|
||||
'inlineEdit': inlineEdit,
|
||||
'verifyInlineEditChange': verifyInlineEditChange,
|
||||
'installMockAnalytics': installMockAnalytics,
|
||||
'removeMockAnalytics': removeMockAnalytics
|
||||
installViewTemplates: installViewTemplates,
|
||||
createNotificationSpy: createNotificationSpy,
|
||||
verifyNotificationShowing: verifyNotificationShowing,
|
||||
verifyNotificationHidden: verifyNotificationHidden,
|
||||
confirmPrompt: confirmPrompt,
|
||||
createPromptSpy: createPromptSpy,
|
||||
verifyPromptShowing: verifyPromptShowing,
|
||||
verifyPromptHidden: verifyPromptHidden,
|
||||
inlineEdit: inlineEdit,
|
||||
verifyInlineEditChange: verifyInlineEditChange,
|
||||
installMockAnalytics: installMockAnalytics,
|
||||
removeMockAnalytics: removeMockAnalytics
|
||||
};
|
||||
});
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Provides helper methods for invoking Studio editors in Jasmine tests.
|
||||
*/
|
||||
define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec_helpers/modal_helpers', 'js/views/modals/edit_xblock',
|
||||
'js/collections/component_template', 'xmodule', 'cms/js/main', 'xblock/cms.runtime.v1'],
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec_helpers/modal_helpers', 'js/views/modals/edit_xblock',
|
||||
'js/collections/component_template', 'xmodule', 'cms/js/main', 'xblock/cms.runtime.v1'],
|
||||
function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) {
|
||||
var installMockXBlock, uninstallMockXBlock, installMockXModule, uninstallMockXModule,
|
||||
mockComponentTemplates, installEditTemplates, showEditModal, verifyXBlockRequest;
|
||||
@@ -40,30 +40,30 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
|
||||
mockComponentTemplates = new ComponentTemplates([
|
||||
{
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'discussion',
|
||||
'display_name': 'Discussion'
|
||||
category: 'discussion',
|
||||
display_name: 'Discussion'
|
||||
}],
|
||||
'type': 'discussion',
|
||||
'support_legend': {'show_legend': false}
|
||||
type: 'discussion',
|
||||
support_legend: {show_legend: false}
|
||||
}, {
|
||||
'templates': [
|
||||
templates: [
|
||||
{
|
||||
'category': 'html',
|
||||
'boilerplate_name': null,
|
||||
'display_name': 'Text'
|
||||
category: 'html',
|
||||
boilerplate_name: null,
|
||||
display_name: 'Text'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'announcement.yaml',
|
||||
'display_name': 'Announcement'
|
||||
category: 'html',
|
||||
boilerplate_name: 'announcement.yaml',
|
||||
display_name: 'Announcement'
|
||||
}, {
|
||||
'category': 'html',
|
||||
'boilerplate_name': 'raw.yaml',
|
||||
'display_name': 'Raw HTML'
|
||||
category: 'html',
|
||||
boilerplate_name: 'raw.yaml',
|
||||
display_name: 'Raw HTML'
|
||||
}],
|
||||
'type': 'html',
|
||||
'support_legend': {'show_legend': false}
|
||||
type: 'html',
|
||||
support_legend: {show_legend: false}
|
||||
}],
|
||||
{
|
||||
parse: true
|
||||
@@ -95,7 +95,7 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
modal.edit(xblockElement, model, options);
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockHtml,
|
||||
'resources': []
|
||||
resources: []
|
||||
});
|
||||
return modal;
|
||||
};
|
||||
@@ -109,13 +109,13 @@ define(['jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpe
|
||||
};
|
||||
|
||||
return $.extend(modal_helpers, {
|
||||
'installMockXBlock': installMockXBlock,
|
||||
'uninstallMockXBlock': uninstallMockXBlock,
|
||||
'installMockXModule': installMockXModule,
|
||||
'uninstallMockXModule': uninstallMockXModule,
|
||||
'mockComponentTemplates': mockComponentTemplates,
|
||||
'installEditTemplates': installEditTemplates,
|
||||
'showEditModal': showEditModal,
|
||||
'verifyXBlockRequest': verifyXBlockRequest
|
||||
installMockXBlock: installMockXBlock,
|
||||
uninstallMockXBlock: uninstallMockXBlock,
|
||||
installMockXModule: installMockXModule,
|
||||
uninstallMockXModule: uninstallMockXModule,
|
||||
mockComponentTemplates: mockComponentTemplates,
|
||||
installEditTemplates: installEditTemplates,
|
||||
showEditModal: showEditModal,
|
||||
verifyXBlockRequest: verifyXBlockRequest
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,13 +13,13 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'common/js/spec_hel
|
||||
};
|
||||
|
||||
getModalElement = function(modal) {
|
||||
var modalElement;
|
||||
var $modalElement;
|
||||
if (modal) {
|
||||
modalElement = modal.$('.wrapper-modal-window');
|
||||
$modalElement = modal.$('.wrapper-modal-window');
|
||||
} else {
|
||||
modalElement = $('.wrapper-modal-window');
|
||||
$modalElement = $('.wrapper-modal-window');
|
||||
}
|
||||
return modalElement;
|
||||
return $modalElement;
|
||||
};
|
||||
|
||||
getModalWindow = function(modal) {
|
||||
@@ -62,14 +62,14 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'common/js/spec_hel
|
||||
};
|
||||
|
||||
return $.extend(ViewHelpers, {
|
||||
'getModalElement': getModalElement,
|
||||
'getModalWindow': getModalWindow,
|
||||
'getModalTitle': getModalTitle,
|
||||
'installModalTemplates': installModalTemplates,
|
||||
'isShowingModal': isShowingModal,
|
||||
'hideModalIfShowing': hideModalIfShowing,
|
||||
'pressModalButton': pressModalButton,
|
||||
'cancelModal': cancelModal,
|
||||
'cancelModalIfShowing': cancelModalIfShowing
|
||||
getModalElement: getModalElement,
|
||||
getModalWindow: getModalWindow,
|
||||
getModalTitle: getModalTitle,
|
||||
installModalTemplates: installModalTemplates,
|
||||
isShowingModal: isShowingModal,
|
||||
hideModalIfShowing: hideModalIfShowing,
|
||||
pressModalButton: pressModalButton,
|
||||
cancelModal: cancelModal,
|
||||
cancelModalIfShowing: cancelModalIfShowing
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,8 +27,8 @@ define(['jquery', 'js/spec_helpers/modal_helpers', 'common/js/spec_helpers/templ
|
||||
};
|
||||
|
||||
return $.extend(ModalHelpers, {
|
||||
'installValidationTemplates': installValidationTemplates,
|
||||
'checkErrorContents': checkErrorContents,
|
||||
'undoChanges': undoChanges
|
||||
installValidationTemplates: installValidationTemplates,
|
||||
checkErrorContents: checkErrorContents,
|
||||
undoChanges: undoChanges
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
define(['jquery'], function($) {
|
||||
// Trigger "Change" event on "Enter" keyup event
|
||||
var triggerChangeEventOnEnter = function(e) {
|
||||
if (e.which == 13)
|
||||
{
|
||||
if (e.which == 13) {
|
||||
$(this).trigger('change').blur();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ function($, date, TriggerChangeEventOnEnter) {
|
||||
};
|
||||
|
||||
// instrument as date and time pickers
|
||||
timefield.timepicker({'timeFormat': 'H:i'});
|
||||
timefield.timepicker({timeFormat: 'H:i'});
|
||||
datefield.datepicker();
|
||||
|
||||
// Using the change event causes setfield to be triggered twice, but it is necessary
|
||||
@@ -52,7 +52,8 @@ function($, date, TriggerChangeEventOnEnter) {
|
||||
// given a pair of inputs (datepicker and timepicker), return a JS Date
|
||||
// object that corresponds to the datetime.js that they represent. Assume
|
||||
// UTC timezone, NOT the timezone of the user's browser.
|
||||
var date = null, time = null;
|
||||
var date = null,
|
||||
time = null;
|
||||
if (datepickerInput.length > 0) {
|
||||
date = $(datepickerInput).datepicker('getDate');
|
||||
}
|
||||
@@ -97,8 +98,7 @@ function($, date, TriggerChangeEventOnEnter) {
|
||||
var parseDateFromString = function(stringDate) {
|
||||
if (stringDate && typeof stringDate === 'string') {
|
||||
return new Date(stringDate);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return stringDate;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
'js/utils/module', 'common/js/components/views/feedback_notification'],
|
||||
'js/utils/module', 'common/js/components/views/feedback_notification'],
|
||||
function($, ui, _, gettext, Draggabilly, ModuleUtils, NotificationView) {
|
||||
'use strict';
|
||||
|
||||
@@ -17,20 +17,20 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
findDestination: function(ele, yChange) {
|
||||
var eleY = ele.offset().top;
|
||||
var eleYEnd = eleY + ele.outerHeight();
|
||||
var containers = $(ele.data('droppable-class'));
|
||||
var $containers = $(ele.data('droppable-class'));
|
||||
var isSibling = function() {
|
||||
return $(this).data('locator') !== undefined && !$(this).is(ele);
|
||||
};
|
||||
|
||||
for (var i = 0; i < containers.length; i++) {
|
||||
var container = $(containers[i]);
|
||||
for (var i = 0; i < $containers.length; i++) {
|
||||
var $container = $($containers[i]);
|
||||
// Exclude the 'new unit' buttons, and make sure we don't
|
||||
// prepend an element to itself
|
||||
var siblings = container.children().filter(isSibling);
|
||||
var siblings = $container.children().filter(isSibling);
|
||||
// If the container is collapsed, check to see if the
|
||||
// element is on top of its parent list -- don't check the
|
||||
// position of the container
|
||||
var parentList = container.parents(ele.data('parent-location-selector')).first();
|
||||
var parentList = $container.parents(ele.data('parent-location-selector')).first();
|
||||
if (parentList.hasClass(this.collapsedClass)) {
|
||||
var parentListTop = parentList.offset().top;
|
||||
// To make it easier to drop subsections into collapsed sections (which have
|
||||
@@ -42,7 +42,7 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
eleYEnd - collapseFudge <= parentListTop + parentList.outerHeight())
|
||||
) {
|
||||
return {
|
||||
ele: container,
|
||||
ele: $container,
|
||||
attachMethod: 'prepend',
|
||||
parentList: parentList
|
||||
};
|
||||
@@ -54,12 +54,12 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
// unless both elements are at the same location --
|
||||
// this prevents the user from being unable to expand
|
||||
// a section
|
||||
var containerY = container.offset().top;
|
||||
var containerY = $container.offset().top;
|
||||
if (siblings.length === 0 &&
|
||||
containerY !== eleY &&
|
||||
Math.abs(eleY - containerY) < 50) {
|
||||
return {
|
||||
ele: container,
|
||||
ele: $container,
|
||||
attachMethod: 'prepend'
|
||||
};
|
||||
}
|
||||
@@ -100,8 +100,7 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
attachMethod: 'after'
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Dragging up into end of list.
|
||||
if (j === siblings.length - 1 && yChange < 0 &&
|
||||
Math.abs(eleY - siblingYEnd) <= fudge) {
|
||||
@@ -126,8 +125,7 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
ele: $sibling,
|
||||
attachMethod: 'after'
|
||||
};
|
||||
}
|
||||
else if (eleY >= siblingY && eleY <= siblingYEnd) {
|
||||
} else if (eleY >= siblingY && eleY <= siblingYEnd) {
|
||||
return {
|
||||
ele: $sibling,
|
||||
attachMethod: eleY - siblingY <= siblingHeight / 2 ? 'before' : 'after'
|
||||
@@ -149,7 +147,7 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
dragState: {},
|
||||
|
||||
onDragStart: function(draggable) {
|
||||
var ele = $(draggable.element);
|
||||
var $ele = $(draggable.element);
|
||||
this.dragState = {
|
||||
// Which element will be dropped into/onto on success
|
||||
dropDestination: null,
|
||||
@@ -162,18 +160,18 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
// The direction the drag is moving in (negative means up, positive down).
|
||||
dragDirection: 0
|
||||
};
|
||||
if (!ele.hasClass(this.collapsedClass)) {
|
||||
ele.addClass(this.collapsedClass);
|
||||
ele.find('.expand-collapse').first().addClass('expand').removeClass('collapse');
|
||||
if (!$ele.hasClass(this.collapsedClass)) {
|
||||
$ele.addClass(this.collapsedClass);
|
||||
$ele.find('.expand-collapse').first().addClass('expand').removeClass('collapse');
|
||||
|
||||
// onDragStart gets called again after the collapse, so we can't
|
||||
// just store a variable in the dragState.
|
||||
ele.addClass(this.expandOnDropClass);
|
||||
$ele.addClass(this.expandOnDropClass);
|
||||
}
|
||||
|
||||
// We should remove this class name before start dragging to
|
||||
// avoid performance issues.
|
||||
ele.removeClass('was-dragging');
|
||||
$ele.removeClass('was-dragging');
|
||||
},
|
||||
|
||||
onDragMove: function(draggable, event, pointer) {
|
||||
@@ -182,8 +180,7 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
var dragBuffer = 10;
|
||||
if (window.innerHeight - dragBuffer < pointer.clientY) {
|
||||
scrollAmount = dragBuffer;
|
||||
}
|
||||
else if (dragBuffer > pointer.clientY) {
|
||||
} else if (dragBuffer > pointer.clientY) {
|
||||
scrollAmount = -(dragBuffer);
|
||||
}
|
||||
if (scrollAmount !== 0) {
|
||||
@@ -197,8 +194,8 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
}
|
||||
this.dragState.lastY = draggable.dragPoint.y;
|
||||
|
||||
var ele = $(draggable.element);
|
||||
var destinationInfo = this.findDestination(ele, this.dragState.direction);
|
||||
var $ele = $(draggable.element);
|
||||
var destinationInfo = this.findDestination($ele, this.dragState.direction);
|
||||
var destinationEle = destinationInfo.ele;
|
||||
this.dragState.parentList = destinationInfo.parentList;
|
||||
|
||||
@@ -207,52 +204,51 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
this.dragState.dropDestination.removeClass(this.droppableClasses);
|
||||
}
|
||||
// Mark the new destination
|
||||
if (destinationEle && this.pointerInBounds(pointer, ele)) {
|
||||
ele.addClass(this.validDropClass);
|
||||
if (destinationEle && this.pointerInBounds(pointer, $ele)) {
|
||||
$ele.addClass(this.validDropClass);
|
||||
destinationEle.addClass('drop-target drop-target-' + destinationInfo.attachMethod);
|
||||
this.dragState.attachMethod = destinationInfo.attachMethod;
|
||||
this.dragState.dropDestination = destinationEle;
|
||||
}
|
||||
else {
|
||||
ele.removeClass(this.validDropClass);
|
||||
} else {
|
||||
$ele.removeClass(this.validDropClass);
|
||||
this.dragState.attachMethod = '';
|
||||
this.dragState.dropDestination = null;
|
||||
}
|
||||
},
|
||||
|
||||
onDragEnd: function(draggable, event, pointer) {
|
||||
var ele = $(draggable.element);
|
||||
var $ele = $(draggable.element);
|
||||
var destination = this.dragState.dropDestination;
|
||||
|
||||
// Clear dragging state in preparation for the next event.
|
||||
if (destination) {
|
||||
destination.removeClass(this.droppableClasses);
|
||||
}
|
||||
ele.removeClass(this.validDropClass);
|
||||
$ele.removeClass(this.validDropClass);
|
||||
|
||||
// If the drag succeeded, rearrange the DOM and send the result.
|
||||
if (destination && this.pointerInBounds(pointer, ele)) {
|
||||
if (destination && this.pointerInBounds(pointer, $ele)) {
|
||||
// Make sure we don't drop into a collapsed element
|
||||
if (this.dragState.parentList) {
|
||||
this.expandElement(this.dragState.parentList);
|
||||
}
|
||||
var method = this.dragState.attachMethod;
|
||||
destination[method](ele);
|
||||
this.handleReorder(ele);
|
||||
destination[method]($ele);
|
||||
this.handleReorder($ele);
|
||||
}
|
||||
// If the drag failed, send it back
|
||||
else {
|
||||
$('.was-dragging').removeClass('was-dragging');
|
||||
ele.addClass('was-dragging');
|
||||
$ele.addClass('was-dragging');
|
||||
}
|
||||
|
||||
if (ele.hasClass(this.expandOnDropClass)) {
|
||||
this.expandElement(ele);
|
||||
ele.removeClass(this.expandOnDropClass);
|
||||
if ($ele.hasClass(this.expandOnDropClass)) {
|
||||
this.expandElement($ele);
|
||||
$ele.removeClass(this.expandOnDropClass);
|
||||
}
|
||||
|
||||
// Everything in its right place
|
||||
ele.css({
|
||||
$ele.css({
|
||||
top: 'auto',
|
||||
left: 'auto'
|
||||
});
|
||||
@@ -371,8 +367,8 @@ define(['jquery', 'jquery.ui', 'underscore', 'gettext', 'draggabilly',
|
||||
'droppable-class': options.droppableClass,
|
||||
'parent-location-selector': options.parentLocationSelector,
|
||||
'child-selector': options.type,
|
||||
'refresh': options.refresh,
|
||||
'ensureChildrenRendered': options.ensureChildrenRendered
|
||||
refresh: options.refresh,
|
||||
ensureChildrenRendered: options.ensureChildrenRendered
|
||||
});
|
||||
|
||||
draggable = new Draggabilly(element, {
|
||||
|
||||
@@ -36,8 +36,7 @@ define(['jquery'], function($) {
|
||||
$(this).attr('src', ifr_source + '?' + wmode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$(this).attr('wmode', 'transparent');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,8 +59,7 @@ define(['jquery'], function($) {
|
||||
$modalCover.unbind('click');
|
||||
if (clickHandler) {
|
||||
$modalCover.bind('click', clickHandler);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$modalCover.bind('click', hideModal);
|
||||
}
|
||||
return $modalCover;
|
||||
|
||||
@@ -13,8 +13,7 @@ define(['underscore'], function(_) {
|
||||
var getUpdateUrl = function(locator) {
|
||||
if (_.isUndefined(locator)) {
|
||||
return urlRoot + '/';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return urlRoot + '/' + locator;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -72,8 +72,7 @@ define(['js/views/baseview', 'underscore'], function(BaseView, _) {
|
||||
|
||||
if (this.model.isExplicitlySet()) {
|
||||
this.showClearButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$el.removeClass('is-set');
|
||||
this.getClearButton().addClass('inactive');
|
||||
this.getClearButton().removeClass('active');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['js/views/baseview', 'underscore', 'gettext', 'common/js/components/views/feedback_prompt',
|
||||
'common/js/components/views/feedback_notification'],
|
||||
'common/js/components/views/feedback_notification'],
|
||||
function(BaseView, _, gettext, PromptView, NotificationView) {
|
||||
var AssetView = BaseView.extend({
|
||||
initialize: function() {
|
||||
@@ -36,8 +36,7 @@ define(['js/views/baseview', 'underscore', 'gettext', 'common/js/components/view
|
||||
if (this.model.get('locked')) {
|
||||
this.$el.addClass(locked_class);
|
||||
this.$el.find('.lock-checkbox').attr('checked', 'checked');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$el.removeClass(locked_class);
|
||||
this.$el.find('.lock-checkbox').removeAttr('checked');
|
||||
}
|
||||
@@ -45,7 +44,8 @@ define(['js/views/baseview', 'underscore', 'gettext', 'common/js/components/view
|
||||
|
||||
confirmDelete: function(e) {
|
||||
if (e && e.preventDefault) { e.preventDefault(); }
|
||||
var asset = this.model, collection = this.model.collection;
|
||||
var asset = this.model,
|
||||
collection = this.model.collection;
|
||||
new PromptView.Warning({
|
||||
title: gettext('Delete File Confirmation'),
|
||||
message: gettext('Are you sure you wish to delete this item. It cannot be reversed!\n\nAlso any content that links/refers to this item will no longer work (e.g. broken images and/or links)'),
|
||||
@@ -81,7 +81,7 @@ define(['js/views/baseview', 'underscore', 'gettext', 'common/js/components/view
|
||||
var saving = new NotificationView.Mini({
|
||||
title: gettext('Saving')
|
||||
}).show();
|
||||
asset.save({'locked': !asset.get('locked')}, {
|
||||
asset.save({locked: !asset.get('locked')}, {
|
||||
wait: true, // This means we won't re-render until we get back the success state.
|
||||
success: function() {
|
||||
saving.hide();
|
||||
|
||||
@@ -132,8 +132,8 @@ define([
|
||||
handleDestroy: function(model) {
|
||||
this.collection.fetch({reset: true}); // reload the collection to get a fresh page full of items
|
||||
analytics.track('Deleted Asset', {
|
||||
'course': course_location_analytics,
|
||||
'id': model.get('url')
|
||||
course: course_location_analytics,
|
||||
id: model.get('url')
|
||||
});
|
||||
},
|
||||
|
||||
@@ -145,8 +145,8 @@ define([
|
||||
this.pagingView.setPage(1);
|
||||
|
||||
analytics.track('Uploaded a File', {
|
||||
'course': course_location_analytics,
|
||||
'asset_url': model.get('url')
|
||||
course: course_location_analytics,
|
||||
asset_url: model.get('url')
|
||||
});
|
||||
},
|
||||
|
||||
@@ -207,13 +207,13 @@ define([
|
||||
}
|
||||
|
||||
self.largeFileErrorMsg = new NotificationView.Error({
|
||||
'title': gettext('Your file could not be uploaded'),
|
||||
'message': error
|
||||
title: gettext('Your file could not be uploaded'),
|
||||
message: error
|
||||
});
|
||||
self.largeFileErrorMsg.show();
|
||||
|
||||
self.displayFailedUpload({
|
||||
'msg': gettext('Max file size exceeded')
|
||||
msg: gettext('Max file size exceeded')
|
||||
});
|
||||
},
|
||||
processdone: function(event, data) {
|
||||
@@ -281,8 +281,7 @@ define([
|
||||
if (assettype) {
|
||||
if (assettype === this.allLabel) {
|
||||
titleText.text(titleText.data('alllabel'));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
titleText.text(assettype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'underscore', 'backbone', 'gettext', 'js/utils/handle_iframe_binding', 'js/utils/templates',
|
||||
'common/js/components/utils/view_utils'],
|
||||
'common/js/components/utils/view_utils'],
|
||||
function($, _, Backbone, gettext, IframeUtils, TemplateUtils, ViewUtils) {
|
||||
/*
|
||||
This view is extended from backbone to provide useful functionality for all Studio views.
|
||||
@@ -58,12 +58,12 @@ define(['jquery', 'underscore', 'backbone', 'gettext', 'js/utils/handle_iframe_b
|
||||
},
|
||||
|
||||
toggleExpandCollapse: function(event) {
|
||||
var target = $(event.target);
|
||||
var $target = $(event.target);
|
||||
// Don't propagate the event as it is possible that two views will both contain
|
||||
// this element, e.g. clicking on the element of a child view container in a parent.
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
ViewUtils.toggleExpandCollapse(target, this.options.collapsedClass);
|
||||
ViewUtils.toggleExpandCollapse($target, this.options.collapsedClass);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This is a simple component that renders add buttons for all available XBlock template types.
|
||||
*/
|
||||
define(['jquery', 'underscore', 'gettext', 'js/views/baseview', 'common/js/components/utils/view_utils',
|
||||
'js/views/components/add_xblock_button', 'js/views/components/add_xblock_menu'],
|
||||
'js/views/components/add_xblock_button', 'js/views/components/add_xblock_menu'],
|
||||
function($, _, gettext, BaseView, ViewUtils, AddXBlockButton, AddXBlockMenu) {
|
||||
var AddXBlockComponent = BaseView.extend({
|
||||
events: {
|
||||
@@ -57,14 +57,14 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview', 'common/js/compo
|
||||
|
||||
createNewComponent: function(event) {
|
||||
var self = this,
|
||||
element = $(event.currentTarget),
|
||||
saveData = element.data(),
|
||||
$element = $(event.currentTarget),
|
||||
saveData = $element.data(),
|
||||
oldOffset = ViewUtils.getScrollOffset(this.$el);
|
||||
event.preventDefault();
|
||||
this.closeNewComponent(event);
|
||||
ViewUtils.runOperationShowingMessage(
|
||||
gettext('Adding'),
|
||||
_.bind(this.options.createComponent, this, saveData, element)
|
||||
_.bind(this.options.createComponent, this, saveData, $element)
|
||||
).always(function() {
|
||||
// Restore the scroll position of the buttons so that the new
|
||||
// component appears above them.
|
||||
|
||||
@@ -14,7 +14,8 @@ define(['jquery', 'underscore', 'js/views/xblock', 'js/utils/module', 'gettext',
|
||||
xblockReady: function() {
|
||||
XBlockView.prototype.xblockReady.call(this);
|
||||
var reorderableClass, reorderableContainer,
|
||||
newParent, oldParent, self = this;
|
||||
newParent, oldParent,
|
||||
self = this;
|
||||
|
||||
this.requestToken = this.$('div.xblock').first().data('request-token');
|
||||
reorderableClass = this.makeRequestSpecificSelector('.reorderable-container');
|
||||
@@ -91,7 +92,8 @@ define(['jquery', 'underscore', 'js/views/xblock', 'js/utils/module', 'gettext',
|
||||
},
|
||||
|
||||
updateChildren: function(targetParent, successCallback) {
|
||||
var children, childLocators, xblockInfo = this.model;
|
||||
var children, childLocators,
|
||||
xblockInfo = this.model;
|
||||
|
||||
// Find descendants with class "studio-xblock-wrapper" whose parent === targetParent.
|
||||
// This is necessary to filter our grandchildren, great-grandchildren, etc.
|
||||
|
||||
@@ -12,7 +12,7 @@ function(ListItemEditorView, _) {
|
||||
tagName: 'div',
|
||||
className: 'content-group-edit collection-edit',
|
||||
events: {
|
||||
'submit': 'setAndClose',
|
||||
submit: 'setAndClose',
|
||||
'click .action-cancel': 'cancel'
|
||||
},
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ define(['js/views/baseview', 'codemirror', 'common/js/components/views/feedback_
|
||||
|
||||
render: function() {
|
||||
CourseInfoHelper.changeContentToPreview(
|
||||
this.model, 'data', this.options['base_asset_url']);
|
||||
this.model, 'data', this.options.base_asset_url);
|
||||
|
||||
this.$el.html(
|
||||
$(this.template({
|
||||
@@ -44,7 +44,7 @@ define(['js/views/baseview', 'codemirror', 'common/js/components/views/feedback_
|
||||
this.$form.show();
|
||||
|
||||
this.$codeMirror = CourseInfoHelper.editWithCodeMirror(
|
||||
self.model, 'data', self.options['base_asset_url'], this.$editor.get(0));
|
||||
self.model, 'data', self.options.base_asset_url, this.$editor.get(0));
|
||||
|
||||
ModalUtils.showModalCover(false, function() { self.closeEditor(); });
|
||||
},
|
||||
@@ -72,7 +72,7 @@ define(['js/views/baseview', 'codemirror', 'common/js/components/views/feedback_
|
||||
this.closeEditor();
|
||||
|
||||
analytics.track('Saved Course Handouts', {
|
||||
'course': course_location_analytics
|
||||
course: course_location_analytics
|
||||
});
|
||||
} else {
|
||||
$('#handout_error').addClass('is-shown');
|
||||
|
||||
@@ -28,6 +28,6 @@ define(['codemirror', 'js/utils/handle_iframe_binding', 'utility'],
|
||||
return content;
|
||||
};
|
||||
|
||||
return {'editWithCodeMirror': editWithCodeMirror, 'changeContentToPreview': changeContentToPreview};
|
||||
return {editWithCodeMirror: editWithCodeMirror, changeContentToPreview: changeContentToPreview};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
define(['codemirror',
|
||||
'js/utils/modal',
|
||||
'js/utils/date_utils',
|
||||
'edx-ui-toolkit/js/utils/html-utils',
|
||||
'js/views/course_info_helper',
|
||||
'js/views/validation',
|
||||
'js/models/course_update',
|
||||
'common/js/components/views/feedback_prompt',
|
||||
'common/js/components/views/feedback_notification'],
|
||||
'js/utils/modal',
|
||||
'js/utils/date_utils',
|
||||
'edx-ui-toolkit/js/utils/html-utils',
|
||||
'js/views/course_info_helper',
|
||||
'js/views/validation',
|
||||
'js/models/course_update',
|
||||
'common/js/components/views/feedback_prompt',
|
||||
'common/js/components/views/feedback_notification'],
|
||||
function(CodeMirror, ModalUtils, DateUtils, HtmlUtils, CourseInfoHelper, ValidatingView, CourseUpdateModel,
|
||||
PromptView, NotificationView) {
|
||||
'use strict';
|
||||
@@ -184,9 +184,9 @@ define(['codemirror',
|
||||
this.closeEditor(false);
|
||||
|
||||
analytics.track('Saved Course Update', {
|
||||
'course': course_location_analytics,
|
||||
'date': this.dateEntry(event).val(),
|
||||
'push_notification_selected': this.push_notification_selected(event)
|
||||
course: course_location_analytics,
|
||||
date: this.dateEntry(event).val(),
|
||||
push_notification_selected: this.push_notification_selected(event)
|
||||
});
|
||||
},
|
||||
|
||||
@@ -214,8 +214,7 @@ define(['codemirror',
|
||||
// translate long-form date (for viewing) into short-form date (for input)
|
||||
if (targetModel.get('date') && targetModel.isValid()) {
|
||||
$(this.dateEntry(event)).val($.datepicker.formatDate('mm/dd/yy', new Date(targetModel.get('date'))));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$(this.dateEntry(event)).val('MM/DD/YY');
|
||||
}
|
||||
this.$codeMirror = CourseInfoHelper.editWithCodeMirror(
|
||||
@@ -245,8 +244,8 @@ define(['codemirror',
|
||||
text: gettext('OK'),
|
||||
click: function() {
|
||||
analytics.track('Deleted Course Update', {
|
||||
'course': course_location_analytics,
|
||||
'date': self.dateEntry(event).val()
|
||||
course: course_location_analytics,
|
||||
date: self.dateEntry(event).val()
|
||||
});
|
||||
self.modelDom(event).remove();
|
||||
var deleting = new NotificationView.Mini({
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* - adding units will automatically redirect to the unit page rather than showing them inline
|
||||
*/
|
||||
define(['jquery', 'underscore', 'js/views/xblock_outline', 'common/js/components/utils/view_utils', 'js/views/utils/xblock_utils',
|
||||
'js/models/xblock_outline_info', 'js/views/modals/course_outline_modals', 'js/utils/drag_and_drop'],
|
||||
'js/models/xblock_outline_info', 'js/views/modals/course_outline_modals', 'js/utils/drag_and_drop'],
|
||||
function(
|
||||
$, _, XBlockOutlineView, ViewUtils, XBlockViewUtils,
|
||||
XBlockOutlineInfo, CourseOutlineModalsFactory, ContentDragger
|
||||
@@ -69,8 +69,7 @@ define(['jquery', 'underscore', 'js/views/xblock_outline', 'common/js/components
|
||||
var locator = this.model.get('id');
|
||||
if (isCollapsed) {
|
||||
this.expandedLocators.remove(locator);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.expandedLocators.add(locator);
|
||||
}
|
||||
this.refresh();
|
||||
@@ -239,8 +238,7 @@ define(['jquery', 'underscore', 'js/views/xblock_outline', 'common/js/components
|
||||
refresh: this.refreshWithCollapsedState.bind(this),
|
||||
ensureChildrenRendered: this.ensureChildrenRendered.bind(this)
|
||||
});
|
||||
}
|
||||
else if ($(element).hasClass('outline-subsection')) {
|
||||
} else if ($(element).hasClass('outline-subsection')) {
|
||||
ContentDragger.makeDraggable(element, {
|
||||
type: '.outline-subsection',
|
||||
handleClass: '.subsection-drag-handle',
|
||||
@@ -249,8 +247,7 @@ define(['jquery', 'underscore', 'js/views/xblock_outline', 'common/js/components
|
||||
refresh: this.refreshWithCollapsedState.bind(this),
|
||||
ensureChildrenRendered: this.ensureChildrenRendered.bind(this)
|
||||
});
|
||||
}
|
||||
else if ($(element).hasClass('outline-unit')) {
|
||||
} else if ($(element).hasClass('outline-unit')) {
|
||||
ContentDragger.makeDraggable(element, {
|
||||
type: '.outline-unit',
|
||||
handleClass: '.unit-drag-handle',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* global course */
|
||||
|
||||
define(['underscore', 'jquery', 'gettext', 'edx-ui-toolkit/js/utils/html-utils',
|
||||
'js/views/baseview', 'js/models/uploads', 'js/views/uploads', 'text!templates/edit-chapter.underscore'],
|
||||
'js/views/baseview', 'js/models/uploads', 'js/views/uploads', 'text!templates/edit-chapter.underscore'],
|
||||
function(_, $, gettext, HtmlUtils, BaseView, FileUploadModel, UploadDialogView, editChapterTemplate) {
|
||||
'use strict';
|
||||
|
||||
@@ -31,7 +31,7 @@ define(['underscore', 'jquery', 'gettext', 'edx-ui-toolkit/js/utils/html-utils',
|
||||
'change .chapter-asset-path': 'changeAssetPath',
|
||||
'click .action-close': 'removeChapter',
|
||||
'click .action-upload': 'openUploadDialog',
|
||||
'submit': 'uploadAsset'
|
||||
submit: 'uploadAsset'
|
||||
},
|
||||
changeName: function(e) {
|
||||
if (e && e.preventDefault) { e.preventDefault(); }
|
||||
|
||||
@@ -21,7 +21,7 @@ define(['js/views/baseview', 'underscore', 'jquery', 'js/views/edit_chapter', 'c
|
||||
},
|
||||
events: {
|
||||
'change input[name=textbook-name]': 'setName',
|
||||
'submit': 'setAndClose',
|
||||
submit: 'setAndClose',
|
||||
'click .action-cancel': 'cancel',
|
||||
'click .action-add-chapter': 'createChapter'
|
||||
},
|
||||
@@ -49,8 +49,8 @@ define(['js/views/baseview', 'underscore', 'jquery', 'js/views/edit_chapter', 'c
|
||||
var chapter = that.model.get('chapters').at(i);
|
||||
if (!chapter) { return; }
|
||||
chapter.set({
|
||||
'name': $('.chapter-name', li).val(),
|
||||
'asset_path': $('.chapter-asset-path', li).val()
|
||||
name: $('.chapter-name', li).val(),
|
||||
asset_path: $('.chapter-asset-path', li).val()
|
||||
});
|
||||
});
|
||||
return this;
|
||||
|
||||
@@ -16,7 +16,7 @@ function(ListItemEditorView, _, $, gettext, ExperimentGroupEditView) {
|
||||
'click .action-add-group': 'createGroup',
|
||||
'focus .input-text': 'onFocus',
|
||||
'blur .input-text': 'onBlur',
|
||||
'submit': 'setAndClose',
|
||||
submit: 'setAndClose',
|
||||
'click .action-cancel': 'cancel'
|
||||
},
|
||||
|
||||
@@ -108,7 +108,7 @@ function(ListItemEditorView, _, $, gettext, ExperimentGroupEditView) {
|
||||
|
||||
if (group) {
|
||||
group.set({
|
||||
'name': $('.group-name', li).val()
|
||||
name: $('.group-name', li).val()
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
|
||||
@@ -27,8 +27,8 @@ define([
|
||||
|
||||
attributes: function() {
|
||||
return {
|
||||
'id': this.model.get('id'),
|
||||
'tabindex': -1
|
||||
id: this.model.get('id'),
|
||||
tabindex: -1
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -5,48 +5,48 @@ define([
|
||||
], function(BaseView, _, licenseSelectorTemplate) {
|
||||
var defaultLicenseInfo = {
|
||||
'all-rights-reserved': {
|
||||
'name': gettext('All Rights Reserved'),
|
||||
'tooltip': gettext('You reserve all rights for your work')
|
||||
name: gettext('All Rights Reserved'),
|
||||
tooltip: gettext('You reserve all rights for your work')
|
||||
},
|
||||
'creative-commons': {
|
||||
'name': gettext('Creative Commons'),
|
||||
'tooltip': gettext('You waive some rights for your work, such that others can use it too'),
|
||||
'url': 'https://creativecommons.org/about',
|
||||
'options': {
|
||||
'ver': {
|
||||
'name': gettext('Version'),
|
||||
'type': 'string',
|
||||
'default': '4.0'
|
||||
name: gettext('Creative Commons'),
|
||||
tooltip: gettext('You waive some rights for your work, such that others can use it too'),
|
||||
url: 'https://creativecommons.org/about',
|
||||
options: {
|
||||
ver: {
|
||||
name: gettext('Version'),
|
||||
type: 'string',
|
||||
default: '4.0'
|
||||
},
|
||||
'BY': {
|
||||
'name': gettext('Attribution'),
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'help': gettext('Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.'),
|
||||
'disabled': true
|
||||
BY: {
|
||||
name: gettext('Attribution'),
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
help: gettext('Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.'),
|
||||
disabled: true
|
||||
},
|
||||
'NC': {
|
||||
'name': gettext('Noncommercial'),
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'help': gettext('Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.')
|
||||
NC: {
|
||||
name: gettext('Noncommercial'),
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
help: gettext('Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.')
|
||||
},
|
||||
'ND': {
|
||||
'name': gettext('No Derivatives'),
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'help': gettext('Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with "Share Alike".'),
|
||||
'conflictsWith': ['SA']
|
||||
ND: {
|
||||
name: gettext('No Derivatives'),
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
help: gettext('Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with "Share Alike".'),
|
||||
conflictsWith: ['SA']
|
||||
},
|
||||
'SA': {
|
||||
'name': gettext('Share Alike'),
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'help': gettext('Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with "No Derivatives".'),
|
||||
'conflictsWith': ['ND']
|
||||
SA: {
|
||||
name: gettext('Share Alike'),
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
help: gettext('Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with "No Derivatives".'),
|
||||
conflictsWith: ['ND']
|
||||
}
|
||||
},
|
||||
'option_order': ['BY', 'NC', 'ND', 'SA']
|
||||
option_order: ['BY', 'NC', 'ND', 'SA']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
this.model.set({'options': licenseOptions});
|
||||
this.model.set({options: licenseOptions});
|
||||
// Backbone has trouble identifying when objects change, so we'll
|
||||
// fire the change event manually.
|
||||
this.model.trigger('change change:options');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Code for editing users and assigning roles within a course or library team context.
|
||||
*/
|
||||
define(['jquery', 'underscore', 'gettext', 'js/views/baseview',
|
||||
'common/js/components/views/feedback_prompt', 'common/js/components/utils/view_utils'],
|
||||
'common/js/components/views/feedback_prompt', 'common/js/components/utils/view_utils'],
|
||||
function($, _, gettext, BaseView, PromptView, ViewUtils) {
|
||||
'use strict';
|
||||
var default_messages = {
|
||||
@@ -95,7 +95,7 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview',
|
||||
'click .create-user-button': 'addUserHandler',
|
||||
'submit #create-user-form': 'createUserFormSubmit',
|
||||
'click .action-cancel': 'cancelEditHandler',
|
||||
'keyup': 'keyUpHandler',
|
||||
keyup: 'keyUpHandler',
|
||||
'click .remove-user': 'removeUserHandler'
|
||||
};
|
||||
var roleEvents = {};
|
||||
@@ -106,7 +106,7 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview',
|
||||
|
||||
(function(role) {
|
||||
roleEvents[role_selector] = function(event) { self.handleRoleButtonClick(event.target, role); };
|
||||
})(role_name);
|
||||
}(role_name));
|
||||
}
|
||||
return _.extend(baseEvents, roleEvents);
|
||||
},
|
||||
@@ -171,8 +171,7 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview',
|
||||
role_names = _.map(this.roles, function(role) { return role.key; });
|
||||
if (role === this.admin_role.key && adminRoleCount === 1) {
|
||||
result.push({notoggle: true});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var currentRoleIdx = _.indexOf(role_names, role);
|
||||
// in reverse order to show "Add" buttons to the left, "Remove" to the right
|
||||
for (var i = this.roles.length - 1; i >= 0; i--) {
|
||||
|
||||
@@ -31,9 +31,9 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
model: model
|
||||
},
|
||||
conversions = {
|
||||
'Select': 'Option',
|
||||
'Float': 'Number',
|
||||
'Integer': 'Number'
|
||||
Select: 'Option',
|
||||
Float: 'Number',
|
||||
Integer: 'Number'
|
||||
},
|
||||
type = model.getType();
|
||||
|
||||
@@ -77,7 +77,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
if (model.get('field_name') === 'display_name') {
|
||||
var displayNameValue = model.get('value');
|
||||
// It is possible that there is no display name value set. In that case, return empty string.
|
||||
displayName = displayNameValue ? displayNameValue : '';
|
||||
displayName = displayNameValue || '';
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -151,8 +151,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
if (options.hasOwnProperty(step)) {
|
||||
// Parse step and convert to String. Polyfill doesn't like float values like ".1" (expects "0.1").
|
||||
stepValue = numToString(Number(options[step]));
|
||||
}
|
||||
else if (this.isIntegerField()) {
|
||||
} else if (this.isIntegerField()) {
|
||||
stepValue = '1';
|
||||
}
|
||||
if (stepValue !== undefined) {
|
||||
@@ -238,9 +237,8 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
_.each(this.model.getOptions(), function(modelValue) {
|
||||
if (modelValue === selectedText) {
|
||||
selectedValue = modelValue;
|
||||
}
|
||||
else if (modelValue['display_name'] === selectedText) {
|
||||
selectedValue = modelValue['value'];
|
||||
} else if (modelValue.display_name === selectedText) {
|
||||
selectedValue = modelValue.value;
|
||||
}
|
||||
});
|
||||
return selectedValue;
|
||||
@@ -250,8 +248,8 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
// Value here is the json value as used by the field. The choice may instead be showing display names.
|
||||
// Find the display name matching the value passed in.
|
||||
_.each(this.model.getOptions(), function(modelValue) {
|
||||
if (modelValue['value'] === value) {
|
||||
value = modelValue['display_name'];
|
||||
if (modelValue.value === value) {
|
||||
value = modelValue.display_name;
|
||||
}
|
||||
});
|
||||
this.$el.find('#' + this.uniqueId + ' option').filter(function() {
|
||||
@@ -291,7 +289,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
'<a href="#" class="remove-action remove-setting" data-index="<%- index %>"><span class="icon fa fa-times-circle" aria-hidden="true"></span><span class="sr">' + gettext('Remove') + '</span></a>' + // eslint-disable-line max-len
|
||||
'</li>'
|
||||
);
|
||||
list.append($(template({'ele': ele, 'index': index})));
|
||||
list.append($(template({ele: ele, index: index})));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -459,7 +457,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
'</li>'
|
||||
);
|
||||
|
||||
frag.appendChild($(template({'key': key, 'value': value}))[0]);
|
||||
frag.appendChild($(template({key: key, value: value}))[0]);
|
||||
});
|
||||
|
||||
list.html([frag]);
|
||||
@@ -532,7 +530,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
|
||||
upload: function(event) {
|
||||
var self = this,
|
||||
target = $(event.currentTarget),
|
||||
$target = $(event.currentTarget),
|
||||
url = '/assets/' + this.options.courseKey + '/',
|
||||
model = new FileUpload({
|
||||
title: gettext('Upload File')
|
||||
@@ -540,10 +538,10 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
view = new UploadDialog({
|
||||
model: model,
|
||||
url: url,
|
||||
parentElement: target.closest('.xblock-editor'),
|
||||
parentElement: $target.closest('.xblock-editor'),
|
||||
onSuccess: function(response) {
|
||||
if (response['asset'] && response['asset']['url']) {
|
||||
self.model.setValue(response['asset']['url']);
|
||||
if (response.asset && response.asset.url) {
|
||||
self.model.setValue(response.asset.url);
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
@@ -555,7 +553,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
Metadata.License = AbstractEditor.extend({
|
||||
|
||||
initialize: function(options) {
|
||||
this.licenseModel = new LicenseModel({'asString': this.model.getValue()});
|
||||
this.licenseModel = new LicenseModel({asString: this.model.getValue()});
|
||||
this.licenseView = new LicenseView({model: this.licenseModel});
|
||||
|
||||
// Rerender when the license model changes
|
||||
|
||||
@@ -334,10 +334,10 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
|
||||
afterRender: function() {
|
||||
AbstractEditor.prototype.afterRender.call(this);
|
||||
this.$('input.date').datepicker({'dateFormat': 'm/d/yy'});
|
||||
this.$('input.date').datepicker({dateFormat: 'm/d/yy'});
|
||||
this.$('input.time').timepicker({
|
||||
'timeFormat': 'H:i',
|
||||
'forceRoundTime': false
|
||||
timeFormat: 'H:i',
|
||||
forceRoundTime: false
|
||||
});
|
||||
if (this.model.get(this.fieldName)) {
|
||||
DateUtils.setDate(
|
||||
@@ -365,7 +365,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
getRequestData: function() {
|
||||
return {
|
||||
metadata: {
|
||||
'due': this.getValue()
|
||||
due: this.getValue()
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -400,7 +400,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
}
|
||||
return {
|
||||
metadata: {
|
||||
'start': newReleaseDate
|
||||
start: newReleaseDate
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -429,8 +429,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
}
|
||||
if (showRulesField) {
|
||||
this.$('.field-exam-review-rules').show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$('.field-exam-review-rules').hide();
|
||||
}
|
||||
},
|
||||
@@ -456,10 +455,10 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
afterRender: function() {
|
||||
AbstractEditor.prototype.afterRender.call(this);
|
||||
this.$('input.time').timepicker({
|
||||
'timeFormat': 'H:i',
|
||||
'minTime': '00:30',
|
||||
'maxTime': '24:00',
|
||||
'forceRoundTime': false
|
||||
timeFormat: 'H:i',
|
||||
minTime: '00:30',
|
||||
maxTime: '24:00',
|
||||
forceRoundTime: false
|
||||
});
|
||||
|
||||
this.setExamType(this.model.get('is_time_limited'), this.model.get('is_proctored_exam'),
|
||||
@@ -546,16 +545,16 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
|
||||
return {
|
||||
metadata: {
|
||||
'is_practice_exam': is_practice_exam,
|
||||
'is_time_limited': is_time_limited,
|
||||
'exam_review_rules': exam_review_rules,
|
||||
is_practice_exam: is_practice_exam,
|
||||
is_time_limited: is_time_limited,
|
||||
exam_review_rules: exam_review_rules,
|
||||
// We have to use the legacy field name
|
||||
// as the Ajax handler directly populates
|
||||
// the xBlocks fields. We will have to
|
||||
// update this call site when we migrate
|
||||
// seq_module.py to use 'is_proctored_exam'
|
||||
'is_proctored_enabled': is_proctored_exam,
|
||||
'default_time_limit_minutes': this.convertTimeLimitToMinutes(time_limit)
|
||||
is_proctored_enabled: is_proctored_exam,
|
||||
default_time_limit_minutes: this.convertTimeLimitToMinutes(time_limit)
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -633,7 +632,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
|
||||
getRequestData: function() {
|
||||
return {
|
||||
'graderType': this.getValue()
|
||||
graderType: this.getValue()
|
||||
};
|
||||
},
|
||||
|
||||
@@ -856,8 +855,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
if (this.currentVisibility() === 'staff_only') {
|
||||
metadata.visible_to_staff_only = true;
|
||||
metadata.hide_after_due = null;
|
||||
}
|
||||
else if (this.currentVisibility() === 'hide_after_due') {
|
||||
} else if (this.currentVisibility() === 'hide_after_due') {
|
||||
metadata.visible_to_staff_only = null;
|
||||
metadata.hide_after_due = true;
|
||||
} else {
|
||||
@@ -869,8 +867,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
|
||||
publish: 'republish',
|
||||
metadata: metadata
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user