Autocompletion contacts now change with changing aspect selection

This commit is contained in:
Raphael Sofaer 2011-02-09 12:23:14 -08:00
parent c11ffe93c0
commit 056bebd4f4
3 changed files with 5 additions and 2 deletions

View file

@ -12,8 +12,11 @@ class AspectsController < ApplicationController
def index
if params[:a_ids]
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts => {:person => :profile})
@selected_contacts = @aspects.inject([]){|arr, aspect| arr.concat(aspect.contacts)}
@selected_contacts.uniq!
else
@aspects = current_user.aspects.includes(:contacts => {:person => :profile})
@selected_contacts = current_user.contacts
end
# redirect to signup
@ -119,7 +122,7 @@ class AspectsController < ApplicationController
def update
@aspect = current_user.aspects.where(:id => params[:id]).first
if @aspect.update_attributes!( params[:aspect] )
#hack, we don't know why mass assignment is not working
@aspect.contacts_visible = params[:aspect][:contacts_visible]

View file

@ -2,6 +2,7 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= hidden_field_tag :contact_json, @selected_contacts.map{|contact| contact.person}.to_json
%h4
.right

View file

@ -6,7 +6,6 @@
- content_for :head do
= include_javascripts :home
= hidden_field_tag :contact_json, @contacts.map{|contact| contact.person}.to_json
.span-15.append-2
= render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count