From 4fa8f811cfe83c884b0e261caff83ffbe69596e1 Mon Sep 17 00:00:00 2001 From: Felix Wolff Date: Tue, 5 May 2015 11:23:31 +0200 Subject: [PATCH 1/2] internationalization and feedback for RFC button --- app/assets/javascripts/editor.js | 9 +++++++-- app/views/exercises/_editor_file_tree.html.slim | 2 +- config/locales/de.yml | 1 + config/locales/en.yml | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 09c23bba..42fc28b0 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -928,14 +928,19 @@ $(function() { requestorid: user_id, exerciseid: exercise_id, fileid: file_id, - "requested_at(1i)": 2015, - "requested_at(2i)":3, + "requested_at(1i)": 2015, // these are the timestamp values that the request handler demands + "requested_at(2i)":3, // they could be random here, because the timestamp is updated on serverside anyway "requested_at(3i)":27, "requested_at(4i)":17, "requested_at(5i)":06 } } + }).done(function() { + hideSpinner() + $.flash.success({ text: 'Request for comments sent!' }) }) + + showSpinner($('#request-for-comments')) } var initializeCodePilot = function() { diff --git a/app/views/exercises/_editor_file_tree.html.slim b/app/views/exercises/_editor_file_tree.html.slim index 36ba8c37..9ed5626d 100644 --- a/app/views/exercises/_editor_file_tree.html.slim +++ b/app/views/exercises/_editor_file_tree.html.slim @@ -5,6 +5,6 @@ hr = render('editor_button', classes: 'btn-block btn-primary btn-sm', data: {:'data-cause' => 'file'}, icon: 'fa fa-plus', id: 'create-file', label: t('exercises.editor.create_file')) = render('editor_button', classes: 'btn-block btn-warning btn-sm', data: {:'data-cause' => 'file', :'data-message-confirm' => t('shared.confirm_destroy')}, icon: 'fa fa-times', id: 'destroy-file', label: t('exercises.editor.destroy_file')) = render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-download', id: 'download', label: t('exercises.editor.download')) -= render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-bullhorn', id: 'request-for-comments', label: 'Request comments') += render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-bullhorn', id: 'request-for-comments', label: t('exercises.editor.requestComments')) = render('shared/modal', id: 'modal-file', template: 'code_ocean/files/_form', title: t('exercises.editor.create_file')) diff --git a/config/locales/de.yml b/config/locales/de.yml index fa725fde..028d9318 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -174,6 +174,7 @@ de: run: Ausführen run_failure: Bei der Ausführung Ihres Codes sind Fehler aufgetreten. run_success: Ihr Code wurde fehlerfrei ausgeführt. + requestComments: Rückmeldung erbitten save: Speichern score: Bewerten start_over: Von vorne anfangen diff --git a/config/locales/en.yml b/config/locales/en.yml index 64cd0eda..1c3f4b96 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -174,6 +174,7 @@ en: run: Run run_failure: Your code ran with errors. run_success: Your code ran without errors. + requestComments: Request comments save: Save score: Score start_over: Start over From 5d767d3de0b054b97ec0f0d8780c5b7ec8b5e965 Mon Sep 17 00:00:00 2001 From: Felix Wolff Date: Tue, 5 May 2015 13:52:53 +0200 Subject: [PATCH 2/2] Comment code via popovers --- app/views/request_for_comments/index.html.erb | 2 +- app/views/request_for_comments/show.html.erb | 64 ++++++++++++------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/app/views/request_for_comments/index.html.erb b/app/views/request_for_comments/index.html.erb index 865f0bca..311be4b5 100644 --- a/app/views/request_for_comments/index.html.erb +++ b/app/views/request_for_comments/index.html.erb @@ -9,4 +9,4 @@

<% end %> - + \ No newline at end of file diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index 44ea1d13..d9779583 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -4,18 +4,8 @@ <%= InternalUser.find(@request_for_comment.requestorid) %> | <%= @request_for_comment.requested_at %>

- -
-
-

<%= t('exercises.implement.comment.line') %>

- -
-
-

<%= t('exercises.implement.comment.a_comment') %>

- -
- -
+
<%= CodeOcean::File.find(@request_for_comment.fileid).content %> @@ -26,12 +16,24 @@ var commentitor = $('#commentitor'); var userid = commentitor.data('user-id'); var fileid = commentitor.data('file-id'); - var lineInput = $('#lineInput'); - var commentInput = $('#commentInput'); + + var inputHtml = '' + //inputHtml += '
' + //inputHtml += '
' + //inputHtml += '

<%= t("exercises.implement.comment.line") %>

' + //inputHtml += '' + //inputHtml += '
' + inputHtml += '
' + //inputHtml += '

<%= t("exercises.implement.comment.a_comment") %>

' + inputHtml += '' + inputHtml += '' + inputHtml += '
' + //inputHtml +='
' + + commentitor = ace.edit(commentitor[0]); commentitor.setReadOnly(true); - $('#submitComment').click(addComment); setAnnotations(); function setAnnotations() { @@ -47,18 +49,34 @@ }); jqrequest.done(function(response){ + //data-container=".ui-front" on gutter cell $.each(response, function(index, comment) { comment.className = "code-ocean_comment" comment.text = comment.username + ": " + comment.text }) commentitor.getSession().setAnnotations(response) + + //$('.ace_gutter-layer').data('container', '.ui-front') + $('.ace_gutter-cell').popover({ + title: 'Add a comment', + html: true, + content: inputHtml, + position: 'right', + trigger: 'focus click' + }).on('shown.bs.popover', function() { + $('#commentInput').focus() + $('#submitComment').click(addComment); + console.log($(this).text()) + $('#commentInput').data('line', $(this).text()) + }) }) } function addComment() { - var line = lineInput.val() + var commentInput = $('#commentInput'); var comment = commentInput.val() + var line = $('#commentInput').data('line') if (line == '' || comment == '') { return @@ -66,8 +84,7 @@ line = parseInt(line) - 1 } - - var jqxhr = $.ajax({ + $.ajax({ data: { comment: { user_id: userid, @@ -80,10 +97,13 @@ dataType: 'json', method: 'POST', url: "/comments" - }) + }).done(setAnnotations) - jqxhr.done(setAnnotations) - lineInput.val(''); commentInput.val(''); + $('.ace_gutter-cell').popover('hide') } //})() - \ No newline at end of file + + \ No newline at end of file