From a8d801d3a74e411152cb12b500646834ce8a2057 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 23 Aug 2017 18:38:24 +0200 Subject: [PATCH] Show html formatted comments in modal --- .../stylesheets/request-for-comments.css.scss | 3 ++- app/views/request_for_comments/show.html.erb | 21 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/request-for-comments.css.scss b/app/assets/stylesheets/request-for-comments.css.scss index 562c02f4..08b02839 100644 --- a/app/assets/stylesheets/request-for-comments.css.scss +++ b/app/assets/stylesheets/request-for-comments.css.scss @@ -71,7 +71,8 @@ p.comment { } .container { - min-height: 300px; + width: 100%; + max-height: 300px; overflow-y: auto; } } diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index 92892b04..b93f7594 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -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().setOption("useWorker", false); - currentEditor.annotationsByLine = {}; + currentEditor.commentVisualsByLine = {}; setAnnotations(currentEditor, $(editor).data('file-id')); 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){ - editor.annotationsByLine = clusterComments(response.slice()); - for (var line in editor.annotationsByLine) { - if (editor.annotationsByLine.hasOwnProperty(line)) { - var htmlContent = generateCommentHtmlContent(editor.annotationsByLine[line]); - buildPopover(fileid, line, htmlContent); - } - } + editor.commentVisualsByLine = {}; + var clusters = clusterComments(response.slice()); + $.each(clusters, function (line, cluster) { + var htmlContent = generateCommentHtmlContent(cluster); + editor.commentVisualsByLine[line] = htmlContent; + buildPopover(fileid, line, htmlContent); + }); $.each(response, function(index, 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'); if (hasCommentsInRow(editor, row)) { - var rowComments = getCommentsForRow(editor, row); - var comments = _.pluck(rowComments, 'text').join('\n'); + var htmlContent = editor.commentVisualsByLine[row]; commentModal.find('#otherComments').show(); - commentModal.find('#otherCommentsTextfield').text(comments); + commentModal.find('#otherComments > .container').html(htmlContent); } else { commentModal.find('#otherComments').hide(); }