Show html formatted comments in modal

This commit is contained in:
Maximilian Grundke
2017-08-23 18:38:24 +02:00
parent b9646b4857
commit a8d801d3a7
2 changed files with 12 additions and 12 deletions

View File

@ -71,7 +71,8 @@ p.comment {
} }
.container { .container {
min-height: 300px; width: 100%;
max-height: 300px;
overflow-y: auto; overflow-y: auto;
} }
} }

View File

@ -137,7 +137,7 @@ also, all settings from the rails model needed for the editor configuration in t
currentEditor.getSession().setMode($(editor).data('mode')); currentEditor.getSession().setMode($(editor).data('mode'));
currentEditor.getSession().setOption("useWorker", false); currentEditor.getSession().setOption("useWorker", false);
currentEditor.annotationsByLine = {}; currentEditor.commentVisualsByLine = {};
setAnnotations(currentEditor, $(editor).data('file-id')); setAnnotations(currentEditor, $(editor).data('file-id'));
currentEditor.on("guttermousedown", handleSidebarClick); currentEditor.on("guttermousedown", handleSidebarClick);
}); });
@ -226,13 +226,13 @@ also, all settings from the rails model needed for the editor configuration in t
}); });
jqrequest.done(function(response){ jqrequest.done(function(response){
editor.annotationsByLine = clusterComments(response.slice()); editor.commentVisualsByLine = {};
for (var line in editor.annotationsByLine) { var clusters = clusterComments(response.slice());
if (editor.annotationsByLine.hasOwnProperty(line)) { $.each(clusters, function (line, cluster) {
var htmlContent = generateCommentHtmlContent(editor.annotationsByLine[line]); var htmlContent = generateCommentHtmlContent(cluster);
buildPopover(fileid, line, htmlContent); editor.commentVisualsByLine[line] = htmlContent;
} buildPopover(fileid, line, htmlContent);
} });
$.each(response, function(index, comment) { $.each(response, function(index, comment) {
comment.className = 'code-ocean_comment'; comment.className = 'code-ocean_comment';
@ -302,10 +302,9 @@ also, all settings from the rails model needed for the editor configuration in t
var commentModal = $('#comment-modal'); var commentModal = $('#comment-modal');
if (hasCommentsInRow(editor, row)) { if (hasCommentsInRow(editor, row)) {
var rowComments = getCommentsForRow(editor, row); var htmlContent = editor.commentVisualsByLine[row];
var comments = _.pluck(rowComments, 'text').join('\n');
commentModal.find('#otherComments').show(); commentModal.find('#otherComments').show();
commentModal.find('#otherCommentsTextfield').text(comments); commentModal.find('#otherComments > .container').html(htmlContent);
} else { } else {
commentModal.find('#otherComments').hide(); commentModal.find('#otherComments').hide();
} }