Get rid of manage

This commit is contained in:
Raphael Sofaer 2011-06-23 18:04:01 -07:00
parent c01641b619
commit 5884a900a2
19 changed files with 87 additions and 336 deletions

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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."

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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")

View file

@ -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