sub menu for people only sharing with you on contacts page
This commit is contained in:
parent
44b77c58a3
commit
00ffade884
5 changed files with 34 additions and 8 deletions
|
|
@ -10,10 +10,13 @@ class ContactsController < ApplicationController
|
||||||
|
|
||||||
@all_contacts_count = current_user.contacts.count
|
@all_contacts_count = current_user.contacts.count
|
||||||
@my_contacts_count = current_user.contacts.receiving.count
|
@my_contacts_count = current_user.contacts.receiving.count
|
||||||
|
@only_sharing_count = current_user.contacts.only_sharing.count
|
||||||
|
|
||||||
if params["a_id"]
|
if params[:a_id]
|
||||||
@aspect_ = current_user.aspects.find(params["a_id"])
|
@aspect_ = current_user.aspects.find(params["a_id"])
|
||||||
@contacts = @aspect_.contacts.includes(:aspects, :person => :profile).order('profiles.last_name ASC').paginate(:page => params[:page], :per_page => 25)
|
@contacts = @aspect_.contacts.includes(:aspects, :person => :profile).order('profiles.last_name ASC').paginate(:page => params[:page], :per_page => 25)
|
||||||
|
elsif params[:set] == "only_sharing"
|
||||||
|
@contacts = current_user.contacts.only_sharing.includes(:aspects, :person => :profile).order('profiles.last_name ASC').paginate(:page => params[:page], :per_page => 25)
|
||||||
elsif params[:set] != "all"
|
elsif params[:set] != "all"
|
||||||
@contacts = current_user.contacts.receiving.includes(:aspects, :person => :profile).order('profiles.last_name ASC').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
|
else
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ class Contact < ActiveRecord::Base
|
||||||
where(:receiving => true)
|
where(:receiving => true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :only_sharing, lambda {
|
||||||
|
sharing.where(:receiving => false)
|
||||||
|
}
|
||||||
|
|
||||||
before_destroy :destroy_notifications
|
before_destroy :destroy_notifications
|
||||||
def destroy_notifications
|
def destroy_notifications
|
||||||
Notification.where(:target_type => "Person",
|
Notification.where(:target_type => "Person",
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
.span-5.append-1
|
.span-5.append-1
|
||||||
%ul#left_nav
|
%ul#left_nav
|
||||||
%li{:class => ("active" unless params["set"] == "all")}
|
%li{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing")}
|
||||||
%a{:href => contacts_path, :class => ("sub_selected" if params["a_id"])}
|
%a{:href => contacts_path, :class => ("sub_selected" if params["a_id"])}
|
||||||
.contact_count
|
.contact_count
|
||||||
= @my_contacts_count
|
= @my_contacts_count
|
||||||
My Contacts
|
My Contacts
|
||||||
|
|
||||||
%ul#aspect_sub_nav
|
%ul.sub_nav
|
||||||
- for aspect in all_aspects
|
- for aspect in all_aspects
|
||||||
%li{:class => ("active" if params["a_id"].to_i == aspect.id)}
|
%li{:class => ("active" if params["a_id"].to_i == aspect.id)}
|
||||||
%a{:href => contacts_path(:a_id => aspect.id)}
|
%a{:href => contacts_path(:a_id => aspect.id)}
|
||||||
|
|
@ -32,17 +32,23 @@
|
||||||
%li
|
%li
|
||||||
= link_to "+ Add new aspect", "#add_aspect_pane", :class => "new_aspect", :rel => "facebox"
|
= link_to "+ Add new aspect", "#add_aspect_pane", :class => "new_aspect", :rel => "facebox"
|
||||||
|
|
||||||
%li{:class => ("active" if params["set"] == "all")}
|
%li{:class => ("active" if params["set"] == "all" || params["set"] == "only_sharing")}
|
||||||
%a{:href => contacts_path(:set => "all")}
|
%a{:href => contacts_path(:set => "all"), :class => ("sub_selected" if params["set"] == "only_sharing")}
|
||||||
.contact_count
|
.contact_count
|
||||||
= @all_contacts_count
|
= @all_contacts_count
|
||||||
All Contacts
|
All Contacts
|
||||||
|
|
||||||
|
%ul.sub_nav
|
||||||
|
%li{:class => ("active" if params["set"] == "only_sharing")}
|
||||||
|
%a{:href => contacts_path(:set => "only_sharing")}
|
||||||
|
.contact_count
|
||||||
|
= @only_sharing_count
|
||||||
|
Only sharing with me
|
||||||
|
|
||||||
.span-15
|
.span-15
|
||||||
#people_stream.stream.contacts
|
#people_stream.stream.contacts
|
||||||
- if @contacts.size > 0
|
- if @contacts.size > 0
|
||||||
- for contact in @contacts
|
- for contact in @contacts
|
||||||
|
|
||||||
.stream_element{:id => contact.person.id}
|
.stream_element{:id => contact.person.id}
|
||||||
.right
|
.right
|
||||||
- if @aspect_
|
- if @aspect_
|
||||||
|
|
|
||||||
|
|
@ -2989,7 +2989,7 @@ ul#left_nav
|
||||||
:weight 700
|
:weight 700
|
||||||
:color #666
|
:color #666
|
||||||
|
|
||||||
ul#aspect_sub_nav
|
ul.sub_nav
|
||||||
:display block
|
:display block
|
||||||
|
|
||||||
.contact_count
|
.contact_count
|
||||||
|
|
@ -3004,7 +3004,7 @@ ul#left_nav
|
||||||
:font
|
:font
|
||||||
:size 11px
|
:size 11px
|
||||||
|
|
||||||
ul#aspect_sub_nav
|
ul.sub_nav
|
||||||
:padding 0
|
:padding 0
|
||||||
:margin 0
|
:margin 0
|
||||||
:display none
|
:display none
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,19 @@ describe Contact do
|
||||||
}.by(1)
|
}.by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'only_sharing' do
|
||||||
|
it 'returns contacts with sharing true and receiving false' do
|
||||||
|
lambda {
|
||||||
|
alice.contacts.create!(:receiving => true, :sharing => true, :person => Factory(:person))
|
||||||
|
alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person))
|
||||||
|
alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person))
|
||||||
|
alice.contacts.create!(:receiving => true, :sharing => false, :person => Factory(:person))
|
||||||
|
}.should change{
|
||||||
|
Contact.receiving.count
|
||||||
|
}.by(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#contacts' do
|
describe '#contacts' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue