diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 541bde0..51f76b2 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -20,7 +20,7 @@ authorize @answer if @answer.save - @timestamp = Time.now.iso8601 + @timestamp = @answer.updated_at.iso8601 end @lock_version = @answer.lock_version elsif params[:answer][:id].blank? # Someone else already added an answer while the user was working diff --git a/app/views/answers/_status.html.erb b/app/views/answers/_status.html.erb new file mode 100644 index 0000000..e1c8d8b --- /dev/null +++ b/app/views/answers/_status.html.erb @@ -0,0 +1,9 @@ + + + +
+ <% if answer.updated_at.blank? %> + <%= _('Not answered yet') %> + <% else %> + <%= _('Answered')%> <%= answer.updated_at.iso8601 %><%= _(' by')%> <%= answer.user.name %> + <% end %> \ No newline at end of file diff --git a/app/views/answers/update.js.erb b/app/views/answers/update.js.erb index 8086893..ec06441 100644 --- a/app/views/answers/update.js.erb +++ b/app/views/answers/update.js.erb @@ -3,10 +3,6 @@ // On success this will be "" on error it will be the // conflicting answer -// go back from "Saving..." message to "Save" button -$("#saving-<%=@question.id%>").hide(); -$("#saving-<%=@question.id%>").prev().show(); - <% if @old_answer %> $("#answer_notice_<%=@question.id%>").html("<%= escape_javascript(render partial: '/phases/answer', locals: { question: @question, answer: @old_answer}) %>"); <% else %> @@ -21,20 +17,13 @@ $("#question-form-<%= @question.id %> #answer_id").val(<%= @answer.id %>); // update the answer status - -var q_status = $("#<%=@question.id%>-status"); -var timestamp = "<%= @timestamp.nil? ? "": @timestamp %>"; - -if( timestamp != "") { - q_status.text(""); - q_status.append("<%= _('Answered') %> \" title=\"<%=@timestamp%>\"><%=@timestamp%> <%= _('by') %> <%=@username%>"); - $('abbr.timeago').timeago(); -} - +$("#answer-status-<%= @question.id %>") + .html("<%= escape_javascript(render partial: '/answers/status', locals: { question_id: @question.id, answer: @answer}) %>"); +if($.fn.init_answer_status) + $.fn.init_answer_status(); // update plan progress bar $(".progress").html("<%= escape_javascript(render :partial => '/plans/progress', locals: {nquestions: @nquestions, nanswers: @nanswers}) %>"); - // update the section progress message $("#<%=@section_id%>-status").html("(<%=@n_section_questions%> <%= _('questions') %>, <%=@n_section_answers%> <%= _('answered') %>)") diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb index abee475..9a252b7 100644 --- a/app/views/phases/_answer_form.html.erb +++ b/app/views/phases/_answer_form.html.erb @@ -117,20 +117,12 @@ <% if !readonly %> <% end %> - - - - - +
"> + <%= render(partial: 'answers/status', locals: { question_id: question_id, answer: answer }) %> +
<% end %> - - <% if answer.nil? || !answer.text.present? %> - <%= _('Not answered yet') %> - <% else %> - <%= _('Answered')%> <%= answer.updated_at.iso8601 %><%= _(' by')%> <%= answer.user.name %> - <% end %> diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index 8310dce..9c73d91 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -1,6 +1,6 @@ <%- model_class = Plan -%> <% javascript "plans.js" %> - +<% javascript "answers/status.js" %>