green everywhere.
This commit is contained in:
parent
c128cae4ec
commit
1c9ca738ae
9 changed files with 38 additions and 82 deletions
|
|
@ -16,21 +16,10 @@ class AspectMembershipsController < ApplicationController
|
|||
membership = @contact ? @contact.aspect_memberships.where(:aspect_id => @aspect_id).first : nil
|
||||
|
||||
if membership && membership.destroy
|
||||
@aspect = membership.aspect
|
||||
|
||||
flash.now[:notice] = I18n.t 'aspect_memberships.destroy.success'
|
||||
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
render :json => {:button_html =>
|
||||
render_to_string(:partial => 'aspect_memberships/remove_from_aspect',
|
||||
:locals => {:aspect => membership.aspect,
|
||||
:person => @contact.person,
|
||||
:contact => @contact }),
|
||||
:aspect_id => @aspect_id}
|
||||
end
|
||||
format.html{
|
||||
redirect_to :back
|
||||
}
|
||||
end
|
||||
else
|
||||
flash.now[:error] = I18n.t 'aspect_memberships.destroy.failure'
|
||||
errors = membership ? membership.errors.full_messages : t('aspect_memberships.destroy.no_membership')
|
||||
|
|
@ -47,20 +36,10 @@ class AspectMembershipsController < ApplicationController
|
|||
@person = Person.find(params[:person_id])
|
||||
@aspect = current_user.aspects.where(:id => params[:aspect_id]).first
|
||||
|
||||
if current_user.share_with(@person, @aspect)
|
||||
if @contact = current_user.share_with(@person, @aspect)
|
||||
|
||||
flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success'
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :json => {
|
||||
:button_html => render_to_string(:partial => 'aspect_memberships/add_to_aspect',
|
||||
:locals => {:aspect_id => @aspect.id,
|
||||
:person_id => @person.id}),
|
||||
:badge_html => render_to_string(:partial => 'aspects/aspect_badge',
|
||||
:locals => {:aspect => @aspect})
|
||||
}}
|
||||
format.html{ redirect_to aspect_path(@aspect.id)}
|
||||
end
|
||||
else
|
||||
flash[:error] = I18n.t 'contacts.create.failure'
|
||||
redirect_to :back
|
||||
|
|
|
|||
|
|
@ -49,15 +49,6 @@ class AspectsController < ApplicationController
|
|||
@contact = Contact.where(:id => params[:aspect][:contact_id]).first
|
||||
@person = Person.where(:id => params[:aspect][:person_id]).first
|
||||
@contact = current_user.contact_for(@person) || Contact.new
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :json => {:html => render_to_string(
|
||||
:partial => 'aspects/aspect_list_item',
|
||||
:locals => {:aspect => @aspect,
|
||||
:person => @person,
|
||||
:contact => @contact}
|
||||
), :aspect_id => @aspect.id}, :status => 201 }
|
||||
end
|
||||
else
|
||||
respond_with @aspect
|
||||
end
|
||||
|
|
|
|||
15
app/views/aspect_memberships/create.js.erb
Normal file
15
app/views/aspect_memberships/create.js.erb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
var element = $(".add", "li[data-guid=<%= @aspect.id %>]");
|
||||
|
||||
if( $("#no_contacts").is(':visible') ) {
|
||||
$("#no_contacts").fadeOut(200);
|
||||
}
|
||||
|
||||
$(".badges").prepend("<%= escape_javascript( aspect_badge(@aspect).html_safe ) %>");
|
||||
element.parent().html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>");
|
||||
|
||||
if($('#aspects_list').length == 1) {
|
||||
$('.aspect_list').attr('data-contact_id', "<%= @contact_id %>");
|
||||
$('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));})
|
||||
};
|
||||
|
||||
element.fadeTo(200,1);
|
||||
13
app/views/aspect_memberships/destroy.js.erb
Normal file
13
app/views/aspect_memberships/destroy.js.erb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
var element = $(".added", "li[data-guid=<%= @aspect.id %>]"),
|
||||
contactPictures = $(".contact_pictures");
|
||||
|
||||
if( contactPictures.length > 0 ) {
|
||||
if( contactPictures[0].childElementCount == 0 ) {
|
||||
$("#no_contacts").fadeIn(200);
|
||||
}
|
||||
}
|
||||
|
||||
$("a[data-guid=<%= @aspect_id %>]", ".aspects").parent().remove();
|
||||
element.parent().html("<%= escape_javascript(render('aspect_memberships/remove_from_aspect', :aspect => @aspect, :person => @contact.person, :contact => @contact)) %>");
|
||||
element.fadeTo(200,1);
|
||||
|
||||
|
|
@ -1,7 +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.
|
||||
|
||||
|
||||
.aspect_badge.single{:guid=>aspect.id}
|
||||
= link_to aspect.name, aspect
|
||||
3
app/views/aspects/create.js.erb
Normal file
3
app/views/aspects/create.js.erb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$('#aspects_list ul').append("<%= escape_javascript( render('aspects/aspect_list_item', :aspect => @aspect, :person => @person, :contact => @contact)) %>");
|
||||
$("#aspects_list ul li[data-guid='<%= @aspect.id %>'] .add.button").click();
|
||||
|
||||
|
|
@ -22,7 +22,6 @@ javascripts:
|
|||
- public/javascripts/vendor/Mustache.js
|
||||
- public/javascripts/vendor/charCount.js
|
||||
- public/javascripts/jquery.autocomplete-custom.js
|
||||
- public/javascripts/fileuploader-custom.js
|
||||
- public/javascripts/keycodes.js
|
||||
- public/javascripts/diaspora.js
|
||||
- public/javascripts/widgets/i18n.js
|
||||
|
|
@ -57,6 +56,7 @@ javascripts:
|
|||
- public/javascripts/aspect-filters.js
|
||||
- public/javascripts/contact-list.js
|
||||
- public/javascripts/aspect-edit-pane.js
|
||||
- public/javascripts/fileuploader-custom.js
|
||||
people:
|
||||
- public/javascripts/vendor/jquery.autoSuggest.custom.js
|
||||
photos:
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ Feature: sending and receiving requests
|
|||
|
||||
When I go to the home page
|
||||
Then I go to the manage aspects page
|
||||
|
||||
Then I should see 1 contact in "Super People"
|
||||
Then I go to the destroy user session page
|
||||
|
||||
|
|
|
|||
|
|
@ -43,21 +43,11 @@ $(document).ready(function() {
|
|||
$(this).fadeTo(200,0.4);
|
||||
});
|
||||
|
||||
$('.added').live('ajax:success', function(data, json, xhr) {
|
||||
var json = $.parseJSON(json);
|
||||
var contactPictures = $(".contact_pictures");
|
||||
|
||||
if( contactPictures.length > 0 ) {
|
||||
if( contactPictures[0].childElementCount == 0 ) {
|
||||
$("#no_contacts").fadeIn(200);
|
||||
}
|
||||
}
|
||||
|
||||
$(".aspect_badge[guid='" + json.aspect_id + "']", ".aspects").remove();
|
||||
$(this).parent().html(json.button_html);
|
||||
$(this).fadeTo(200,1);
|
||||
$('.add').live('ajax:loading', function() {
|
||||
$(this).fadeTo(200,0.4);
|
||||
});
|
||||
|
||||
|
||||
$('.added').live('ajax:failure', function(data, html, xhr) {
|
||||
if(confirm(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'))){
|
||||
var contact_id;
|
||||
|
|
@ -75,27 +65,6 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
|
||||
$('.add').live('ajax:loading', function() {
|
||||
$(this).fadeTo(200,0.4);
|
||||
});
|
||||
|
||||
$('.add').live('ajax:success', function(data, json, xhr) {
|
||||
var json = $.parseJSON(json);
|
||||
if( $("#no_contacts").is(':visible') ) {
|
||||
$("#no_contacts").fadeOut(200);
|
||||
}
|
||||
|
||||
$(".badges").prepend(json.badge_html);
|
||||
$(this).parent().html(json.button_html);
|
||||
|
||||
if($('#aspects_list').length == 1) {
|
||||
$('.aspect_list').attr('data-contact_id', json.contact_id);
|
||||
$('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));})
|
||||
};
|
||||
|
||||
$(this).fadeTo(200,1);
|
||||
});
|
||||
|
||||
$('.added').live('mouseover', function() {
|
||||
$(this).addClass("remove");
|
||||
$(this).children("img").attr("src","/images/icons/monotone_close_exit_delete.png");
|
||||
|
|
@ -104,11 +73,5 @@ $(document).ready(function() {
|
|||
$(this).children("img").attr("src","/images/icons/monotone_check_yes.png");
|
||||
});
|
||||
|
||||
$('.new_aspect').live('ajax:success', function(data, json, xhr){
|
||||
var json = JSON.parse(json);
|
||||
$('#aspects_list ul').append(json.html);
|
||||
$("#aspects_list ul li[data-guid='" + json.aspect_id + "'] .add.button").click();
|
||||
});
|
||||
|
||||
List.initialize();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue