From 9f239789b9d307f12dd91a84f1cfb7ae5c00fed5 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Fri, 11 Feb 2011 12:57:52 -0800 Subject: [PATCH] can remote the person from the last aspect from edit contact pane --- app/views/people/_share_with_pane.html.haml | 2 +- features/disconnects_users.feature | 25 ++++++++++++++------- public/javascripts/contact-list.js | 17 ++++++++++++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/views/people/_share_with_pane.html.haml b/app/views/people/_share_with_pane.html.haml index a302636c7..5d9e50423 100644 --- a/app/views/people/_share_with_pane.html.haml +++ b/app/views/people/_share_with_pane.html.haml @@ -2,7 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -.aspect_list#aspects_list +.aspect_list#aspects_list{:data=>{:person_id=>person.id}} %ul - for aspect in aspects_with_person = render :partial => 'aspects/aspect_list_item', diff --git a/features/disconnects_users.feature b/features/disconnects_users.feature index 422e8beb1..6cc77a0b1 100644 --- a/features/disconnects_users.feature +++ b/features/disconnects_users.feature @@ -13,26 +13,35 @@ Feature: disconnecting users Then I should see 1 contact in "Besties" - Scenario: remove contact from the contact show page + Scenario Outline: remove contact from the contact show page When I am on "alice@alice.alice"'s page And I follow "edit aspect membership" - And I preemptively confirm the alert + And I preemptively the alert And I follow "remove contact" in the modal window And I wait for the ajax to finish And I am on the aspects manage page - Then I should see no contacts in "Besties" + Then I should see in "Besties" - - Scenario: cancel removing contact from the contact show page + Examples: + | accept | contacts | + | confirm | no contacts | + | reject | 1 contact | + + Scenario Outline: remove last contact from the contact show page When I am on "alice@alice.alice"'s page And I follow "edit aspect membership" - And I preemptively reject the alert - And I follow "remove contact" in the modal window + And I preemptively the alert + And I press the first ".added" within "#facebox #aspects_list ul > li:first-child" And I wait for the ajax to finish And I am on the aspects manage page - Then I should see 1 contact in "Besties" + Then I should see in "Besties" + + Examples: + | accept | contacts | + | confirm | no contacts | + | reject | 1 contact | Scenario: remove contact from the aspect edit page When I go to the home page diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js index 694bd0e18..01007a325 100644 --- a/public/javascripts/contact-list.js +++ b/public/javascripts/contact-list.js @@ -27,7 +27,11 @@ var List = { url: "/people/" + person_id, type: "DELETE", success: function(){ - $('.contact_list li[data-guid='+person_id+']').fadeOut(200); + if( $('.contact_list').length == 1){ + $('.contact_list li[data-guid='+person_id+']').fadeOut(200); + } else if($('#aspects_list').length == 1) { + $.facebox.close(); + }; } }); } @@ -56,7 +60,16 @@ $(document).ready(function() { $('.added').live('ajax:failure', function(data, html, xhr) { if(confirm(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'))){ - List.disconnectUser($(this).parents('li').attr("data-guid")); + var person_id; + + if( $('.contact_list').length == 1){ + person_id = $(this).parents('li').attr("data-guid"); + $('.contact_list li[data-guid='+person_id+']').fadeOut(200); + } else if($('#aspects_list').length == 1) { + person_id = $(this).parents('#aspects_list').attr("data-person_id"); + }; + + List.disconnectUser(person_id); }; $(this).fadeTo(200,1); });