accept invitation feature passing
wip, added a form to add aspect to the contact list added files typo render the partial remote friend specifying the provider for the route refactored local person person friend finder functionality to use the partial typo trying to use the stream
This commit is contained in:
parent
a398184081
commit
df4ebb286d
13 changed files with 133 additions and 104 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
9
app/views/aspects/_aspect_list_item.haml
Normal file
9
app/views/aspects/_aspect_list_item.haml
Normal file
|
|
@ -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)
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
||||
|
|
|
|||
8
app/views/services/_finder.html.haml
Normal file
8
app/views/services/_finder.html.haml
Normal file
|
|
@ -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}
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -8,55 +8,21 @@
|
|||
= t('.your_aspects')
|
||||
.description
|
||||
= t('.description')
|
||||
-if @requests.length > 0
|
||||
%br
|
||||
= t('.your_inviter')
|
||||
%br
|
||||
|
||||
-if @requests.size > 0
|
||||
%h3
|
||||
= t('.your_inviter')
|
||||
#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}
|
||||
|
||||
%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"
|
||||
|
|
|
|||
|
|
@ -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 wait for the ajax to finish
|
||||
Then I should see 1 contact in "Family"
|
||||
|
||||
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
|
||||
|
||||
When I go to the home page
|
||||
Then I go to the aspects manage page
|
||||
Then I should see 1 contact in "Family"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
BIN
public/images/icons/monotone_add_plus.png
Normal file
BIN
public/images/icons/monotone_add_plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 228 B |
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue