Merge pull request #186 from edx/sustaining/security-fixes-2
Sustaining/security fixes 2
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
* 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'],
|
||||
function($, _, gettext, BaseView, ViewUtils, AddXBlockButton, AddXBlockMenu) {
|
||||
'js/views/components/add_xblock_button', 'js/views/components/add_xblock_menu',
|
||||
'edx-ui-toolkit/js/utils/html-utils'],
|
||||
function($, _, gettext, BaseView, ViewUtils, AddXBlockButton, AddXBlockMenu, HtmlUtils) {
|
||||
'use strict';
|
||||
var AddXBlockComponent = BaseView.extend({
|
||||
events: {
|
||||
'click .new-component .new-component-type .multiple-templates': 'showComponentTemplates',
|
||||
@@ -19,9 +21,10 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview', 'common/js/compo
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var that;
|
||||
if (!this.$el.html()) {
|
||||
var that = this;
|
||||
this.$el.html(this.template({}));
|
||||
that = this;
|
||||
this.$el.html(HtmlUtils.HTML(this.template({})).toString());
|
||||
this.collection.each(
|
||||
function(componentModel) {
|
||||
var view, menu;
|
||||
@@ -47,6 +50,7 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview', 'common/js/compo
|
||||
},
|
||||
|
||||
closeNewComponent: function(event) {
|
||||
var type;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
type = $(event.currentTarget).data('type');
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
define(['js/views/baseview'],
|
||||
function(BaseView) {
|
||||
define(['js/views/baseview', 'edx-ui-toolkit/js/utils/html-utils'],
|
||||
function(BaseView, HtmlUtils) {
|
||||
'use strict';
|
||||
return BaseView.extend({
|
||||
tagName: 'li',
|
||||
initialize: function() {
|
||||
var attributes = {
|
||||
type: this.model.type,
|
||||
templates: this.model.templates,
|
||||
display_name: this.model.display_name
|
||||
};
|
||||
BaseView.prototype.initialize.call(this);
|
||||
this.template = this.loadTemplate('add-xblock-component-button');
|
||||
this.$el.html(
|
||||
this.template({
|
||||
type: this.model.type,
|
||||
templates: this.model.templates,
|
||||
display_name: this.model.display_name
|
||||
})
|
||||
this.$el.html(HtmlUtils.HTML(this.template(attributes)).toString()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils', 'common/js/components/utils/view_utils'],
|
||||
function(domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {
|
||||
define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils',
|
||||
'common/js/components/utils/view_utils', 'edx-ui-toolkit/js/utils/html-utils'],
|
||||
function(domReady, $, _, CreateCourseUtilsFactory, ViewUtils, HtmlUtils) {
|
||||
'use strict';
|
||||
var CreateCourseUtils = new CreateCourseUtilsFactory({
|
||||
name: '.rerun-course-name',
|
||||
org: '.rerun-course-org',
|
||||
@@ -20,6 +22,7 @@ define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils'
|
||||
});
|
||||
|
||||
var saveRerunCourse = function(e) {
|
||||
var courseInfo;
|
||||
e.preventDefault();
|
||||
|
||||
if (CreateCourseUtils.hasInvalidRequiredFields()) {
|
||||
@@ -32,7 +35,7 @@ define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils'
|
||||
var number = $newCourseForm.find('.rerun-course-number').val();
|
||||
var run = $newCourseForm.find('.rerun-course-run').val();
|
||||
|
||||
course_info = {
|
||||
courseInfo = {
|
||||
source_course_key: source_course_key,
|
||||
org: org,
|
||||
number: number,
|
||||
@@ -40,18 +43,20 @@ define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils'
|
||||
run: run
|
||||
};
|
||||
|
||||
analytics.track('Reran a Course', course_info);
|
||||
CreateCourseUtils.create(course_info, function(errorMessage) {
|
||||
analytics.track('Reran a Course', courseInfo); // eslint-disable-line no-undef
|
||||
CreateCourseUtils.create(courseInfo, function(errorMessage) {
|
||||
$('.wrapper-error').addClass('is-shown').removeClass('is-hidden');
|
||||
$('#course_rerun_error').html('<p>' + errorMessage + '</p>');
|
||||
$('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).removeClass('is-processing').html(gettext('Create Re-run'));
|
||||
$('#course_rerun_error').html(HtmlUtils.joinHtml(HtmlUtils.HTML('<p>'), errorMessage, HtmlUtils.HTML('</p>')).toString()); // eslint-disable-line max-len
|
||||
$('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true)
|
||||
.removeClass('is-processing')
|
||||
.text(gettext('Create Re-run'));
|
||||
$('.action-cancel').removeClass('is-hidden');
|
||||
});
|
||||
|
||||
// Go into creating re-run state
|
||||
$('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).addClass('is-processing').html(
|
||||
'<span class="icon fa fa-refresh fa-spin" aria-hidden="true"></span>' + gettext('Processing Re-run Request') // eslint-disable-line max-len
|
||||
);
|
||||
$('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true)
|
||||
.addClass('is-processing')
|
||||
.html(HtmlUtils.joinHtml(HtmlUtils.HTML('<span class="icon fa fa-refresh fa-spin" aria-hidden="true"></span>'), gettext('Processing Re-run Request')).toString()); // eslint-disable-line max-len
|
||||
$('.action-cancel').addClass('is-hidden');
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ define([
|
||||
'gettext',
|
||||
'js/utils/templates',
|
||||
'js/models/uploads',
|
||||
'js/views/uploads'
|
||||
'js/views/uploads',
|
||||
'edx-ui-toolkit/js/utils/html-utils'
|
||||
],
|
||||
function($, _, Backbone, gettext, TemplateUtils, FileUploadModel, FileUploadDialog) {
|
||||
function($, _, Backbone, gettext, TemplateUtils, FileUploadModel, FileUploadDialog, HtmlUtils) {
|
||||
'use strict';
|
||||
var InstructorInfoView = Backbone.View.extend({
|
||||
|
||||
@@ -31,14 +32,16 @@ define([
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var attributes;
|
||||
// Assemble the render view for this model.
|
||||
$('.course-instructor-details-fields').empty();
|
||||
var self = this;
|
||||
$.each(this.model.get('instructor_info').instructors, function(index, data) {
|
||||
$(self.el).append(self.template({
|
||||
attributes = {
|
||||
data: data,
|
||||
index: index
|
||||
}));
|
||||
};
|
||||
$(self.el).append(HtmlUtils.HTML(self.template(attributes)).toString());
|
||||
});
|
||||
|
||||
// Avoid showing broken image on mistyped/nonexistent image
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
* saved by this view. Note this may be a parent model.
|
||||
*/
|
||||
define([
|
||||
'js/views/baseview', 'common/js/components/utils/view_utils', 'underscore', 'gettext'
|
||||
], function(BaseView, ViewUtils, _, gettext) {
|
||||
'js/views/baseview', 'common/js/components/utils/view_utils', 'underscore', 'gettext',
|
||||
'edx-ui-toolkit/js/utils/html-utils'
|
||||
], function(BaseView, ViewUtils, _, gettext, HtmlUtils) {
|
||||
'use strict';
|
||||
|
||||
var ListItemEditorView = BaseView.extend({
|
||||
@@ -21,9 +22,11 @@ define([
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(_.extend({
|
||||
var template = this.template(_.extend({
|
||||
error: this.model.validationError || this.getSaveableModel().validationError
|
||||
}, this.getTemplateOptions())));
|
||||
}, this.getTemplateOptions())
|
||||
);
|
||||
this.$el.html(HtmlUtils.HTML(template).toString());
|
||||
},
|
||||
|
||||
setAndClose: function(event) {
|
||||
|
||||
@@ -127,17 +127,20 @@ function($, _, HtmlUtils, TranscriptUtils, AbstractEditor, ViewUtils, FileUpload
|
||||
languageMap = TranscriptUtils.Storage.get('languageMap');
|
||||
|
||||
_.each(values, function(value, newLang) {
|
||||
var html = $(self.templateItem({
|
||||
var $html = $(self.templateItem({
|
||||
newLang: newLang,
|
||||
originalLang: _.findKey(languageMap, function(lang) { return lang === newLang; }) || '',
|
||||
value: value,
|
||||
url: self.model.get('urlRoot')
|
||||
})).prepend(dropdown.clone().val(newLang))[0];
|
||||
|
||||
frag.appendChild(html);
|
||||
}));
|
||||
HtmlUtils.append($html, dropdown.clone().val(newLang));
|
||||
frag.appendChild($html[0]);
|
||||
});
|
||||
|
||||
this.$el.find('ol').html([frag]);
|
||||
HtmlUtils.setHtml(
|
||||
this.$el.find('ol'),
|
||||
HtmlUtils.HTML([frag])
|
||||
);
|
||||
},
|
||||
|
||||
addEntry: function(event) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
define(['jquery', 'underscore', 'js/views/baseview', 'gettext'],
|
||||
function($, _, BaseView, gettext) {
|
||||
define(['jquery', 'underscore', 'js/views/baseview', 'gettext', 'edx-ui-toolkit/js/utils/html-utils'],
|
||||
function($, _, BaseView, gettext, HtmlUtils) {
|
||||
'use strict';
|
||||
/**
|
||||
* View for xblock validation messages as displayed in Studio.
|
||||
*/
|
||||
@@ -13,12 +14,13 @@ define(['jquery', 'underscore', 'js/views/baseview', 'gettext'],
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template({
|
||||
var attributes = {
|
||||
validation: this.model,
|
||||
additionalClasses: this.getAdditionalClasses(),
|
||||
getIcon: this.getIcon.bind(this),
|
||||
getDisplayName: this.getDisplayName.bind(this)
|
||||
}));
|
||||
};
|
||||
this.$el.html(HtmlUtils.HTML(this.template(attributes)).toString());
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user