diff --git a/app/views/shared/_contact_list.html.haml b/app/views/shared/_contact_list.html.haml
index a0d6a1f3e..63ec275bc 100644
--- a/app/views/shared/_contact_list.html.haml
+++ b/app/views/shared/_contact_list.html.haml
@@ -7,7 +7,7 @@
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
%ul
- for contact in contacts
- %li
+ %li{:data=>{:guid=>contact.person.id}}
= person_image_tag contact.person
%h4.name
= link_to contact.person.name, contact.person
diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb
index 5628cd067..8f3f6169f 100644
--- a/features/step_definitions/custom_web_steps.rb
+++ b/features/step_definitions/custom_web_steps.rb
@@ -19,6 +19,10 @@ And /^I preemptively confirm the alert$/ do
a = page.evaluate_script("window.confirm = function() { return true; }")
end
+And /^I preemptively reject the alert$/ do
+ a = page.evaluate_script("window.confirm = function() { return false; }")
+end
+
When /^(.*) in the modal window$/ do |action|
within('#facebox') do
When action
@@ -68,4 +72,4 @@ When /^I wait for "([^\"]*)" to load$/ do |page_name|
current_location << "?#{uri.query}" unless uri.query.blank?
current_location == path_to(page_name)
end
-end
\ No newline at end of file
+end
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb
index b2973362b..1efa30eaf 100644
--- a/features/step_definitions/user_steps.rb
+++ b/features/step_definitions/user_steps.rb
@@ -57,6 +57,13 @@ Then /^I should see (\d+) contact(?:s)? in "([^"]*)"$/ do |contact_count, aspect
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)
@@ -90,3 +97,10 @@ Then /^I should have aspect "([^"]*)" "([^"]*)"$/ do |arg1, arg2|
end
end
+Given /^a user with email "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
+ user1 = User.where(:email => arg1).first
+ user2 = User.where(:email => arg2).first
+ connect_users(user1, user1.aspects.first, user2, user2.aspects.first)
+end
+
+
diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js
index be016c680..c8967dab9 100644
--- a/public/javascripts/contact-list.js
+++ b/public/javascripts/contact-list.js
@@ -3,28 +3,37 @@
* the COPYRIGHT file.
*/
+var List = {
+ initialize: function() {
+ $(".contact_list_search").live("keyup", function(e) {
+ var search = $(this);
+ var list = $(this).siblings("ul").first();
+ var query = new RegExp(search.val(),'i');
+
+ $("li", list).each( function() {
+ var element = $(this);
+ if( !element.text().match(query) ) {
+ if( !element.hasClass('hidden') ) {
+ element.addClass('hidden');
+ }
+ } else {
+ element.removeClass('hidden');
+ }
+ });
+ });
+ },
+ disconnectUser: function(person_id){
+ $.ajax({
+ url: "/people/" + person_id,
+ type: "DELETE",
+ success: function(){
+ $('.contact_list li[data-guid='+person_id+']').fadeOut(200);
+ }
+ });
+ }
+};
$(document).ready(function() {
- var List = {
- initialize: function() {
- $(".contact_list_search").live("keyup", function(e) {
- var search = $(this);
- var list = $(this).siblings("ul").first();
- var query = new RegExp(search.val(),'i');
-
- $("li", list).each( function() {
- var element = $(this);
- if( !element.text().match(query) ) {
- if( !element.hasClass('hidden') ) {
- element.addClass('hidden');
- }
- } else {
- element.removeClass('hidden');
- }
- });
- });
- }
- };
$('.added').live('ajax:loading', function() {
$(this).fadeTo(200,0.4);
@@ -46,7 +55,9 @@ $(document).ready(function() {
});
$('.added').live('ajax:failure', function(data, html, xhr) {
- alert(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'));
+ if(confirm(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'))){
+ List.disconnectUser($(this).parents('li').attr("data-guid"));
+ };
$(this).fadeTo(200,1);
});
diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml
index 409bae9ae..5887ea0bf 100644
--- a/spec/javascripts/support/jasmine.yml
+++ b/spec/javascripts/support/jasmine.yml
@@ -29,6 +29,7 @@ src_files:
- public/javascripts/mobile.js
- public/javascripts/aspect-edit.js
- public/javascripts/aspect-contacts.js
+ - public/javascripts/contact-list.js
- public/javascripts/web-socket-receiver.js
- public/javascripts/view.js
- public/javascripts/publisher.js