diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb
index f7a1bdf45..d484dae52 100644
--- a/app/controllers/admin/users_new_interface_controller.rb
+++ b/app/controllers/admin/users_new_interface_controller.rb
@@ -240,6 +240,32 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
end
end
+
+ def edit_order
+ @users = User.all
+ end
+
+ def update_order
+ if params[:users].present?
+ params[:users].values.sort.each do |pair|
+ to_go = pair[0].to_i
+ if to_go > 0
+ user_at_position = User.where(position: to_go - 1).first
+ user = User.find(pair[1])
+ if user_at_position && !user_at_position == user
+ if user.position > user_at_position.position
+ user.move_above(user_at_position)
+ else
+ user.move_below(user_at_position)
+ end
+ elsif to_go > User.count
+ user.move_to_bottom
+ end
+ end
+ end
+ end
+ @users = User.all
+ end
protected
def get_tags
diff --git a/app/models/user/user.rb b/app/models/user/user.rb
index b726c0f3b..90b61f6d4 100644
--- a/app/models/user/user.rb
+++ b/app/models/user/user.rb
@@ -1,6 +1,8 @@
class User
include Mongoid::Document
+ include Mongoid::Tree
+ include Mongoid::Tree::Ordering # use mongoid-tree because mongoid-ordering needs mongoid(~>3.0)
include Mongoid::Timestamps
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable #, :timeoutable
diff --git a/app/views/admin/users_new_interface/_index_paginator.html.erb b/app/views/admin/users_new_interface/_index_paginator.html.erb
index ef2228410..058d8f278 100644
--- a/app/views/admin/users_new_interface/_index_paginator.html.erb
+++ b/app/views/admin/users_new_interface/_index_paginator.html.erb
@@ -1,12 +1,13 @@
-
-
- <% if is_admin? %>
- <%= link_to(new_admin_users_new_interface_path,:class=> "btn btn-primary pull-right") do%>
- <%= t(:add)%>
- <% end -%>
- <%end -%>
-
-
-
+
+
+ <% if is_admin? %>
+ <%= link_to t(:edit_order), edit_order_admin_users_new_interface_index_path, :class => "btn btn-primary" %>
+ <%= link_to(new_admin_users_new_interface_path,:class=> "btn btn-primary") do %>
+ <%= t(:add) %>
+ <% end -%>
+ <% end -%>
+
+
+
diff --git a/app/views/admin/users_new_interface/_user_edit_order.html.erb b/app/views/admin/users_new_interface/_user_edit_order.html.erb
new file mode 100644
index 000000000..35150b5af
--- /dev/null
+++ b/app/views/admin/users_new_interface/_user_edit_order.html.erb
@@ -0,0 +1,15 @@
+<%
+ if user_edit_order.sex == 'male'
+ @user_sex = 'gender-man'
+ elsif user_edit_order.sex == 'female'
+ @user_sex = 'gender-woman'
+ else
+ @user_sex = 'gender-none'
+ end
+%>
+
+ |
+ <%= link_to user_edit_order.position + 1, '#', class: 'edit_position', 'data-user-id' => user_edit_order.id %> |
+ <%= link_to user_edit_order.name, admin_users_new_interface_path(user_edit_order) %> |
+ <%= user_edit_order.email %> |
+
\ No newline at end of file
diff --git a/app/views/admin/users_new_interface/edit_order.html.erb b/app/views/admin/users_new_interface/edit_order.html.erb
new file mode 100644
index 000000000..3ea93f075
--- /dev/null
+++ b/app/views/admin/users_new_interface/edit_order.html.erb
@@ -0,0 +1,56 @@
+<% content_for :side_bar do %>
+ <%= render :partial => 'admin/users_new_interface/side_bar' %>
+<% end %>
+
+
+
+
+
+
+
+ <%= render partial: "user_edit_order", collection: @users %>
+
+
+
+
+
+
+ <%= link_to t(:update_), '#', class: "btn btn-primary pull-right" %>
+
+
+
+<% content_for :page_specific_javascript do %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/users_new_interface/update_order.js.erb b/app/views/admin/users_new_interface/update_order.js.erb
new file mode 100644
index 000000000..e9de95668
--- /dev/null
+++ b/app/views/admin/users_new_interface/update_order.js.erb
@@ -0,0 +1 @@
+$('#list-view table tbody').html("<%= j render partial: 'user_edit_order', collection: @users %>")
\ No newline at end of file
diff --git a/config/locales/new_ui.en.yml b/config/locales/new_ui.en.yml
index b6f072b3c..c064a8836 100644
--- a/config/locales/new_ui.en.yml
+++ b/config/locales/new_ui.en.yml
@@ -16,6 +16,7 @@ en:
deselect_all: Deselect all
detail: Detail
edit_category: Edit Categorie
+ edit_order: Edit order
editing:
tag: Editing tag
file:
@@ -37,6 +38,7 @@ en:
no_date: No date
no_file: No file
path: Path
+ position: Position
previous: Previous
remove: Remove
remove_default: Remove default
diff --git a/config/locales/new_ui.zh_tw.yml b/config/locales/new_ui.zh_tw.yml
index bb4ee69b4..b6bdfd4ea 100644
--- a/config/locales/new_ui.zh_tw.yml
+++ b/config/locales/new_ui.zh_tw.yml
@@ -16,6 +16,7 @@ zh_tw:
deselect_all: 取消全選
detail: 細節
edit_category: 編輯類別
+ edit_order: 編輯排序
editing:
tag: 編輯標籤
file:
@@ -37,6 +38,7 @@ zh_tw:
no_date: 無日期
no_file: 無檔案
path: 路徑
+ position: 排序
previous: 上一頁
remove: 移除
remove_default: 移除預設
diff --git a/config/routes.rb b/config/routes.rb
index 2263b3c77..843cff3be 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -214,6 +214,10 @@ Orbit::Application.routes.draw do
member do
get 'temp_edit'
end
+ collection do
+ get 'edit_order'
+ post 'update_order'
+ end
match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd
end
diff --git a/lib/tasks/new_ui.rake b/lib/tasks/new_ui.rake
index 70584a8db..84ed715c7 100644
--- a/lib/tasks/new_ui.rake
+++ b/lib/tasks/new_ui.rake
@@ -91,4 +91,8 @@ namespace :new_ui do
end
end
+ task :save_users => :environment do
+ User.all.each(&:save)
+ end
+
end