diff --git a/app/routes/notes_routes.rb b/app/routes/notes_routes.rb index ec8be13..ca0bb6f 100644 --- a/app/routes/notes_routes.rb +++ b/app/routes/notes_routes.rb @@ -14,7 +14,7 @@ class Sinatra::Application end get '/notes' do - @notes = current_user.notes.includes(:tags) + @notes = current_user.notes.includes(:tags).order('title ASC') erb :'notes/index' end diff --git a/app/views/layout.erb b/app/views/layout.erb index 8cffbab..eb59d90 100644 --- a/app/views/layout.erb +++ b/app/views/layout.erb @@ -10,7 +10,7 @@ - +
<% if current_user %> <%= partial :'sidebar' %> diff --git a/app/views/notes/_form.erb b/app/views/notes/_form.erb index 4f6fe90..8d725de 100644 --- a/app/views/notes/_form.erb +++ b/app/views/notes/_form.erb @@ -1,6 +1,6 @@ <% action_url = note.new_record? ? '/note/create' : "/note/#{note.id}" %> <% method = note.new_record? ? 'post' : 'patch' %> -
+ <% unless note.new_record? %> <% end %> diff --git a/app/views/notes/_note.erb b/app/views/notes/_note.erb new file mode 100644 index 0000000..cd9ca1f --- /dev/null +++ b/app/views/notes/_note.erb @@ -0,0 +1,28 @@ +
+ +
+
+
+ + <%= note.title %> + + <% if note.tags %> +
+ <% note.tags.each do |tag| %> + + <%= tag.name %> + + <% end %> +
+ <% end %> +
+
+
+ <% if note.project %> + + <%= note.project.name %> + + <% end %> +
+
+
diff --git a/app/views/notes/_notes_table.erb b/app/views/notes/_notes_table.erb deleted file mode 100644 index 18d7160..0000000 --- a/app/views/notes/_notes_table.erb +++ /dev/null @@ -1,31 +0,0 @@ -
- - - - - - - - - <% notes.each do |note| %> - - - - - <% end %> - -
ContentTags
- -
- <%= partial :'notes/_form', locals: { note: note } %> -
-
- <% note.tags.each do |tag| %> - <%= tag.name %> - <% end %> -
-
\ No newline at end of file diff --git a/app/views/notes/index.erb b/app/views/notes/index.erb index 2729f24..c640185 100644 --- a/app/views/notes/index.erb +++ b/app/views/notes/index.erb @@ -3,11 +3,16 @@ New note
-
+
<%= partial :'notes/_form', locals: { note: Note.new } %>
- <%= partial :'notes/_notes_table', locals: {notes: @notes} %> + <% @notes.each do |note| %> +
+ <%= partial :'notes/_form', locals: { note: note } %> +
+ <%= partial :'notes/_note', locals: {note: note} %> + <% end %>
<%= partial :'notes/_edit_note_modal' %> diff --git a/app/views/projects/show.erb b/app/views/projects/show.erb index 859cbb3..e41d18a 100644 --- a/app/views/projects/show.erb +++ b/app/views/projects/show.erb @@ -34,7 +34,7 @@
-
Tasks
+

Tasks

<% if @project.tasks.any? %> <% @project.tasks.each do |task| %> @@ -51,10 +51,16 @@
<% end %> -
Notes
+ +

Notes

<% if @project.notes.any? %> - <%= partial :'notes/_notes_table', locals: {notes: @project.notes} %> + <% @project.notes.each do |note| %> +
+ <%= partial :'notes/_form', locals: { note: note } %> +
+ <%= partial :'notes/_note', locals: {note: note} %> + <% end %> <% else %>
No notes have been created yet for this project diff --git a/app/views/sidebar.erb b/app/views/sidebar.erb index 899940b..d11089f 100644 --- a/app/views/sidebar.erb +++ b/app/views/sidebar.erb @@ -1,4 +1,4 @@ -
+