Files
edx-platform/cms/static/js/views/course_video_sharing_enable.js
Syed Ali Abbas Zaidi d7053a6783 fix: eslint autofixable issues (#32181)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* fix: failing js test
2023-05-18 11:03:59 +05:00

68 lines
2.0 KiB
JavaScript

define([
'jquery',
'underscore',
'backbone',
'js/views/utils/xblock_utils',
'js/utils/templates',
'js/views/modals/course_outline_modals',
'edx-ui-toolkit/js/utils/html-utils',
], function($, _, Backbone, XBlockViewUtils, TemplateUtils, CourseOutlineModalsFactory, HtmlUtils) {
'use strict';
var CourseVideoSharingEnableView = Backbone.View.extend({
events: {
'change #video-sharing-configuration-options': 'handleVideoSharingConfigurationChange',
},
initialize: function() {
this.template = TemplateUtils.loadTemplate('course-video-sharing-enable');
},
getRequestData: function(value) {
return {
metadata: {
video_sharing_options: value,
},
};
},
handleVideoSharingConfigurationChange: function(event) {
if (event.type === 'change') {
event.preventDefault();
this.updateVideoSharingConfiguration(event.target.value);
this.trackVideoSharingConfigurationChange(event.target.value);
}
},
updateVideoSharingConfiguration: function(value) {
XBlockViewUtils.updateXBlockFields(this.model, this.getRequestData(value), {
success: this.refresh.bind(this)
});
},
trackVideoSharingConfigurationChange: function(value) {
window.analytics.track(
'edx.social.video_sharing_options.changed',
{
course_id: this.model.id,
video_sharing_options: value
}
);
},
refresh: function() {
this.model.fetch({
success: this.render.bind(this),
});
},
render: function() {
var html = this.template(this.model.attributes);
HtmlUtils.setHtml(this.$el, HtmlUtils.HTML(html));
return this;
},
});
return CourseVideoSharingEnableView;
});