From d73b41f578288204f3d471e2a81daea2efb24519 Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 15 Jul 2020 16:12:42 +0500 Subject: [PATCH 1/7] PROD-1605 --- cms/static/js/views/components/add_xblock.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cms/static/js/views/components/add_xblock.js b/cms/static/js/views/components/add_xblock.js index 8da194ce49..1479c07563 100644 --- a/cms/static/js/views/components/add_xblock.js +++ b/cms/static/js/views/components/add_xblock.js @@ -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'); From 4d0c4912592ec7e752ccdf99cdbba0b276c16f85 Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 15 Jul 2020 16:13:52 +0500 Subject: [PATCH 2/7] PROD-1612 --- .../js/views/components/add_xblock_button.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cms/static/js/views/components/add_xblock_button.js b/cms/static/js/views/components/add_xblock_button.js index aba7bd91b9..e0c4cc522d 100644 --- a/cms/static/js/views/components/add_xblock_button.js +++ b/cms/static/js/views/components/add_xblock_button.js @@ -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() ); } }); From 8876e7bf25aa8974fc0596cfe225c03367340ab1 Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 15 Jul 2020 16:14:19 +0500 Subject: [PATCH 3/7] PROD-1603 --- cms/static/js/views/xblock_validation.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cms/static/js/views/xblock_validation.js b/cms/static/js/views/xblock_validation.js index e675b3e80f..437d7ecc05 100644 --- a/cms/static/js/views/xblock_validation.js +++ b/cms/static/js/views/xblock_validation.js @@ -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; }, From a9cf0d84acad13569990218feb4341b76f0fab0f Mon Sep 17 00:00:00 2001 From: SaadYousaf Date: Mon, 20 Jul 2020 15:45:27 +0500 Subject: [PATCH 4/7] PROD-1619 --- cms/static/js/views/video/translations_editor.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cms/static/js/views/video/translations_editor.js b/cms/static/js/views/video/translations_editor.js index 9c82afa180..9570cd3ad9 100644 --- a/cms/static/js/views/video/translations_editor.js +++ b/cms/static/js/views/video/translations_editor.js @@ -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) { From 6905f64aa359fac517878d1b4c3f5bc83834db92 Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 22 Jul 2020 13:12:07 +0500 Subject: [PATCH 5/7] PROD-1289 --- cms/static/js/views/course_rerun.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cms/static/js/views/course_rerun.js b/cms/static/js/views/course_rerun.js index ad90449352..f311ae1037 100644 --- a/cms/static/js/views/course_rerun.js +++ b/cms/static/js/views/course_rerun.js @@ -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('

' + errorMessage + '

'); - $('.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('

'), errorMessage, HtmlUtils.HTML('

')).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( - '' + 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(''), gettext('Processing Re-run Request')).toString()); // eslint-disable-line max-len $('.action-cancel').addClass('is-hidden'); }; From 8f12875e4a19771cf3cd463cbe3b1b9d6bbc585c Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 22 Jul 2020 15:04:58 +0500 Subject: [PATCH 6/7] PROD-1530 --- cms/static/js/views/list_item_editor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cms/static/js/views/list_item_editor.js b/cms/static/js/views/list_item_editor.js index 4fae99dcf9..3332117789 100644 --- a/cms/static/js/views/list_item_editor.js +++ b/cms/static/js/views/list_item_editor.js @@ -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) { From ff2bf588eb7f18e2798871677e14b0119673d727 Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Wed, 22 Jul 2020 17:10:13 +0500 Subject: [PATCH 7/7] PROD-1525 --- cms/static/js/views/instructor_info.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cms/static/js/views/instructor_info.js b/cms/static/js/views/instructor_info.js index 2c13b029bb..8942569c27 100644 --- a/cms/static/js/views/instructor_info.js +++ b/cms/static/js/views/instructor_info.js @@ -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