sort fixes and edit fix

This commit is contained in:
Harry Bomrah 2015-11-16 21:47:27 +08:00
parent 4ce8637c53
commit 52c12560ef
2 changed files with 5 additions and 4 deletions

View File

@ -15,7 +15,7 @@ class Admin::UniversalTablesController < OrbitAdminController
if !@table.nil?
@columns = @table.table_columns.asc(:order)
@table_fields = @columns.collect{|tc| tc.title}
@entries = @table.table_entries.page(params[:page_id]).per(10)
@entries = @table.table_entries.desc(:created_at).page(params[:page_id]).per(10)
end
end
@ -37,8 +37,8 @@ class Admin::UniversalTablesController < OrbitAdminController
end
def edit_entry
id = params[:universal_table_id]
@entry = TableEntry.find(id)
id = params[:universal_table_id].split("-").last
@entry = TableEntry.where(:uid => id).first
@table = @entry.u_table
if !@table.nil?
@columns = @table.table_columns.asc(:order)

View File

@ -39,9 +39,10 @@ class UniversalTablesController < ApplicationController
columns.each do |column|
entries << column.table_entry
end
entries = entries.sort{|k,v| v["created_at"] <=> k["created_at"]}
entries = Kaminari.paginate_array(entries).page(params["page_no"]).per(OrbitHelper.page_data_count)
else
entries = table.table_entries.page(params["page_no"]).per(OrbitHelper.page_data_count)
entries = table.table_entries.desc(:created_at).page(params["page_no"]).per(OrbitHelper.page_data_count)
end
entries.each do |te|
cols = []