added an option to remove a contact from the last aspect, after a prompt
This commit is contained in:
parent
acd55cf7d6
commit
1da965616b
5 changed files with 53 additions and 23 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
|
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
|
||||||
%ul
|
%ul
|
||||||
- for contact in contacts
|
- for contact in contacts
|
||||||
%li
|
%li{:data=>{:guid=>contact.person.id}}
|
||||||
= person_image_tag contact.person
|
= person_image_tag contact.person
|
||||||
%h4.name
|
%h4.name
|
||||||
= link_to contact.person.name, contact.person
|
= link_to contact.person.name, contact.person
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ And /^I preemptively confirm the alert$/ do
|
||||||
a = page.evaluate_script("window.confirm = function() { return true; }")
|
a = page.evaluate_script("window.confirm = function() { return true; }")
|
||||||
end
|
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|
|
When /^(.*) in the modal window$/ do |action|
|
||||||
within('#facebox') do
|
within('#facebox') do
|
||||||
When action
|
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 << "?#{uri.query}" unless uri.query.blank?
|
||||||
current_location == path_to(page_name)
|
current_location == path_to(page_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,13 @@ Then /^I should see (\d+) contact(?:s)? in "([^"]*)"$/ do |contact_count, aspect
|
||||||
number_of_contacts.should == contact_count.to_i
|
number_of_contacts.should == contact_count.to_i
|
||||||
end
|
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|
|
When /^I drag the contact request to the "([^"]*)" aspect$/ do |aspect_name|
|
||||||
Given "I have turned off jQuery effects"
|
Given "I have turned off jQuery effects"
|
||||||
aspect = @me.reload.aspects.find_by_name(aspect_name)
|
aspect = @me.reload.aspects.find_by_name(aspect_name)
|
||||||
|
|
@ -90,3 +97,10 @@ Then /^I should have aspect "([^"]*)" "([^"]*)"$/ do |arg1, arg2|
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,28 +3,37 @@
|
||||||
* the COPYRIGHT file.
|
* 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() {
|
$(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() {
|
$('.added').live('ajax:loading', function() {
|
||||||
$(this).fadeTo(200,0.4);
|
$(this).fadeTo(200,0.4);
|
||||||
|
|
@ -46,7 +55,9 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.added').live('ajax:failure', function(data, html, xhr) {
|
$('.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);
|
$(this).fadeTo(200,1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ src_files:
|
||||||
- public/javascripts/mobile.js
|
- public/javascripts/mobile.js
|
||||||
- public/javascripts/aspect-edit.js
|
- public/javascripts/aspect-edit.js
|
||||||
- public/javascripts/aspect-contacts.js
|
- public/javascripts/aspect-contacts.js
|
||||||
|
- public/javascripts/contact-list.js
|
||||||
- public/javascripts/web-socket-receiver.js
|
- public/javascripts/web-socket-receiver.js
|
||||||
- public/javascripts/view.js
|
- public/javascripts/view.js
|
||||||
- public/javascripts/publisher.js
|
- public/javascripts/publisher.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue