diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index e13bb2266..0f9628c76 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -7,7 +7,15 @@ class ContactsController < ApplicationController def index @aspect = :manage - @contacts = current_user.contacts.includes(:aspects, :person => :profile).order('contacts.id DESC').paginate(:page => params[:page], :per_page => 25) + + @all_contacts_count = current_user.contacts.count + @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) + else + @contacts = current_user.contacts.includes(:aspects, :person => :profile).order('contacts.id DESC').paginate(:page => params[:page], :per_page => 25) + end end def sharing diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index 2941922fd..546e7e73c 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -6,12 +6,34 @@ = t('.title') #section_header - .right - = link_to("+ #{t('.add_a_new_aspect')}", "#add_aspect_pane", :class => "new_aspect button", :title => t('.add_a_new_aspect'), :rel => 'facebox') - %h2 - =t('.title') -.span-15.append-1 + = t('.title') + +.span-5.append-1 + %ul#left_nav + %li{:class => ("active" unless params["set"] == "all")} + + %a{:href => contacts_path} + .contact_count + = @my_contacts_count + My Contacts + + %ul#aspect_sub_nav + - for aspect in all_aspects + %li + = aspect + %li + Add new aspect + + %li{:class => ("active" if params["set"] == "all")} + + %a{:href => contacts_path(:set => "all")} + .contact_count + = @all_contacts_count + All Contacts + + +.span-15 #people_stream.stream - for contact in @contacts = render :partial => 'people/person', :locals => {:contact => contact, :person => contact.person} diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index e3cd9bde6..78b194e57 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -284,6 +284,11 @@ ul.dropdown :bottom 1px solid #ddd :top 1px solid #fff + &:first-child + :border + :top none + + .youtube-player, .vimeo-player :border none :height 370px @@ -2953,3 +2958,53 @@ h1.tag .hold-me :display inline-block + +ul#left_nav + :margin 0 + :padding 0 + + li + :position relative + + a + :display block + :width 100% + :padding 3px 7px + + &:hover + :background + :color lighten($blue,45%) + :text + :decoration none + + li.active + a + :color #333 + :font + :weight 700 + + .contact_count + @include border-radius(4px) + :float right + :margin-top 1px + :color #999 + :background + :color #eee + :padding 0 5px + :display inline + :font + :size 11px + + li.active + .contact_count + :font + :weight 700 + :color #666 + + ul#aspect_sub_nav + :padding 0 + :left 20px + :margin 0 + :display none + + diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 7dd164f96..b459923b6 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe ContactsController do before do - sign_in :user, alice - @controller.stub(:current_user).and_return(alice) + sign_in :user, bob + @controller.stub(:current_user).and_return(bob) end describe '#sharing' do @@ -23,7 +23,7 @@ describe ContactsController do it "assigns only the people sharing with you with 'share_with' flag" do get :sharing, :id => 'share_with' - assigns[:contacts].to_set.should == alice.contacts.sharing.to_set + assigns[:contacts].to_set.should == bob.contacts.sharing.to_set end end @@ -41,7 +41,25 @@ describe ContactsController do it "assigns contacts" do get :index contacts = assigns(:contacts) - contacts.to_set.should == alice.contacts.to_set + contacts.to_set.should == bob.contacts.to_set + end + + it "shows only contacts a user is sharing with" do + contact = bob.contacts.first + contact.update_attributes(:sharing => false) + + get :index, :set => "mine" + contacts = assigns(:contacts) + contacts.to_set.should == bob.contacts.sharing.to_set + end + + it "shows all contacts (sharing and receiving)" do + contact = bob.contacts.first + contact.update_attributes(:sharing => false) + + get :index, :set => "all" + contacts = assigns(:contacts) + contacts.to_set.should == bob.contacts.to_set end it "generates a jasmine fixture", :fixture => 'jasmine' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 20962af0c..1822d30e1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -34,6 +34,7 @@ describe User do new_user.id.should_not == alice.id end end + describe "validation" do describe "of associated person" do it "fails if person is not valid" do