From 85da6d340f656e0284f91b88d2481db926dc635e Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Mon, 27 Jun 2011 14:00:15 -0700 Subject: [PATCH] sort contacts by last name on contacts page --- app/controllers/contacts_controller.rb | 6 ++++-- app/views/contacts/index.html.haml | 12 ++++++++---- public/stylesheets/sass/application.sass | 11 +++++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 0f9628c76..060aa6675 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -12,10 +12,12 @@ class ContactsController < ApplicationController @my_contacts_count = current_user.contacts.receiving.count unless params[:set] == "all" - @contacts = current_user.contacts.receiving.includes(:aspects, :person => :profile).order('contacts.id DESC').paginate(:page => params[:page], :per_page => 25) + @contacts = current_user.contacts.receiving.includes(:aspects, :person => :profile).order('profiles.last_name ASC').paginate(:page => params[:page], :per_page => 25) else - @contacts = current_user.contacts.includes(:aspects, :person => :profile).order('contacts.id DESC').paginate(:page => params[:page], :per_page => 25) + @contacts = current_user.contacts.includes(:aspects, :person => :profile).order('profiles.last_name ASC').paginate(:page => params[:page], :per_page => 25) end + + @contacts_grouped = @contacts.group_by{|contact| contact.person.profile.last_name[0,1]} end def sharing diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index 546e7e73c..3d8cba182 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -21,9 +21,9 @@ %ul#aspect_sub_nav - for aspect in all_aspects %li - = aspect + = link_to aspect, contacts_path(:a_id => aspect) %li - Add new aspect + = link_to "Add new aspect", "#", :class => "add_new_aspect_link" %li{:class => ("active" if params["set"] == "all")} @@ -35,7 +35,11 @@ .span-15 #people_stream.stream - - for contact in @contacts - = render :partial => 'people/person', :locals => {:contact => contact, :person => contact.person} + - @contacts_grouped.each do |letter, contacts| + .right.letter + %h1 + = letter + - for contact in contacts + = render :partial => 'people/person', :locals => {:contact => contact, :person => contact.person} = will_paginate @contacts diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 78b194e57..af5179ffe 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2978,7 +2978,7 @@ ul#left_nav :decoration none li.active - a + > a :color #333 :font :weight 700 @@ -3003,8 +3003,15 @@ ul#left_nav ul#aspect_sub_nav :padding 0 - :left 20px + :left 15px :margin 0 :display none +#people_stream + :position relative + + .letter + :right -80px + h1 + :color #eee