diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
deleted file mode 100644
index 87838cb..0000000
--- a/app/controllers/comments_controller.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-class CommentsController < ApplicationController
- after_action :verify_authorized
-
- # POST /comments
- def create
- @comment = Comment.new(params[:new_comment])
- @comment.text = params["#{params[:new_comment][:question_id]}new_comment_text"]
- @comment.question_id = params[:new_comment][:question_id]
- @comment.user_id = params[:new_comment][:user_id]
- @comment.plan_id = params[:new_comment][:plan_id]
- authorize @comment
-
- @plan = Plan.find(@comment.plan_id)
- @project = Project.find(@plan.project_id)
-
- respond_to do |format|
- if @comment.save
- session[:question_id_comments] = @comment.question_id
- format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_created") }
- end
- end
- end
-
- # PUT /comments/1
- def update
- @comment = Comment.find(params[:comment][:id])
- authorize @comment
- @comment.text = params["#{params[:comment][:id]}_comment_text"]
-
- @plan = Plan.find(@comment.plan_id)
- @project = Project.find(@plan.project_id)
-
- respond_to do |format|
- if @comment.update_attributes(params[:comment])
- session[:question_id_comments] = @comment.question_id
- format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_updated") }
- end
- end
- end
-
- # ARCHIVE /comments/1
- # ARCHIVE /comments/1.json
- def archive
- @comment = Comment.find(params[:comment][:id])
- authorize @comment
- @comment.archived = true
- @comment.archived_by = params[:comment][:archived_by]
-
- @plan = Plan.find(@comment.plan_id)
- @project = Project.find(@plan.project_id)
-
- respond_to do |format|
- if @comment.update_attributes(params[:comment])
- session[:question_id_comments] = @comment.question_id
- format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_removed") }
- end
- end
- end
-
-
-end
diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb
new file mode 100644
index 0000000..ec5253a
--- /dev/null
+++ b/app/controllers/notes_controller.rb
@@ -0,0 +1,60 @@
+class NotesController < ApplicationController
+ after_action :verify_authorized
+
+ # POST /notes
+ def create
+ @note = Note.new(params[:new_note])
+ @note.text = params["#{params[:new_note][:question_id]}new_note_text"]
+ @note.question_id = params[:new_note][:question_id]
+ @note.user_id = params[:new_note][:user_id]
+ @note.plan_id = params[:new_note][:plan_id]
+ authorize @note
+
+ @plan = Plan.find(@note.plan_id)
+ @project = Project.find(@plan.project_id)
+
+ respond_to do |format|
+ if @note.save
+ session[:question_id_notes] = @note.question_id
+ format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.note_created") }
+ end
+ end
+ end
+
+ # PUT /notes/1
+ def update
+ @note = Note.find(params[:note][:id])
+ authorize @note
+ @note.text = params["#{params[:note][:id]}_note_text"]
+
+ @plan = Plan.find(@note.plan_id)
+ @project = Project.find(@plan.project_id)
+
+ respond_to do |format|
+ if @note.update_attributes(params[:note])
+ session[:question_id_notes] = @note.question_id
+ format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.note_updated") }
+ end
+ end
+ end
+
+ # ARCHIVE /notes/1
+ def archive
+ @note = Note.find(params[:note][:id])
+ authorize @note
+ @note.archived = true
+ @note.archived_by = params[:note][:archived_by]
+
+ @plan = Plan.find(@note.plan_id)
+ @project = Project.find(@plan.project_id)
+
+ respond_to do |format|
+ if @note.update_attributes(params[:note])
+ session[:question_id_notes] = @note.question_id
+ format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.note_removed") }
+ end
+ end
+ end
+
+
+end
diff --git a/app/policies/comment_policy.rb b/app/policies/comment_policy.rb
deleted file mode 100644
index 570c0a1..0000000
--- a/app/policies/comment_policy.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class CommentPolicy < ApplicationPolicy
- attr_reader :user
- attr_reader :comment
-
- def initialize(user, comment)
- raise Pundit::NotAuthorizedError, "must be logged in" unless user
- @user = user
- @comment = comment
- end
-
- def create?
- Plan.find(@comment.plan_id).readable_by(@user.id)
- end
-
- def update?
- Plan.find(@comment.plan_id).readable_by(@user.id)
- end
-
- def archive?
- Plan.find(@comment.plan_id).readable_by(@user.id)
- end
-
-end
\ No newline at end of file
diff --git a/app/policies/note_policy.rb b/app/policies/note_policy.rb
new file mode 100644
index 0000000..49b9766
--- /dev/null
+++ b/app/policies/note_policy.rb
@@ -0,0 +1,23 @@
+class NotePolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :note
+
+ def initialize(user, comment)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @note = note
+ end
+
+ def create?
+ Plan.find(@note.plan_id).readable_by(@user.id)
+ end
+
+ def update?
+ Plan.find(@note.plan_id).readable_by(@user.id)
+ end
+
+ def archive?
+ Plan.find(@note.plan_id).readable_by(@user.id)
+ end
+
+end
\ No newline at end of file
diff --git a/app/views/plans/_add_comment.html.erb b/app/views/plans/_add_comment.html.erb
deleted file mode 100644
index 0d8aa49..0000000
--- a/app/views/plans/_add_comment.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-<% @new_comment = Comment.new %>
-
-<%= form_for :new_comment, :url => {:controller => :comments, :action => :create } , :html=>{:method=>:post, :id => "new_comment_form_#{questionId}", :class => "add_comment_form"} do |f| %>
- <%= f.hidden_field :user_id, :value => current_user.id %>
- <%= f.hidden_field :question_id, :value => questionId %>
- <%= f.hidden_field :plan_id, :value => planId %>
-
- <%= text_area_tag("#{questionId}new_comment_text".to_sym, "" , class: "tinymce") %>
-
- <% question = Question.find(questionId)%>
-
-
- <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %>
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary new_comment_submit_button" %>
-
-
-<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_add_note.html.erb b/app/views/plans/_add_note.html.erb
new file mode 100644
index 0000000..957e0ef
--- /dev/null
+++ b/app/views/plans/_add_note.html.erb
@@ -0,0 +1,20 @@
+
+
+<% @new_note = Note.new %>
+
+<%= form_for :new_note, :url => {:controller => :notes, :action => :create } , :html=>{:method=>:post, :id => "new_note_form_#{questionId}", :class => "add_note_form"} do |f| %>
+ <%= f.hidden_field :user_id, :value => current_user.id %>
+ <%= f.hidden_field :question_id, :value => questionId %>
+ <%= f.hidden_field :plan_id, :value => planId %>
+
+ <%= text_area_tag("#{questionId}new_note_text".to_sym, "" , class: "tinymce") %>
+
+ <% question = Question.find(questionId)%>
+
+
+ <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
+ <%= hidden_field_tag :question_id, question.id, :class => "question_id" %>
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary new_comment_submit_button" %>
+
+
+<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_archive_comment.html.erb b/app/views/plans/_archive_comment.html.erb
deleted file mode 100644
index 03ba05c..0000000
--- a/app/views/plans/_archive_comment.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-<%= form_for(comment, :url => {:controller => :comments, :action => :archive } , :html => { :method => :put, :class => "archive_comment_form", :id => "archive_comment_form_#{comment.id}"}) do |f| %>
- <%= f.hidden_field :id, :value => comment.id %>
- <%= f.hidden_field :archived_by, :value => current_user.id %>
-
- <%= render :partial => "view_comment", locals: {comment: comment} %>
-
- <% if current_user.id == comment.user_id then %>
- <%= t('helpers.comments.archive_own_comment_question')%>
- <% button_label = t("helpers.comments.archive_own_comment_button_label") %>
- <% else%>
- <%= t("helpers.comments.archive_comment_question")%>
- <% button_label = t("helpers.comments.archive_comment_button_label") %>
- <%end%>
-
-
-
- <% question = Question.find(comment.question_id)%>
- <%= hidden_field_tag :plan_id, comment.plan_id, :class => "plan_id" %>
- <%= hidden_field_tag :comment_id, comment.id, :class => "comment_id" %>
- <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
- <%= f.submit button_label, :class => "btn btn-primary archive_comment_submit_button" %>
- <%= hidden_field_tag :comment_id, comment.id, :class => "comment_id" %>
- <%= link_to t("helpers.submit.cancel"), "#", :class => "cancel_archive_comment btn cancel" %>
-
-
-<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_archive_note.html.erb b/app/views/plans/_archive_note.html.erb
new file mode 100644
index 0000000..a101e30
--- /dev/null
+++ b/app/views/plans/_archive_note.html.erb
@@ -0,0 +1,28 @@
+
+
+<%= form_for(note, :url => {:controller => :notes, :action => :archive } , :html => { :method => :put, :class => "archive_note_form", :id => "archive_note_form_#{note.id}"}) do |f| %>
+ <%= f.hidden_field :id, :value => note.id %>
+ <%= f.hidden_field :archived_by, :value => current_user.id %>
+
+ <%= render :partial => "view_note", locals: {note: note} %>
+
+ <% if current_user.id == note.user_id then %>
+ <%= t('helpers.notes.archive_own_note_question')%>
+ <% button_label = t("helpers.notes.archive_own_comment_button_label") %>
+ <% else%>
+ <%= t("helpers.notes.archive_note_question")%>
+ <% button_label = t("helpers.notes.archive_comment_button_label") %>
+ <%end%>
+
+
+
+ <% question = Question.find(note.question_id)%>
+ <%= hidden_field_tag :plan_id, note.plan_id, :class => "plan_id" %>
+ <%= hidden_field_tag :note_id, note.id, :class => "comment_id" %>
+ <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
+ <%= f.submit button_label, :class => "btn btn-primary archive_comment_submit_button" %>
+ <%= hidden_field_tag :note_id, note.id, :class => "comment_id" %>
+ <%= link_to t("helpers.submit.cancel"), "#", :class => "cancel_archive_comment btn cancel" %>
+
+
+<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_comments.html.erb b/app/views/plans/_comments.html.erb
deleted file mode 100644
index dc21608..0000000
--- a/app/views/plans/_comments.html.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-<% @comments = Comment.where("question_id = ? AND plan_id = ?", questionId, plan_id) %>
-<%= hidden_field_tag :question_id, questionId, :class => "question_id" %>
-
-<% if @comments.count > 0 then%>
-
-
-
-
-
- <%= render :partial => "list_comments", locals: {comments: @comments}%>
-
-
-
-
-
-
-
-
-
-<% else%>
- <%= t("helpers.comments.add_comment_text")%>
- <%= render :partial => "add_comment", locals: {questionId: questionId, planId: plan_id}%>
-<% end%>
diff --git a/app/views/plans/_edit_comment.html.erb b/app/views/plans/_edit_comment.html.erb
deleted file mode 100644
index 5ea6c8b..0000000
--- a/app/views/plans/_edit_comment.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-<%= form_for(comment, :url => {:controller => :comments, :action => :update } , :html => { :method => :put, :class => "edit_comment_form", :id=> "edit_comment_form_#{comment.id}"}) do |f| %>
- <%= f.hidden_field :id, :value => comment.id %>
-
- <%= text_area_tag("#{comment.id}_comment_text".to_sym, comment.text , class: "tinymce") %>
-
-
-
-
- <% question = Question.find(comment.question_id)%>
- <%= hidden_field_tag :plan_id, comment.plan_id, :class => "plan_id" %>
- <%= hidden_field_tag :comment_id, comment.id, :class => "comment_id" %>
- <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
- <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary edit_comment_submit_button" %>
-
-
-<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_edit_note.html.erb b/app/views/plans/_edit_note.html.erb
new file mode 100644
index 0000000..6294200
--- /dev/null
+++ b/app/views/plans/_edit_note.html.erb
@@ -0,0 +1,18 @@
+
+
+<%= form_for(note, :url => {:controller => :notes, :action => :update } , :html => { :method => :put, :class => "edit_note_form", :id=> "edit_note_form_#{note.id}"}) do |f| %>
+ <%= f.hidden_field :id, :value => note.id %>
+
+ <%= text_area_tag("#{note.id}_note_text".to_sym, note.text , class: "tinymce") %>
+
+
+
+
+ <% question = Question.find(note.question_id)%>
+ <%= hidden_field_tag :plan_id, note.plan_id, :class => "plan_id" %>
+ <%= hidden_field_tag :note_id, note.id, :class => "note_id" %>
+ <%= hidden_field_tag :section_id, question.section_id, :class => "section_id" %>
+ <%= f.submit t("helpers.submit.save"), :class => "btn btn-primary edit_note_submit_button" %>
+
+
+<%end%>
\ No newline at end of file
diff --git a/app/views/plans/_list_comments.html.erb b/app/views/plans/_list_comments.html.erb
deleted file mode 100644
index 84b9eef..0000000
--- a/app/views/plans/_list_comments.html.erb
+++ /dev/null
@@ -1,80 +0,0 @@
-
-<% if comments.count > 1 then%>
- <% style_to_add = "height:150px; overflow-y:auto;" %>
-<%else%>
- <% style_to_add = "" %>
-<%end%>
-
-
-
-
- <% comments.order("updated_at DESC").each do |c|%>
-
- |
- <% user = User.find(c.user_id) %>
- <%= user.name %>
- (<%= l c.updated_at, format: :custom %>)
- |
-
- <% if c.archived == true then %>
- <% if c.archived_by == current_user.id then%>
- <%= t("helpers.comments.retracted")%>
- <% else %>
- <% archived_by_user = User.find(c.archived_by) %>
- <%= t("helpers.comments.clear_by")%> <%= archived_by_user.name %>
- <%end%>
- <%else%>
- <%= link_to t("helpers.comments.view_label"),"#", :class => "dmp_table_link view_comment_button" %>
- <%= hidden_field_tag :comment_id, c.id, :class => "comment_id" %>
- <% if current_user.id == c.user_id then %>
- <%= link_to t("helpers.comments.edit_label"),"#", :class => "dmp_table_link edit_comment_button" %>
-
- <%= hidden_field_tag :comment_id, c.id, :class => "comment_id" %>
- <%= link_to t("helpers.comments.retract_label"),"#", :class => "dmp_table_link archive_comment_button" %>
- <% end%>
- <% project_id = Plan.find(c.plan_id).project_id%>
- <% if (Project.find(project_id).administerable_by(current_user.id) && current_user.id != c.user_id )then%>
- <%= hidden_field_tag :comment_id, c.id, :class => "comment_id" %>
- <%= link_to t("helpers.comments.clear_label"),"#", :class => "dmp_table_link archive_comment_button" %>
- <% end%>
- <%end%>
- |
-
-
- <%end%>
-
-
-
-
-
-
-
-<% comments_not_archived = comments.where("archived IS NULL") %>
-<% latest_comment = comments_not_archived.order("updated_at DESC").first %>
-<% if !latest_comment.nil? then%>
-
-<%end%>
-
-<%comments.order("updated_at DESC").each do |com|%>
-
-
-
-
-
-
-
-
-
- <%end%>
diff --git a/app/views/plans/_list_notes.html.erb b/app/views/plans/_list_notes.html.erb
new file mode 100644
index 0000000..10a16f0
--- /dev/null
+++ b/app/views/plans/_list_notes.html.erb
@@ -0,0 +1,79 @@
+
+<% if notes.count > 1 then%>
+ <% style_to_add = "height:150px; overflow-y:auto;" %>
+<%else%>
+ <% style_to_add = "" %>
+<%end%>
+
+
+
+
+ <% notes.order("updated_at DESC").each do |c|%>
+
+ |
+ <% user = User.find(c.user_id) %>
+ <%= user.name %>
+ (<%= l c.updated_at, format: :custom %>)
+ |
+
+ <% if c.archived == true then %>
+ <% if c.archived_by == current_user.id then%>
+ <%= t("helpers.comments.retracted")%>
+ <% else %>
+ <% archived_by_user = User.find(c.archived_by) %>
+ <%= t("helpers.comments.clear_by")%> <%= archived_by_user.name %>
+ <%end%>
+ <%else%>
+ <%= link_to t("helpers.comments.view_label"),"#", :class => "dmp_table_link view_comment_button" %>
+ <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %>
+ <% if current_user.id == c.user_id then %>
+ <%= link_to t("helpers.comments.edit_label"),"#", :class => "dmp_table_link edit_comment_button" %>
+
+ <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %>
+ <%= link_to t("helpers.comments.retract_label"),"#", :class => "dmp_table_link archive_comment_button" %>
+ <% end%>
+ <% project_id = Plan.find(c.plan_id).project_id%>
+ <% if (Project.find(project_id).administerable_by(current_user.id) && current_user.id != c.user_id )then%>
+ <%= hidden_field_tag :note_id, c.id, :class => "comment_id" %>
+ <%= link_to t("helpers.comments.clear_label"),"#", :class => "dmp_table_link archive_comment_button" %>
+ <% end%>
+ <%end%>
+ |
+
+ <%end%>
+
+
+
+
+
+
+
+<% notes_not_archived = notes.where("archived IS NULL") %>
+<% latest_note = notes_not_archived.order("updated_at DESC").first %>
+<% if !latest_note.nil? then%>
+
+<%end%>
+
+<%notes.order("updated_at DESC").each do |com|%>
+
+
+
+
+
+
+
+
+
+ <%end%>
diff --git a/app/views/plans/_note.html.erb b/app/views/plans/_note.html.erb
new file mode 100644
index 0000000..a6ed343
--- /dev/null
+++ b/app/views/plans/_note.html.erb
@@ -0,0 +1,35 @@
+
+
+
+
+<% @notes = Note.where("question_id = ? AND plan_id = ?", questionId, plan_id) %>
+<%= hidden_field_tag :question_id, questionId, :class => "question_id" %>
+
+<% if @notes.count > 0 then%>
+
+
+
+
+
+ <%= render :partial => "list_notes", locals: {notes: @notes}%>
+
+
+
+
+
+
+
+
+
+<% else%>
+ <%= t("helpers.comments.add_comment_text")%>
+ <%= render :partial => "add_note", locals: {questionId: questionId, planId: plan_id}%>
+<% end%>
diff --git a/app/views/plans/_view_comment.html.erb b/app/views/plans/_view_comment.html.erb
deleted file mode 100644
index 2141349..0000000
--- a/app/views/plans/_view_comment.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-
-<% user = User.find(comment.user_id) %>
-
-
-
diff --git a/app/views/plans/_view_note.html.erb b/app/views/plans/_view_note.html.erb
new file mode 100644
index 0000000..6b7737f
--- /dev/null
+++ b/app/views/plans/_view_note.html.erb
@@ -0,0 +1,11 @@
+
+<% user = User.find(note.user_id) %>
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index a21a1de..a75ed74 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -111,7 +111,7 @@
resources :answers, only: :create
- resources :comments, only: [:create, :update] do
+ resources :notes, only: [:create, :update] do
member do
put 'archive'
end