only allow comments on submissions, not on templates

This commit is contained in:
Ralf Teusner
2015-06-26 18:25:03 +02:00
parent 283bfb38d6
commit a49ffc978b
2 changed files with 12 additions and 5 deletions

View File

@ -125,13 +125,19 @@ $(function() {
};
var createSubmissionCallback = function(data){
// update the ids of the editors and reload the annotations
for (var i = 0; i < editors.length; i++) {
// set the data attribute to submission
$(editors[i].container).data('context-type', 'Submission');
var file_id_old = $(editors[i].container).data('file-id');
// file_id_old is always set. Either it is a reference to a teacher supplied given file, or it is the actual id of a new user created file.
// I am not sure why the latter happens, but therefore the else part is not needed any longer...
// This is the case, since it is set via a call to ancestor_id on the model, which returns either file_id if set, or id if it is not set.
// therefore the else part is not needed any longer...
// if we have an file_id set (the file is a copy of a teacher supplied given file)
if (file_id_old != null){
// if we find file_id_old (this is the reference to the base file) in the submission, this is the match
@ -361,12 +367,13 @@ $(function() {
session.on('annotationRemoval', handleAnnotationRemoval);
session.on('annotationChange', handleAnnotationChange);
// TODO refactor here
// TODO: only show modal dialog when the file is part of a submission (and not the template)
// TODO refactor here, put this in its own function
// Code for clicks on gutter / sidepanel
editor.on("guttermousedown", function(e){
var target = e.domEvent.target;
// only allow comments on submissions, not on the template
if ($(editor.container).data('context-type') != 'Submission') return;
if (target.className.indexOf("ace_gutter-cell") == -1) return;
if (!editor.isFocused()) return;
if (e.clientX > 25 + target.getBoundingClientRect().left) return;

View File

@ -12,4 +12,4 @@
= link_to(file.native_file.file.name_with_extension, file.native_file.url)
- else
.editor-content.hidden data-file-id=file.ancestor_id = file.content
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id data-context-type=file.context_type