diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 56c34f0bc7e778f03f91658d0f5869d843e0dda2..9efce5a0f3b441a6ca606397f5a12e0448ac7ded 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -6,7 +6,7 @@ class AspectsController < ApplicationController before_filter :authenticate_user! respond_to :html - respond_to :json, :only => :show + respond_to :json, :only => [:show, :create] respond_to :js def index @@ -47,6 +47,17 @@ class AspectsController < ApplicationController redirect_to :back elsif request.env['HTTP_REFERER'].include?("aspects/manage") redirect_to :back + elsif params[:aspect][:share_with] + @contact = Contact.where(:id => params[:aspect][:contact_id]).first + @person = Person.where(:id => params[:aspect][:person_id]).first + respond_to do |format| + format.js { render :json => {:html => render_to_string( + :partial => 'aspects/aspect_list_item', + :locals => {:aspect => @aspect, + :person => @person, + :contact => @contact} + )},:status => 201 } + end else respond_with @aspect end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 61196f2887086fc9ddb35a4874efb4bf224f6774..761ac792466f0cd1a348e6eba0615bf59b24a2cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -83,7 +83,10 @@ class UsersController < ApplicationController @step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1 @step ||= 1 - if @step == 4 + if @step == 3 + service = current_user.services.where(:type => "Services::Facebook").first + @friends = service ? service.finder : {} + elsif @step == 4 @user.getting_started = false @user.save end diff --git a/app/views/aspects/_aspect_list_item.haml b/app/views/aspects/_aspect_list_item.haml new file mode 100644 index 0000000000000000000000000000000000000000..8ee855aa15dc7bc0c17b0ef4fb7f3bf2a7bdaab9 --- /dev/null +++ b/app/views/aspects/_aspect_list_item.haml @@ -0,0 +1,9 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +%li{:data=>{:guid=>aspect.id}} + %span.name + = link_to aspect.name, aspect + .right + = aspect_membership_button(aspect, contact, person) diff --git a/app/views/people/_person.html.haml b/app/views/people/_person.html.haml index cc424791d40e4e1b7be5a9160a2d833de41b6b03..228ad17e09cc27a50c7b2935fee6b78e56e96a78 100644 --- a/app/views/people/_person.html.haml +++ b/app/views/people/_person.html.haml @@ -9,8 +9,15 @@ = t('.thats_you') - elsif contact && !contact.pending = t('.already_connected') - - elsif (contact && contact.pending) || request + - elsif (contact && contact.pending) || (request && request.recipient == person) = t('.pending_request') + - elsif request && request.sender == person + = link_to t('people.show.incoming_request', :name => truncate(person.name, :length => 20, :separator => ' ', :omission => '')), + {:controller => "people", + :action => "share_with", + :id => person.id}, + :class => 'share_with button', + :rel => 'facebox' - else = link_to t('people.show.start_sharing'), {:controller => "people", diff --git a/app/views/people/_share_with_pane.html.haml b/app/views/people/_share_with_pane.html.haml index 74c5ced8b3ff73b9a9100550eb24e6e5bb9a6d46..7ee48f457390926bcb9a92233cb1474b04ff5806 100644 --- a/app/views/people/_share_with_pane.html.haml +++ b/app/views/people/_share_with_pane.html.haml @@ -5,16 +5,27 @@ .aspect_list#aspects_list %ul - for aspect in aspects_with_person - %li{:data=>{:guid=>aspect.id}} - %span.name - = link_to aspect.name, aspect - .right - = aspect_membership_button(aspect, contact, person) + = render :partial => 'aspects/aspect_list_item', + :locals => {:aspect => aspect, :person => person, + :contact => contact} - for aspect in aspects_without_person - %li{:data=>{:guid=>aspect.id}} - %span.name - = link_to aspect.name, aspect - .right - = aspect_membership_button(aspect, contact, person) + = render :partial => 'aspects/aspect_list_item', + :locals => {:aspect => aspect, :person => person, + :contact => contact} + +.add_aspect + = t('users.getting_started.step_3.aspect_name') + = form_for(Aspect.new, :remote => true) do |aspect| + = aspect.error_messages + = aspect.hidden_field :person_id, :value => person.id if person + = aspect.hidden_field :contact_id, :value => contact.id if contact + = aspect.hidden_field :share_with, :value => true + = aspect.text_field :name, :id => "step-3-aspect-name", :style => "display:inline;" + %p.checkbox_select + = aspect.label :contacts_visible, t('aspects.edit.make_aspect_list_visible') + = aspect.check_box :contacts_visible, :default => true + .right + = aspect.submit :src => '/images/icons/monotone_add_plus.png', :type => "image", :value => "", :class => 'button' + diff --git a/app/views/services/_finder.html.haml b/app/views/services/_finder.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..f505950077f698ebd2ee580739cdd67c749428e0 --- /dev/null +++ b/app/views/services/_finder.html.haml @@ -0,0 +1,8 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + += search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts') +%ul + - for uid in friends.keys + = render :partial => 'services/remote_friend', :locals => {:friend => friends[uid], :uid => uid} diff --git a/app/views/services/_remote_friend.html.haml b/app/views/services/_remote_friend.html.haml index 800970cf338a2ba618b225e176ae65c3283b1317..fa28a2f91a541f2562ce4626f0db05e8ac7f8414 100644 --- a/app/views/services/_remote_friend.html.haml +++ b/app/views/services/_remote_friend.html.haml @@ -1,35 +1,22 @@ %li - .right - -if friend[:contact] && !friend[:contact].pending - = t('people.person.already_connected') - - elsif (friend[:contact] && friend[:contact].pending) - = t('people.person.pending_request') - - elsif friend[:invitation_id] - = t('invitations.new.already_invited') - %br - = link_to t('.resend'), service_inviter_path(:uid => uid, :provider => 'facebook', :invitation_id => friend[:invitation_id]) - - elsif friend[:person] - = link_to t('people.show.start_sharing'), - {:controller => "people", - :action => "show", - :id => friend[:person].id, - :share_with => true}, - :class => 'button' + -if friend[:person] + = render :partial => 'people/person', :locals => {:person => friend[:person], :contact => friend[:contact], :request => friend[:request]} + -else + .stream_element + .right + -if friend[:invitation_id] + = t('invitations.new.already_invited') + %br + = link_to t('.resend'), service_inviter_path(:uid => uid, :provider => 'facebook', :invitation_id => friend[:invitation_id]) + - elsif current_user.invites > 0 + = form_tag service_inviter_path(:provider => 'facebook') do + = select_tag(:aspect_id, options_from_collection_for_select(@all_aspects, 'id', 'name')) + = hidden_field_tag :uid, uid + = submit_tag t('.invite') - - elsif current_user.invites > 0 - = form_tag service_inviter_path do - = select_tag(:aspect_id, options_from_collection_for_select(@all_aspects, 'id', 'name')) - = hidden_field_tag :uid, uid - = hidden_field_tag :provider, 'facebook' - = submit_tag t('.invite') + + = image_tag('/images/user/default.png', :class => 'avatar') - - if friend[:person] - = person_image_link(friend[:person]) - - else - = image_tag('/images/user/default.png', :class => 'avatar') - - %h4.name - - if friend[:person] - = link_to friend[:name], person_path(friend[:person]) - - else - = friend[:name] + .content + %span.from + = friend[:name] diff --git a/app/views/services/finder.html.haml b/app/views/services/finder.html.haml index f26e73375cdea1476480fccf73b25e9843392576..f3256ab068b9f4397441dd32e5bccf6843ca2f87 100644 --- a/app/views/services/finder.html.haml +++ b/app/views/services/finder.html.haml @@ -18,10 +18,7 @@ .contact_list - if @friends.keys.length > 0 - = search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts') - %ul - - for uid in @friends.keys - = render :partial => 'remote_friend', :locals => {:friend => @friends[uid], :uid => uid} + = render :partial => 'services/finder', :locals => {:friends => @friends} - else %br %br diff --git a/app/views/users/getting_started/_step_3.html.haml b/app/views/users/getting_started/_step_3.html.haml index 8ff298d55eae14c879482f7c6deb65f71d433342..de5cb05c721b0ab08c67130ccad9e99072d21b98 100644 --- a/app/views/users/getting_started/_step_3.html.haml +++ b/app/views/users/getting_started/_step_3.html.haml @@ -8,55 +8,21 @@ = t('.your_aspects') .description = t('.description') + -if @requests.length > 0 + %br + = t('.your_inviter') + %br + + #people_stream.stream + - for pending_req in @requests + - person = pending_req.sender + + = render :partial => 'people/person', :locals => {:request => pending_req, :person => person, :contact => nil} + -unless @friends.blank? + %br + .contact_list + = render :partial => 'services/finder', :locals => {:friends => @friends, :getting_started => true} --if @requests.size > 0 - %h3 - = t('.your_inviter') - - %h3 - %ul.dropzone - - if @requests.size < 1 - %li=t('.no_requests') - - else - - for request in @requests - %li.person.request{:data=>{:guid=>request.id, :person_id=>request.sender.id}} - = person_image_link(request.sender) - .requests - %p= "#{t('.drag_to_add')} =>" - - -%ul#aspect_list - - for aspect in @all_aspects - %li.aspect{:data=>{:guid=>aspect.id}} - - .aspect_name - %span.edit_name_field - %h3{:contenteditable=>true} - = aspect.name - %span.tip click to edit - - %ul.tools - %li!= remove_link(aspect) - - %ul.dropzone{:data=>{:aspect_id=>aspect.id}} - -for contact in aspect.contacts - %li.person{:data=>{:guid=>contact.person.id, :aspect_id=>aspect.id}} - .delete - .x - X - .circle - = person_image_link(contact.person) -%h4 - = t('.aspect_name') - = form_for Aspect.new do |aspect| - = aspect.text_field :name, :id => "step-3-aspect-name", :style => "display:inline;" - %p.checkbox_select - = aspect.label :contacts_visible, t('aspects.edit.make_aspect_list_visible') - = aspect.check_box :contacts_visible, :default => true - %br - = aspect.submit t('.add') -%br -%br .submit_block = link_to "#{t('users.getting_started.save_and_continue')} →", getting_started_path(:step => 4), :class => "button" diff --git a/features/accepts_invitation.feature b/features/accepts_invitation.feature index 8810eea280182dfbf71cf13138fcae0b0a399405..1df103a533c32e0517e84d86a8a594117073df5c 100644 --- a/features/accepts_invitation.feature +++ b/features/accepts_invitation.feature @@ -11,6 +11,7 @@ Feature: invitation acceptance Then I should be on the getting started page And I should see "Welcome to Diaspora!" And I should see "ohai" + When I follow "Save and continue" And I fill in "profile_first_name" with "O" And I fill in "profile_last_name" with "Hai" And I fill in "profile_gender" with "guess!" @@ -30,15 +31,22 @@ Feature: invitation acceptance Then I should be on the getting started page And I should see "Welcome to Diaspora!" And I should see "ohai" + When I follow "Save and continue" And I fill in "profile_first_name" with "O" And I fill in "profile_last_name" with "Hai" And I fill in "profile_gender" with "guess!" And I press "Save and continue" Then I should see "Profile updated" + And I should see "Your aspects" And I should see "Here are the people who are waiting for you:" - And I should see 1 contact request - When I drag the contact request to the "Family" aspect + + And I press the first ".share_with.button" + And I press the first ".add.button" within "#facebox #aspects_list ul > li:first-child" And I wait for the ajax to finish - Then I should see 1 contact in "Family" + + When I go to the home page + Then I go to the aspects manage page + Then I should see 1 contact in "Family" + diff --git a/features/connects_users.feature b/features/connects_users.feature index 6097aed194076aa80a2d17e6fae1250c48d000eb..0d591c8d6c92ce9fc3f150af485a21b62bc45256 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -1,11 +1,9 @@ +@javascript Feature: sending and receiving requests Background: Given a user with email "bob@bob.bob" And a user with email "alice@alice.alice" - - @javascript - Scenario: initiating and accepting a contact request When I sign in as "bob@bob.bob" And I am on "alice@alice.alice"'s page And I press the first ".share_with.button" within "#author_info" @@ -13,7 +11,8 @@ Feature: sending and receiving requests And I wait for the ajax to finish Then I should see a ".added.button" within "#facebox #aspects_list ul > li:first-child" Then I go to the destroy user session page - + + Scenario: accepting a contact request When I sign in as "alice@alice.alice" And I am on the aspects manage page Then I should see 1 contact request @@ -30,3 +29,21 @@ Feature: sending and receiving requests And I am on the aspects manage page Then I should see 1 contact in "Besties" + + Scenario: accepting a contact request into a new aspect + When I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page + And I press the first ".share_with.button" within "#author_info" + And I fill in "Name" with "Super People" in the modal window + And I press "aspect_submit" in the modal window + And I wait for the ajax to finish + And I press the first ".add.button" within "#facebox #aspects_list ul > li:last-child" + + When I go to the home page + Then I go to the aspects manage page + Then I should see 1 contact in "Super People" + Then I go to the destroy user session page + + When I sign in as "bob@bob.bob" + And I am on the aspects manage page + Then I should see 1 contact in "Besties" diff --git a/public/images/icons/monotone_add_plus.png b/public/images/icons/monotone_add_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..f03378c1eecd97ecee3c05b7caac10f5e601b7dd Binary files /dev/null and b/public/images/icons/monotone_add_plus.png differ diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js index b01c821d457fca742e918d8a1d1437ab45e6fbf4..be016c680aa4bb889608f80218ffb49cf8e0f3b2 100644 --- a/public/javascripts/contact-list.js +++ b/public/javascripts/contact-list.js @@ -74,5 +74,10 @@ $(document).ready(function() { $(this).children("img").attr("src","/images/icons/monotone_check_yes.png"); }); + $('.new_aspect').live('ajax:success', function(data, json, xhr){ + var json = JSON.parse(json); + $('#aspects_list ul').append(json.html); + }); + List.initialize(); });