add unpublished to views
This commit is contained in:
@ -208,6 +208,35 @@ $(document).on('turbolinks:load', function() {
|
||||
}
|
||||
});
|
||||
};
|
||||
var old_execution_environment = $('#exercise_execution_environment_id').val();
|
||||
var observeExecutionEnvironment = function() {
|
||||
$('#exercise_execution_environment_id').on('change', function(){
|
||||
new_execution_environment = $('#exercise_execution_environment_id').val();
|
||||
|
||||
if(new_execution_environment == '' && !$('#exercise_unpublished').prop('checked')){
|
||||
if(confirm('<%= I18n.t('exercises.form.unpublish_warning') %>')){
|
||||
$('#exercise_unpublished').prop('checked', true);
|
||||
} else {
|
||||
return $('#exercise_execution_environment_id').val(old_execution_environment).trigger("chosen:updated");
|
||||
}
|
||||
}
|
||||
old_execution_environment = new_execution_environment;
|
||||
});
|
||||
};
|
||||
|
||||
var observeUnpublishedState = function() {
|
||||
$('#exercise_unpublished').on('change', function(){
|
||||
if($('#exercise_unpublished').prop('checked')){
|
||||
if(!confirm('<%= I18n.t('exercises.form.unpublish_warning') %>')){
|
||||
$('#exercise_unpublished').prop('checked', false);
|
||||
}
|
||||
} else if($('#exercise_execution_environment_id').val() == '') {
|
||||
alert('<%= I18n.t('exercises.form.no_execution_environment_selected') %>');
|
||||
$('#exercise_unpublished').prop('checked', true);
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
var overrideTextareaTabBehavior = function() {
|
||||
$('.form-group textarea[name$="[content]"]').on('keydown', function(event) {
|
||||
@ -271,6 +300,8 @@ $(document).on('turbolinks:load', function() {
|
||||
enableInlineFileCreation();
|
||||
inferFileAttributes();
|
||||
observeFileRoleChanges();
|
||||
observeExecutionEnvironment();
|
||||
observeUnpublishedState();
|
||||
overrideTextareaTabBehavior();
|
||||
} else if ($('#files.jstree').isPresent()) {
|
||||
var fileTypeSelect = $('#code_ocean_file_file_type_id');
|
||||
|
Reference in New Issue
Block a user