fix unit sort

This commit is contained in:
nccu 2014-12-08 15:19:37 +08:00
parent d7fc2b9aaf
commit 6cbd47ced2
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ class Admin::NewsAdminsController < OrbitAdminController
def index def index
@unit_table_fields = ['news.unit','news.department'] @unit_table_fields = ['news.unit','news.department']
@unit = Unit.new @unit = Unit.new
sort = (!params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:id=>"asc"})
@units = Unit.order_by(sort) @units = Unit.order_by(sort)
end end
@ -20,6 +21,7 @@ class Admin::NewsAdminsController < OrbitAdminController
def edit def edit
@unit = Unit.find(params[:id]) @unit = Unit.find(params[:id])
@unit_table_fields = ['news.unit','news.department'] @unit_table_fields = ['news.unit','news.department']
sort = (!params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:id=>"asc"})
@units = Unit.order_by(sort) @units = Unit.order_by(sort)
@url = admin_news_admin_path(@unit) @url = admin_news_admin_path(@unit)

View File

@ -34,7 +34,8 @@ class Admin::NewsController < OrbitAdminController
@statuses = [] @statuses = []
@news_bulletin = NewsBulletin.new @news_bulletin = NewsBulletin.new
@news_bulletin.email_sentdate = Time.now @news_bulletin.email_sentdate = Time.now
@unit = Unit.all sort = (!params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:id=>"asc"})
@unit = Unit.all.order_by(sort)
end end
def create def create
@ -70,7 +71,8 @@ class Admin::NewsController < OrbitAdminController
def edit def edit
if can_edit_or_delete?(@news_bulletin) if can_edit_or_delete?(@news_bulletin)
@unit = Unit.all sort = (!params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:id=>"asc"})
@unit = Unit.all.order_by(sort)
@department = Department.where(:unit_id => @news_bulletin.unit_id) @department = Department.where(:unit_id => @news_bulletin.unit_id)
@tags = @module_app.tags @tags = @module_app.tags
@categories = @module_app.categories.enabled @categories = @module_app.categories.enabled