added a route to get table entries
This commit is contained in:
parent
2f99e39bf2
commit
b4879bd7ae
|
@ -48,6 +48,21 @@ class Admin::UniversalTablesController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
|
||||
def get_entries
|
||||
table = UTable.where(:uid => params["uid"]).first rescue nil
|
||||
data = []
|
||||
if !table.nil?
|
||||
enteries = search_data(table, 50)
|
||||
enteries.each do |entry|
|
||||
data << {
|
||||
"id" => entry.id.to_s,
|
||||
"text" => entry.column_entries.first.text
|
||||
}
|
||||
end
|
||||
end
|
||||
render :json => data.to_json
|
||||
end
|
||||
|
||||
def export_structure
|
||||
uid = params[:universal_table_id].split("-").last
|
||||
@table = UTable.where(:uid => uid).first rescue nil
|
||||
|
@ -262,7 +277,7 @@ class Admin::UniversalTablesController < OrbitAdminController
|
|||
|
||||
private
|
||||
|
||||
def search_data(table)
|
||||
def search_data(table, per=10)
|
||||
keywords = params["q"]
|
||||
keywords = keywords.strip.nil? ? keywords : keywords.strip
|
||||
regexes = keywords.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
|
||||
|
@ -277,7 +292,7 @@ class Admin::UniversalTablesController < OrbitAdminController
|
|||
columns_count = columns.count
|
||||
columns_count = 1 if columns_count==0
|
||||
columns = Kaminari.paginate_array(columns,limit: columns_count)
|
||||
entries = TableEntry.where(:u_table_id=>table.id).sorting(params: params,table: table,column_entries: columns,page_num: params[:page],per: 10)
|
||||
entries = TableEntry.where(:u_table_id=>table.id).sorting(params: params,table: table,column_entries: columns,page_num: params[:page],per: per)
|
||||
end
|
||||
|
||||
def table_params
|
||||
|
|
|
@ -14,21 +14,22 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||
|
||||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
post "/universal_tables/add_entry", to: 'universal_tables#add_entry'
|
||||
post "/universal_tables/add_entry", to: 'universal_tables#add_entry'
|
||||
get "/universal_tables/get_entries", to: 'universal_tables#get_entries'
|
||||
patch "/universal_tables/update_entry", to: 'universal_tables#update_entry'
|
||||
post "/universal_tables/import_data_from_excel", to: 'universal_tables#import_data_from_excel'
|
||||
get "universal_tables/checkforthread", to: "universal_tables#checkforthread"
|
||||
resources :universal_tables do
|
||||
resources :universal_tables do
|
||||
get "new_entry"
|
||||
delete "delete_entry"
|
||||
get "edit_entry"
|
||||
get "edit_sort"
|
||||
post "update_sort", to: 'universal_tables#update_sort'
|
||||
get "export_structure"
|
||||
member do
|
||||
member do
|
||||
get "export_data"
|
||||
end
|
||||
end
|
||||
|
@ -36,5 +37,5 @@ Rails.application.routes.draw do
|
|||
get "/xhr/universal_table/export", to: 'universal_tables#export_filtered'
|
||||
get "/xhr/universal_table/download", to: "universal_tables#download_file"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue