Get rid of manage
This commit is contained in:
parent
c01641b619
commit
5884a900a2
19 changed files with 87 additions and 336 deletions
|
|
@ -131,12 +131,6 @@ class AspectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def manage
|
|
||||||
@aspect = :manage
|
|
||||||
@contacts = current_user.contacts.includes(:person => :profile)
|
|
||||||
@aspects = all_aspects.includes(:contacts => {:person => :profile})
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@aspect = current_user.aspects.where(:id => params[:id]).first
|
@aspect = current_user.aspects.where(:id => params[:id]).first
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
class ContactsController < ApplicationController
|
class ContactsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
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
|
def sharing
|
||||||
@contacts = current_user.contacts.sharing.includes(:aspect_memberships)
|
@contacts = current_user.contacts.sharing.includes(:aspect_memberships)
|
||||||
render :layout => false
|
render :layout => false
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@
|
||||||
- if defined?(@aspect) && ( @aspect == :profile || @aspect == :tag || @aspect == :search || @aspect == :notification)
|
- if defined?(@aspect) && ( @aspect == :profile || @aspect == :tag || @aspect == :search || @aspect == :notification)
|
||||||
%li.newItem
|
%li.newItem
|
||||||
.add_aspect
|
.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'
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
%h4
|
%h4
|
||||||
.right
|
.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)
|
= t('aspects', :count => aspects.count)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
.span-12.last
|
.span-12.last
|
||||||
#facebox_header
|
#facebox_header
|
||||||
%h4
|
%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|
|
= form_for(Aspect.new, :remote => (defined?(remote) && remote) ) do |aspect|
|
||||||
= aspect.error_messages
|
= aspect.error_messages
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
||||||
19
app/views/contacts/index.html.haml
Normal file
19
app/views/contacts/index.html.haml
Normal 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
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
= link_for_aspect(aspect, :class => 'aspect_selector name', :title => t('contacts', :count => aspect.contacts.size))
|
= link_for_aspect(aspect, :class => 'aspect_selector name', :title => t('contacts', :count => aspect.contacts.size))
|
||||||
|
|
||||||
%li
|
%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
|
.facebox_content
|
||||||
#add_aspect_pane
|
#add_aspect_pane
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
%h5
|
%h5
|
||||||
= t('aspects.manage.add_a_new_contact')
|
= t('contacts.index.add_a_new_contact')
|
||||||
= info_text(t('.enter_a_diaspora_username'))
|
= 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
|
= form_tag(person_by_handle_people_path, :id => "new_request_to_#{aspect_id}", :class => "webfinger_form", :remote => true) do
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ javascripts:
|
||||||
- public/javascripts/vendor/mailchimp/jquery.validate.js
|
- public/javascripts/vendor/mailchimp/jquery.validate.js
|
||||||
- public/javascripts/vendor/mailchimp/jquery126.min.js
|
- public/javascripts/vendor/mailchimp/jquery126.min.js
|
||||||
aspects:
|
aspects:
|
||||||
- public/javascripts/aspect-edit.js
|
|
||||||
- public/javascripts/contact-list.js
|
- public/javascripts/contact-list.js
|
||||||
finder:
|
finder:
|
||||||
- public/javascripts/friend-finder.js
|
- public/javascripts/friend-finder.js
|
||||||
|
|
|
||||||
|
|
@ -104,13 +104,7 @@ en:
|
||||||
edit_aspect: "edit aspect"
|
edit_aspect: "edit aspect"
|
||||||
no_posts_message:
|
no_posts_message:
|
||||||
start_talking: "Nobody has said anything yet. Get the conversation started!"
|
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:
|
new:
|
||||||
name: "Name"
|
name: "Name"
|
||||||
create: "Create"
|
create: "Create"
|
||||||
|
|
@ -188,6 +182,9 @@ en:
|
||||||
failure: "Failed to create contact"
|
failure: "Failed to create contact"
|
||||||
sharing:
|
sharing:
|
||||||
people_sharing: "People sharing with you:"
|
people_sharing: "People sharing with you:"
|
||||||
|
index:
|
||||||
|
add_a_new_aspect: "Add a new aspect"
|
||||||
|
title: "Your Contacts"
|
||||||
|
|
||||||
conversations:
|
conversations:
|
||||||
index:
|
index:
|
||||||
|
|
@ -608,6 +605,7 @@ en:
|
||||||
create_request: "Find by Diaspora handle"
|
create_request: "Find by Diaspora handle"
|
||||||
diaspora_handle: "diaspora@handle.org"
|
diaspora_handle: "diaspora@handle.org"
|
||||||
know_email: "Know their email address? You should invite them"
|
know_email: "Know their email address? You should invite them"
|
||||||
|
add_new_contact: "Add a new contact"
|
||||||
invitations:
|
invitations:
|
||||||
invites: "Invites"
|
invites: "Invites"
|
||||||
invite_someone: "Invite someone"
|
invite_someone: "Invite someone"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ Diaspora::Application.routes.draw do
|
||||||
# Posting and Reading
|
# Posting and Reading
|
||||||
|
|
||||||
resources :aspects do
|
resources :aspects do
|
||||||
get 'manage' => :manage, :on => :collection
|
|
||||||
put 'toggle_contact_visibility' => :toggle_contact_visibility
|
put 'toggle_contact_visibility' => :toggle_contact_visibility
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -81,7 +80,7 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
resource :profile
|
resource :profile
|
||||||
|
|
||||||
resources :contacts, :except => [:index, :update, :create] do
|
resources :contacts, :except => [:update, :create] do
|
||||||
get :sharing, :on => :collection
|
get :sharing, :on => :collection
|
||||||
end
|
end
|
||||||
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ Feature: sending and receiving requests
|
||||||
And I add the person to my 2nd aspect
|
And I add the person to my 2nd aspect
|
||||||
|
|
||||||
When I go to the home page
|
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 have 1 contact in "Unicorns"
|
||||||
Then I should see 1 contact in "Besties"
|
Then I should have 1 contact in "Besties"
|
||||||
|
|
||||||
And I am on the home page
|
And I am on the home page
|
||||||
Given I expand the publisher
|
Given I expand the publisher
|
||||||
|
|
@ -60,8 +60,8 @@ Feature: sending and receiving requests
|
||||||
Then I go to the destroy user session page
|
Then I go to the destroy user session page
|
||||||
|
|
||||||
When I sign in as "bob@bob.bob"
|
When I sign in as "bob@bob.bob"
|
||||||
And I am on the manage aspects page
|
When I follow "All Aspects" in the header
|
||||||
Then I should see 1 contact in "Besties"
|
Then I should have 1 contacts in "Besties"
|
||||||
|
|
||||||
And I am on the home page
|
And I am on the home page
|
||||||
Then I should see "I am following you back"
|
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
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
When I go to the home page
|
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 "Super People"
|
Then I should have 1 contact in "Super People"
|
||||||
Then I go to the destroy user session page
|
Then I go to the destroy user session page
|
||||||
|
|
||||||
When I sign in as "bob@bob.bob"
|
When I sign in as "bob@bob.bob"
|
||||||
And I am on the manage aspects page
|
When I follow "All Aspects" in the header
|
||||||
Then I should see 1 contact in "Besties"
|
Then I should have 1 contact in "Besties"
|
||||||
|
|
||||||
Scenario: should not see "Add to aspect" and see mention if already a follower
|
Scenario: should not see "Add to aspect" and see mention if already a follower
|
||||||
When I sign in as "bob@bob.bob"
|
When I sign in as "bob@bob.bob"
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ Feature: disconnecting users
|
||||||
|
|
||||||
And I remove the person from my 1st aspect
|
And I remove the person from my 1st aspect
|
||||||
|
|
||||||
And I am on the manage aspects page
|
When I follow "All Aspects" in the header
|
||||||
Then I should see no contacts in "Besties"
|
Then I should have 0 contacts in "Besties"
|
||||||
|
|
||||||
Then I go to the destroy user session page
|
Then I go to the destroy user session page
|
||||||
When I sign in as "alice@alice.alice"
|
When I sign in as "alice@alice.alice"
|
||||||
|
|
@ -41,19 +41,19 @@ Feature: disconnecting users
|
||||||
Then I should not see "is sharing with you."
|
Then I should not see "is sharing with you."
|
||||||
|
|
||||||
Scenario: remove a non-mutual contact from the aspect edit page
|
Scenario: remove a non-mutual contact from the aspect edit page
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
And I press the first ".contact-count" within "#aspect_listings"
|
And I press the first ".contact-count" within "#aspect_listings"
|
||||||
|
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
And I press the first ".added" within "#facebox .contact_list ul > li:first-child"
|
And I press the first ".added" within "#facebox .contact_list ul > li:first-child"
|
||||||
|
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I am on the manage aspects page
|
When I follow "All Aspects" in the header
|
||||||
Then I should see no contacts in "Besties"
|
Then I should have 0 contacts in "Besties"
|
||||||
|
|
||||||
Then I go to the destroy user session page
|
Then I go to the destroy user session page
|
||||||
When I sign in as "alice@alice.alice"
|
When I sign in as "alice@alice.alice"
|
||||||
And I am on "bob@bob.bob"'s page
|
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."
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
@aspects @javascript
|
@aspects @javascript
|
||||||
Feature: User manages aspects
|
Feature: User manages contacts
|
||||||
In order to share with a limited group
|
In order to share with a limited group
|
||||||
As a User
|
As a User
|
||||||
I want to create new aspects
|
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
|
Given I am signed in
|
||||||
When I follow "All Aspects" in the header
|
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 follow "+ Add a new aspect"
|
||||||
And I fill in "Name" with "Dorm Mates" in the modal window
|
And I fill in "Name" with "Dorm Mates" in the modal window
|
||||||
And I press "Create" in the modal window
|
And I press "Create" in the modal window
|
||||||
|
|
|
||||||
|
|
@ -69,46 +69,6 @@ Given /^I have one follower$/ do
|
||||||
@me.reload
|
@me.reload
|
||||||
end
|
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|
|
Then /^aspect "([^"]*)" should (not )?be selected$/ do |aspect_name, not_selected|
|
||||||
link_is_selected = evaluate_script("$('a:contains(\"#{aspect_name}\")').parent('li').hasClass('selected');")
|
link_is_selected = evaluate_script("$('a:contains(\"#{aspect_name}\")').parent('li').hasClass('selected');")
|
||||||
expected_value = !not_selected
|
expected_value = !not_selected
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
|
|
@ -255,53 +255,6 @@ describe AspectsController do
|
||||||
end
|
end
|
||||||
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
|
describe "#update" do
|
||||||
before do
|
before do
|
||||||
@alices_aspect_1 = alice.aspects.create(:name => "Bruisers")
|
@alices_aspect_1 = alice.aspects.create(:name => "Bruisers")
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,27 @@ describe ContactsController do
|
||||||
assigns[:contacts].to_set.should == alice.contacts.sharing.to_set
|
assigns[:contacts].to_set.should == alice.contacts.sharing.to_set
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue