added an option to remove a contact from the last aspect, after a prompt

This commit is contained in:
zhitomirskiyi 2011-02-09 17:47:02 -08:00
parent acd55cf7d6
commit 1da965616b
5 changed files with 53 additions and 23 deletions

View file

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

View file

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

View file

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

View file

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

View file

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