From 9d3b419aad3069db13fc0169049a30fbc2b2a288 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 2 Feb 2013 14:29:45 +0000 Subject: [PATCH] Improve styling of the per-user notes list view --- app/assets/stylesheets/common.css.scss | 16 +++++++++++++++ app/controllers/notes_controller.rb | 2 +- app/helpers/note_helper.rb | 6 +++++- app/views/notes/mine.html.erb | 28 ++++++++++++-------------- config/locales/en.yml | 5 ++++- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index 5fe4ec97b..0d12b758f 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -1642,6 +1642,22 @@ a.button.submit { } } +/* Rules for the user notes list */ + +.note_list { + tr.creator { + background-color: #eeeeee; + } + + td { + padding: 3px; + } + + p { + margin-bottom: 0px; + } +} + /* Rules for the notes interface */ .note { diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index d25d9a37e..11d0f8cb4 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -236,7 +236,7 @@ class NotesController < ApplicationController if @this_user = User.active.find_by_display_name(params[:display_name]) @title = t 'note.mine.title', :user => @this_user.display_name @heading = t 'note.mine.heading', :user => @this_user.display_name - @description = t 'note.mine.description', :user => render_to_string(:partial => "user", :object => @this_user) + @description = t 'note.mine.subheading', :user => render_to_string(:partial => "user", :object => @this_user) @page = (params[:page] || 1).to_i @page_size = 10 @notes = @this_user.notes.order("updated_at DESC").offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author) diff --git a/app/helpers/note_helper.rb b/app/helpers/note_helper.rb index bfd7f493d..f2bff861f 100644 --- a/app/helpers/note_helper.rb +++ b/app/helpers/note_helper.rb @@ -8,6 +8,10 @@ module NoteHelper end def note_author(author, link_options = {}) - link_to h(author.display_name), link_options.merge({:controller => "user", :action => "view", :display_name => author.display_name}) + if author.nil? + "" + else + link_to h(author.display_name), link_options.merge({:controller => "user", :action => "view", :display_name => author.display_name}) + end end end diff --git a/app/views/notes/mine.html.erb b/app/views/notes/mine.html.erb index e385e942b..d7d866337 100644 --- a/app/views/notes/mine.html.erb +++ b/app/views/notes/mine.html.erb @@ -1,19 +1,21 @@ -

<%= @heading %>

-

<%= raw @description %>

+<% content_for :heading do %> +

<%= @heading %>

+

<%= raw @description %>

+<% end %> <%= render :partial => 'notes_paging_nav' %> - +
- - - + + + <% @notes.each do |note| -%> - bgcolor="#EEEEEE"<% end %>> + class="creator"<% end %>> - <% if note.author.nil? %> - - <% else %> - - <% end %> - - - + + + + <% end -%>
<%= t'note.mine.id' %><%= t'changeset.changesets.user' %><%= t'changeset.changesets.comment' %><%= t'changeset.changesets.saved_at' %><%= t'note.mine.creator' %><%= t'note.mine.description' %><%= t'note.mine.created_at' %> <%= t'note.mine.last_changed' %>
<% if note.status == "closed" %> <%= image_tag("closed_note_marker.png", :alt => 'closed') %> @@ -22,14 +24,10 @@ <% end %> <%= link_to note.id.to_s, :controller => "browse", :action => "note", :id => note.id %><%= link_to h(note.author.display_name), user_url(:display_name => note.author.display_name) %> <%= note.comments.first.body.to_html %> <%= l note.created_at %><%= l note.updated_at %><%= note_author(note.author) %><%= note.comments.first.body.to_html %><%= friendly_date(note.created_at) %><%= friendly_date(note.updated_at) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index f64b833b0..217c43306 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1998,8 +1998,11 @@ en: mine: title: "Notes submitted or commented on by %{user}" heading: "%{user}'s notes" - description: "Notes submitted or commented on by %{user}" + subheading: "Notes submitted or commented on by %{user}" id: "Id" + creator: "Creator" + description: "Description" + created_at: "Created at" last_changed: "Last changed" javascripts: map: -- 2.39.5