Skip to content
Extraits de code Groupes Projets
Valider 5ff1bdae rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Groups can now be batch edited

parent 5ef442d9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -49,15 +49,21 @@ class GroupsController < ApplicationController
end
end
def move_person
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
flash[:error] = "didn't work #{params.inspect}"
end
if group = Group.first(:id => params[:to][:to])
redirect_to group
else
redirect_to Person.first(:id => params[:friend_id])
end
def move_friends
pp params
params[:moves].each{ |move|
move = move[1]
unless current_user.move_friend(move)
flash[:error] = "Group editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}."
redirect_to Group.first, :action => "edit"
return
end
}
flash[:notice] = "Groups edited successfully."
redirect_to Group.first, :action => "edit"
end
end
......@@ -16,7 +16,7 @@ class PeopleController < ApplicationController
@profile = @person.profile
@groups_with_person = current_user.groups_with_person(@person)
@all_groups = current_user.groups.collect{|x| [x.to_s, x.id]}
@groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]}
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
......
......@@ -3,22 +3,24 @@
= javascript_include_tag 'group-edit.js'
%h1.big_text
%h1{:class => 'big_text', :id => 'group_title'}
.back
= link_to "⇧ #{@group.name}", @group
= "Editing Groups"
%ul
%ul#group_list
- for group in @groups
%li.group
%li{:class => 'group'}
= group.name
%ul
stuff
%ul{:id => group.id}
dummy person for dropping onto
-for person in group.people
%li.person
= image_tag (person.profile.image_url(:thumb_small),:size => "30x30") unless person.profile.image_url.nil?
%li{:class => 'person', :id => person.id, :from_group_id => group.id}
= image_tag(person.profile.image_url(:thumb_small),:size => "30x30") unless person.profile.image_url.nil?
= person.real_name
%p
%br
= link_to 'Update Groups', '#', :class => 'button', :id => "move_friends_link"
#content_bottom
.back
......
......@@ -17,8 +17,8 @@
%li
%i= "friends since: #{how_long_ago(@person)}"
%li
= form_tag move_person_path
= select :to, :to, @all_groups
= form_tag move_friends_path
= select :to, :to, @groups_dropdown_array, :selected_value => @groups_with_person.first.id
= hidden_field_tag :from, :from, :value => @groups_with_person.first.id
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
= submit_tag "save"
......
......@@ -20,7 +20,7 @@ Diaspora::Application.routes.draw do
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
match 'groups/move_person', :to => 'groups#move_person', :as => 'move_person'
match 'groups/move_friends', :to => 'groups#move_friends', :as => 'move_friends'
#public routes
#
match 'webfinger', :to => 'publics#webfinger'
......
$('#move_friends_link').live( 'click',
function(){
$.post('/groups/move_friends',
{'moves' : $('#group_list').data()},
function(){ $('#group_title').html("Groups edited successfully!");});
});
$(function() {
$("li .person").draggable({
revert: true
......@@ -7,8 +14,14 @@ $(function() {
drop: function(event, ui) {
$(this).closest("ul").append(ui.draggable)
//$("<li class='person ui-draggable'></li>").text(ui.draggable.text()).appendTo(this).draggable();
var move = {};
move[ 'friend_id' ] = ui.draggable[0].id
move[ 'to' ] = $(this)[0].id;
move[ 'from' ] = ui.draggable[0].getAttribute('from_group_id');
$('#group_list').data( ui.draggable[0].id, move);
}
});
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter