Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRaphael Sofaer <raphael@joindiaspora.com>2011-07-29 01:36:41 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-29 01:36:41 +0400
commitddd4424df81b6f8606837024ad3d961ee7974d7d (patch)
tree079bb58f610390ab5fbdba645534d0d3a0dd09c5 /app
parent444231956008fdd33f234e6334d48c4ea3821b70 (diff)
parent0855144a0aebcc9cf7f2afe43a054aae6cb857e3 (diff)
Merge remote branch 'manuels/842-sortable-aspects'
Conflicts: app/models/user.rb db/schema.rb
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb6
-rw-r--r--app/models/aspect.rb2
-rw-r--r--app/models/user.rb10
-rw-r--r--app/views/aspects/_aspect_listings.haml14
4 files changed, 27 insertions, 5 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 2fce8c079..9692cc778 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -22,9 +22,9 @@ class UsersController < ApplicationController
def update
password_changed = false
- if u = params[:user]
- @user = current_user
+ @user = current_user
+ if u = params[:user]
u.delete(:password) if u[:password].blank?
u.delete(:password_confirmation) if u[:password].blank? and u[:password_confirmation].blank?
u.delete(:language) if u[:language].blank?
@@ -57,6 +57,8 @@ class UsersController < ApplicationController
flash[:error] = I18n.t 'users.update.unconfirmed_email_not_changed'
end
end
+ elsif aspect_order = params[:reorder_aspects]
+ @user.reorder_aspects(aspect_order)
end
respond_to do |format|
diff --git a/app/models/aspect.rb b/app/models/aspect.rb
index 0955e637f..feeec4af1 100644
--- a/app/models/aspect.rb
+++ b/app/models/aspect.rb
@@ -15,7 +15,7 @@ class Aspect < ActiveRecord::Base
validates_length_of :name, :maximum => 20
validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false
- attr_accessible :name, :contacts_visible
+ attr_accessible :name, :contacts_visible, :order_id
before_validation do
name.strip!
diff --git a/app/models/user.rb b/app/models/user.rb
index fdd391b7f..b6be53b8a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -34,7 +34,7 @@ class User < ActiveRecord::Base
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id, :dependent => :destroy
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id, :dependent => :destroy
- has_many :aspects
+ has_many :aspects, :order => 'order_id ASC'
has_many :aspect_memberships, :through => :aspects
has_many :contacts
has_many :contact_people, :through => :contacts, :source => :person
@@ -394,4 +394,12 @@ class User < ActiveRecord::Base
self.confirm_email_token = unconfirmed_email ? ActiveSupport::SecureRandom.hex(15) : nil
end
end
+
+ def reorder_aspects(aspect_order)
+ i = 0
+ aspect_order.each do |id|
+ self.aspects.find(id).update_attributes({ :order_id => i })
+ i += 1
+ end
+ end
end
diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml
index 82219dcc8..7d25d5dfa 100644
--- a/app/views/aspects/_aspect_listings.haml
+++ b/app/views/aspects/_aspect_listings.haml
@@ -11,7 +11,7 @@
%ul.sub_nav
- for aspect in all_aspects
- %li{:class => ("active" if params["a_id"].to_i == aspect.id)}
+ %li{:id => aspect.id, :class => ("active" if params["a_id"].to_i == aspect.id)}
.edit
= link_to image_tag("icons/pencil.svg", :height => 12), edit_aspect_path(aspect), :rel => "facebox"
@@ -36,3 +36,15 @@
= only_sharing_count
= t('contacts.index.only_sharing_with_me')
+ :javascript
+ $(document).ready(function() {
+ jQuery('#aspect_nav.left_nav .all_aspects .sub_nav').sortable({
+ items: 'li[id]',
+ update: function(event, ui) {
+ var order = jQuery(this).sortable('toArray');
+ var obj = { 'reorder_aspects': order, 'authenticity_token': '#{form_authenticity_token}', '_method': 'put' };
+ jQuery.ajax('/user', { type: 'post', dataType: 'script', data: obj });
+ }
+ });
+ });
+