feat: reimagine certificate display settings The course settings `certificate_available_date` (CAD) and `certificates_display_behavior` (CDB) were previously acting indedependantly of one another. They now work in tandem. This change: - limits CDB to a dropdown - removes "early_with_info" and adds "end_with_date" - only takes CAD into account if "end_with_date" is selected - Moves CDB to the main course schedule settings page - updates CourseOverview model and CourseDetails objects to validate these fields and choose sane defaults if they aren't expected values This work was previously done in bd9e7dd (complete with bugs), so this version is toggleable via the ENABLE_V2_CERT_DISPLAY_SETTINGS setting
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
define([
|
|
'jquery', 'js/models/settings/course_details', 'js/views/settings/main'
|
|
], function($, CourseDetailsModel, MainView) {
|
|
'use strict';
|
|
return function(detailsUrl, showMinGradeWarning, showCertificateAvailableDate, upgradeDeadline, useV2CertDisplaySettings) {
|
|
var model;
|
|
// highlighting labels when fields are focused in
|
|
$('form :input')
|
|
.focus(function() {
|
|
$('label[for="' + this.id + '"]').addClass('is-focused');
|
|
})
|
|
.blur(function() {
|
|
$('label').removeClass('is-focused');
|
|
});
|
|
|
|
// Toggle collapsibles when trigger is clicked
|
|
$(".collapsible .collapsible-trigger").click(function() {
|
|
const contentId = this.id.replace("-trigger", "-content")
|
|
$(`#${contentId}`).toggleClass("collapsed")
|
|
})
|
|
|
|
model = new CourseDetailsModel();
|
|
model.urlRoot = detailsUrl;
|
|
model.showCertificateAvailableDate = showCertificateAvailableDate;
|
|
model.useV2CertDisplaySettings = useV2CertDisplaySettings;
|
|
model.set('upgrade_deadline', upgradeDeadline);
|
|
model.fetch({
|
|
success: function(model) {
|
|
var editor = new MainView({
|
|
el: $('.settings-details'),
|
|
model: model,
|
|
showMinGradeWarning: showMinGradeWarning
|
|
});
|
|
editor.useV2CertDisplaySettings = useV2CertDisplaySettings;
|
|
editor.render();
|
|
},
|
|
reset: true
|
|
});
|
|
};
|
|
});
|