diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index f5fcc865f..483a516ba 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -131,12 +131,6 @@ class AspectsController < ApplicationController end end - def manage - @aspect = :manage - @contacts = current_user.contacts.includes(:person => :profile) - @aspects = all_aspects.includes(:contacts => {:person => :profile}) - end - def update @aspect = current_user.aspects.where(:id => params[:id]).first diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 69f8e7e5d..e13bb2266 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -5,6 +5,11 @@ class ContactsController < ApplicationController before_filter :authenticate_user! + def index + @aspect = :manage + @contacts = current_user.contacts.includes(:aspects, :person => :profile).order('contacts.id DESC').paginate(:page => params[:page], :per_page => 25) + end + def sharing @contacts = current_user.contacts.sharing.includes(:aspect_memberships) render :layout => false diff --git a/app/views/aspect_memberships/_aspect_dropdown.html.haml b/app/views/aspect_memberships/_aspect_dropdown.html.haml index 264fd2d83..e24b11bb0 100644 --- a/app/views/aspect_memberships/_aspect_dropdown.html.haml +++ b/app/views/aspect_memberships/_aspect_dropdown.html.haml @@ -11,8 +11,8 @@ %ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => ((person.id) if person)} - for aspect in all_aspects = aspect_dropdown_list_item(aspect, contact, person) - + - if defined?(@aspect) && ( @aspect == :profile || @aspect == :tag || @aspect == :search || @aspect == :notification) %li.newItem .add_aspect - = link_to t('aspects.manage.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox' + = link_to t('contacts.index.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox' diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index 4e5b3ec25..3dedfa3bc 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -4,7 +4,7 @@ %h4 .right - = link_to t('contacts', :count => @contact_count), manage_aspects_path, :title => t('aspects.manage.manage_aspects') + = link_to t('contacts', :count => @contact_count), contacts_path , :title => t('contacts.index.title') = t('aspects', :count => aspects.count) diff --git a/app/views/aspects/_new.haml b/app/views/aspects/_new.haml index 3812a4c27..2534d3f0e 100644 --- a/app/views/aspects/_new.haml +++ b/app/views/aspects/_new.haml @@ -5,7 +5,7 @@ .span-12.last #facebox_header %h4 - = t('aspects.manage.add_a_new_aspect') + = t('contacts.index.add_a_new_aspect') = form_for(Aspect.new, :remote => (defined?(remote) && remote) ) do |aspect| = aspect.error_messages diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml deleted file mode 100644 index 5f73d7cb8..000000000 --- a/app/views/aspects/manage.html.haml +++ /dev/null @@ -1,46 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -- content_for :head do - = include_javascripts :aspects - -- content_for :page_title do - = t('.manage_aspects') - -#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('.manage_aspects') - -#manage_aspect_zones - .span-24.last - - @aspects.each_with_index do |aspect, i| - .aspect.span-12{:data => {:guid => aspect.id}, :class => (i+1) % 2 == 0 ? "last" : nil} - .aspect_name - %span.edit_name_field - %h3{:contenteditable=>true, :ondragenter=>"return false;", :ondragleave=>"return false;", :ondragover=>"return false;", :ondrop=>"return false;"} - = aspect.name - %span.tip click to edit - - %ul.tools - %li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{aspect.id}", :class => 'manage_aspect_contacts_button', :rel => "facebox" - %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 - = link_to person_image_tag(contact.person), contact.person - .draggable_info - =t('.drag_to_add') - - .facebox_content - %div{:id => "manage_aspect_contacts_pane_#{ aspect.id}"} - = render "requests/manage_aspect_contacts", :aspect => aspect, :manage => true, :contacts => @contacts - diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml new file mode 100644 index 000000000..2941922fd --- /dev/null +++ b/app/views/contacts/index.html.haml @@ -0,0 +1,19 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +- content_for :page_title do + = 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 + #people_stream.stream + - for contact in @contacts + = render :partial => 'people/person', :locals => {:contact => contact, :person => contact.person} + + = will_paginate @contacts diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 7ea3d7bbd..fe3720368 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -56,7 +56,7 @@ = link_for_aspect(aspect, :class => 'aspect_selector name', :title => t('contacts', :count => aspect.contacts.size)) %li - = link_to '+', '#add_aspect_pane', :class => "add_aspect_button", :title => t('aspects.manage.add_a_new_aspect'), :rel => 'facebox' + = link_to '+', '#add_aspect_pane', :class => "add_aspect_button", :title => t('contacts.index.add_a_new_aspect'), :rel => 'facebox' .facebox_content #add_aspect_pane diff --git a/app/views/shared/_add_contact.html.haml b/app/views/shared/_add_contact.html.haml index c1c27781f..c863e3d01 100644 --- a/app/views/shared/_add_contact.html.haml +++ b/app/views/shared/_add_contact.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. %h5 - = t('aspects.manage.add_a_new_contact') + = t('contacts.index.add_a_new_contact') = info_text(t('.enter_a_diaspora_username')) = form_tag(person_by_handle_people_path, :id => "new_request_to_#{aspect_id}", :class => "webfinger_form", :remote => true) do diff --git a/config/assets.yml b/config/assets.yml index e18c138ec..7853c8c7e 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -56,7 +56,6 @@ javascripts: - public/javascripts/vendor/mailchimp/jquery.validate.js - public/javascripts/vendor/mailchimp/jquery126.min.js aspects: - - public/javascripts/aspect-edit.js - public/javascripts/contact-list.js finder: - public/javascripts/friend-finder.js diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 24836a8ee..df83b1abe 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -104,13 +104,7 @@ en: edit_aspect: "edit aspect" no_posts_message: start_talking: "Nobody has said anything yet. Get the conversation started!" - manage: - add_a_new_aspect: "Add a new aspect" - add_a_new_contact: "Add a new contact" - requests: "Requests" - no_requests: "No new requests" - manage_aspects: "Manage aspects" - drag_to_add: "Drag to add people" + new: name: "Name" create: "Create" @@ -188,6 +182,9 @@ en: failure: "Failed to create contact" sharing: people_sharing: "People sharing with you:" + index: + add_a_new_aspect: "Add a new aspect" + title: "Your Contacts" conversations: index: @@ -608,6 +605,7 @@ en: create_request: "Find by Diaspora handle" diaspora_handle: "diaspora@handle.org" know_email: "Know their email address? You should invite them" + add_new_contact: "Add a new contact" invitations: invites: "Invites" invite_someone: "Invite someone" diff --git a/config/routes.rb b/config/routes.rb index 5e21f0b2d..afaf105a6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,6 @@ Diaspora::Application.routes.draw do # Posting and Reading resources :aspects do - get 'manage' => :manage, :on => :collection put 'toggle_contact_visibility' => :toggle_contact_visibility end @@ -34,7 +33,7 @@ Diaspora::Application.routes.draw do resources :tags, :only => [:index] get 'tags/:name' => 'tags#show', :as => 'tag' - + resources :apps, :only => [:show] # Users and people @@ -81,7 +80,7 @@ Diaspora::Application.routes.draw do resource :profile - resources :contacts, :except => [:index, :update, :create] do + resources :contacts, :except => [:update, :create] do get :sharing, :on => :collection end resources :aspect_memberships, :only => [:destroy, :create, :update] @@ -99,7 +98,7 @@ Diaspora::Application.routes.draw do end - + # Federation diff --git a/features/connects_users.feature b/features/connects_users.feature index 3d0ce375f..fa581b7bb 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -48,10 +48,10 @@ Feature: sending and receiving requests And I add the person to my 2nd aspect When I go to the home page - Then I go to the manage aspects page + When I follow "All Aspects" in the header - Then I should see 1 contact in "Unicorns" - Then I should see 1 contact in "Besties" + Then I should have 1 contact in "Unicorns" + Then I should have 1 contact in "Besties" And I am on the home page Given I expand the publisher @@ -60,8 +60,8 @@ Feature: sending and receiving requests Then I go to the destroy user session page When I sign in as "bob@bob.bob" - And I am on the manage aspects page - Then I should see 1 contact in "Besties" + When I follow "All Aspects" in the header + Then I should have 1 contacts in "Besties" And I am on the home page Then I should see "I am following you back" @@ -79,13 +79,13 @@ Feature: sending and receiving requests And I wait for the ajax to finish When I go to the home page - Then I go to the manage aspects page - Then I should see 1 contact in "Super People" + When I follow "All Aspects" in the header + Then I should have 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 manage aspects page - Then I should see 1 contact in "Besties" + When I follow "All Aspects" in the header + Then I should have 1 contact in "Besties" Scenario: should not see "Add to aspect" and see mention if already a follower When I sign in as "bob@bob.bob" diff --git a/features/disconnects_users.feature b/features/disconnects_users.feature index 76f0ab9a4..f8e3a8551 100644 --- a/features/disconnects_users.feature +++ b/features/disconnects_users.feature @@ -31,8 +31,8 @@ Feature: disconnecting users And I remove the person from my 1st aspect - And I am on the manage aspects page - Then I should see no contacts in "Besties" + When I follow "All Aspects" in the header + Then I should have 0 contacts in "Besties" Then I go to the destroy user session page When I sign in as "alice@alice.alice" @@ -41,19 +41,19 @@ Feature: disconnecting users Then I should not see "is sharing with you." Scenario: remove a non-mutual contact from the aspect edit page - When I go to the home page - And I press the first ".contact-count" within "#aspect_listings" + When I go to the home page + And I press the first ".contact-count" within "#aspect_listings" - And I wait for the ajax to finish - And I preemptively confirm the alert - And I press the first ".added" within "#facebox .contact_list ul > li:first-child" + And I wait for the ajax to finish + And I preemptively confirm the alert + And I press the first ".added" within "#facebox .contact_list ul > li:first-child" - And I wait for the ajax to finish - And I am on the manage aspects page - Then I should see no contacts in "Besties" + And I wait for the ajax to finish + When I follow "All Aspects" in the header + Then I should have 0 contacts in "Besties" - Then I go to the destroy user session page - When I sign in as "alice@alice.alice" - And I am on "bob@bob.bob"'s page + Then I go to the destroy user session page + When I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page - Then I should not see "is sharing with you." + Then I should not see "is sharing with you." diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature index 81f3af494..f993164d3 100644 --- a/features/manages_aspects.feature +++ b/features/manages_aspects.feature @@ -1,13 +1,13 @@ @aspects @javascript -Feature: User manages aspects +Feature: User manages contacts In order to share with a limited group As a User I want to create new aspects - Scenario: creating an aspect from manage aspects page + Scenario: creating an aspect from contacts index Given I am signed in When I follow "All Aspects" in the header - And I follow "Manage aspects" + And I follow "Your Contacts" And I follow "+ Add a new aspect" And I fill in "Name" with "Dorm Mates" in the modal window And I press "Create" in the modal window diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 548404fb5..1a310d20c 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -69,46 +69,6 @@ Given /^I have one follower$/ do @me.reload end -Then /^I should see (\d+) contact request(?:s)?$/ do |request_count| - wait_until do - number_of_requests = evaluate_script("$('.person.request.ui-draggable').length") - number_of_requests == request_count.to_i - end -end - -Then /^I should see (\d+) contact(?:s)? in "([^\"]*)"$/ do |contact_count, aspect_name| - aspect = @me.reload.aspects.find_by_name(aspect_name) - number_of_contacts = evaluate_script( - "$('ul.dropzone.ui-droppable[data-aspect_id=\"#{aspect.id}\"]').children('li.person').length") - number_of_contacts.should == contact_count.to_i -end - -Then /^I should see no contact(?:s)? in "([^\"]*)"$/ do |aspect_name| - aspect = @me.reload.aspects.find_by_name(aspect_name) - number_of_contacts = evaluate_script( - "$('ul.dropzone.ui-droppable[data-aspect_id=\"#{aspect.id}\"]').children('li.person').length") - number_of_contacts.should == 0 -end - -When /^I drag the contact request to the "([^\"]*)" aspect$/ do |aspect_name| - Given "I have turned off jQuery effects" - aspect = @me.reload.aspects.find_by_name(aspect_name) - aspect_div = find("ul.dropzone[data-aspect_id='#{aspect.id}']") - request_li = find(".person.request.ui-draggable") - request_li.drag_to(aspect_div) -end - -When /^I click "X" on the contact request$/ do - evaluate_script <<-JS - window.confirm = function() { return true; }; - $(".person.request.ui-draggable .delete").hover().click(); - JS -end - -When /^I click on the contact request$/ do - find(".person.request.ui-draggable a").click -end - Then /^aspect "([^"]*)" should (not )?be selected$/ do |aspect_name, not_selected| link_is_selected = evaluate_script("$('a:contains(\"#{aspect_name}\")').parent('li').hasClass('selected');") expected_value = !not_selected diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js deleted file mode 100644 index a6faafb80..000000000 --- a/public/javascripts/aspect-edit.js +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (c) 2010, Diaspora Inc. This file is - * licensed under the Affero General Public License version 3 or later. See - * the COPYRIGHT file. - */ - -var AspectEdit = { - - initialize: function() { - $("ul .person").draggable({ - revert: true, - start: AspectEdit.startDrag, - drag: AspectEdit.duringDrag, - stop: AspectEdit.stopDrag - }); - - $(".aspect ul.dropzone").droppable({ - hoverClass: 'active', - drop: AspectEdit.onDropMove - }); - - $("#manage_aspect_zones").find(".delete").click(AspectEdit.deletePerson); - $(".aspect h3").focus(AspectEdit.changeName); - - }, - - startDrag: function() { - AspectEdit.animateImage($(this).find("img").first()); - $(".draggable_info").fadeIn(100); - }, - - animateImage: function(image) { - image.animate({'height':80, 'width':80, 'opacity':0.8}, 200); - image.tipsy("hide"); - }, - - duringDrag: function(event, ui) { - $(this).find("img").first().tipsy("hide"); //ensure this is hidden - }, - - stopDrag: function(event, ui) { - $(this).find("img").first().animate({'height':50, 'width':50, 'opacity':1}, 200); - $(".draggable_info").fadeOut(100); - }, - - onDropMove: function(event, ui) { - var dropzone = $(this); - var person = ui.draggable; - - if (person.attr('data-aspect_id') !== undefined && // a request doesn't have a data-aspect_id, but an existing contact does - dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { - var aspect_id = person.attr('data-aspect_id'); - $.ajax({ - type: "PUT", - url: "/aspect_memberships/garbage", - data: { - "person_id": person.attr('data-guid'), - "to": dropzone.attr('data-aspect_id'), - "aspect_id": aspect_id - }, - success: function(data) { - AspectEdit.onMovePersonSuccess(person, dropzone); - Diaspora.widgets.flashes.render($.parseJSON(data)); - } - }); - } - - dropzone.closest("ul").append(person); - }, - - onDeleteRequestSuccess: function(person, dropzone) { - person.removeClass('request'); - person.attr('data-aspect_id', dropzone.attr('data-aspect_id')); - person.removeAttr('data-person_id'); - }, - - onMovePersonSuccess: function(person, dropzone) { - person.attr('data-aspect_id', dropzone.attr('data-aspect_id')); - }, - - deletePersonFromAspect: function(person) { - var person_id = person.attr('data-guid'); - - if( $(".person[data-guid='"+ person_id +"']").length == 1) { - Diaspora.widgets.alert.alert("Error removing contact", "You cannot remove the person from the last aspect"); - } else { - person.fadeOut(400, function() { - person.remove(); - }); - } - }, - - changeName: function() { - var $this = $(this), - id = $this.closest(".aspect").attr("data-guid"), - link = "/aspects/" + id; - - //cleanup - $this.text($.trim($this.text())); - - $this.keypress(function(e) { - if (e.which == 13) { - e.preventDefault(); - $this.blur(); - } - - //length limit - if ($this.text().length >= 20) { - e.preventDefault(); - } - //update all other aspect links - $("#aspect_nav li[data-guid='" + id + "'] a").text($this.text()); - }); - - $this.blur(function() { - //save changes - $.ajax({ - type: "PUT", - url: link, - data: { - "aspect": { - "name" : $this.text() - } - } - }); - }); - }, - - deletePerson: function() { - var person = $(this).closest("li.person"); - - if (person.hasClass('request')) { - if (confirm("Ignore request?")) { - var request_id = person.attr("data-guid"); - - $.ajax({ - type: "DELETE", - url: "/requests/" + request_id, - success: function () { - person.fadeOut(400, function() { - person.remove(); - }); - } - }); - } - } else { - if (confirm("Remove this person from aspect?")) { - AspectEdit.deletePersonFromAspect(person); - } - } - } -}; - -$(document).ready(AspectEdit.initialize); diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 07c149420..9a8f6752b 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -255,53 +255,6 @@ describe AspectsController do end end - describe "#manage" do - it "succeeds" do - get :manage - response.should be_success - end - - it "performs reasonably", :performance => true do - require 'benchmark' - 8.times do |n| - aspect = alice.aspects.create(:name => "aspect#{n}") - 8.times do |o| - person = Factory(:person) - alice.contacts.create(:person => person, :aspects => [aspect]) - end - end - Benchmark.realtime{ - get :manage - }.should < 4.5 - end - - it "assigns aspect to manage" do - get :manage - assigns(:aspect).should == :manage - end - - it "assigns contacts" do - get :manage - contacts = assigns(:contacts) - contacts.to_set.should == alice.contacts.to_set - end - - it "succeeds" do - get :manage - response.should be_success - end - - it "assigns aspect to manage" do - get :manage - assigns(:aspect).should == :manage - end - - it "generates a jasmine fixture", :fixture => 'jasmine' do - get :manage - save_fixture(html_for("body"), "aspects_manage") - end - end - describe "#update" do before do @alices_aspect_1 = alice.aspects.create(:name => "Bruisers") diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 8ce8ec501..7dd164f96 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -26,4 +26,27 @@ describe ContactsController do assigns[:contacts].to_set.should == alice.contacts.sharing.to_set end end + + describe '#index' do + it "succeeds" do + get :index + response.should be_success + end + + it "assigns aspect to manage" do + get :index + assigns(:aspect).should == :manage + end + + it "assigns contacts" do + get :index + contacts = assigns(:contacts) + contacts.to_set.should == alice.contacts.to_set + end + + it "generates a jasmine fixture", :fixture => 'jasmine' do + get :index + save_fixture(html_for("body"), "aspects_manage") + end + end end