fix error
This commit is contained in:
1 parent
aeffcf2630
commit
0d8972ea29
22 files changed
+394
-93
No files matched your search
@@ -2,12 +2,38 @@ class Admin::UniversalTablesController < OrbitAdminController
|
||||
def index
|
||||
@table_fields = ["universal_table.table_name","universal_table.created_time","universal_table.total_no_of_entries", "universal_table.import_from_excel"]
|
||||
|
||||
@tables = UTable.where(:title.ne => "")
|
||||
.order_by(sort)
|
||||
.with_categories(filters("category"))
|
||||
@tables = UTable.where(:title.ne => "")
|
||||
.order_by(sort)
|
||||
.with_categories(filters("category"))
|
||||
|
||||
end
|
||||
|
||||
def update_sort
|
||||
uid = params[:universal_table_id].split("-").last
|
||||
@table = UTable.where(:uid => uid).first rescue nil
|
||||
if !@table.nil?
|
||||
ids = params[:ids]
|
||||
ids = ids.reverse if @table.sort_number_order_direction=='desc'
|
||||
ids.each_with_index do |id,i|
|
||||
TableEntry.where(id: id).update(sort_number: i)
|
||||
end
|
||||
@entries = TableEntry.where(u_table_id: @table.id).sorting(params: params,table: @table)
|
||||
@columns = @table.table_columns.asc(:order)
|
||||
@table_fields = ['universal_table.sort_number']+@columns.collect{|tc| tc.title} + ['universal_table.created_at']
|
||||
render 'update_sort',layout: false
|
||||
end
|
||||
end
|
||||
|
||||
def edit_sort
|
||||
uid = params[:universal_table_id].split("-").last
|
||||
@table = UTable.where(:uid => uid).first rescue nil
|
||||
if !@table.nil?
|
||||
@entries = TableEntry.where(u_table_id: @table.id).sorting(params: params,table: @table)
|
||||
@columns = @table.table_columns.asc(:order)
|
||||
@table_fields = ['universal_table.sort_number']+@columns.collect{|tc| tc.title} + ['universal_table.created_at']
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
uid = params[:id].split("-").last
|
||||
@table = UTable.where(:uid => uid).first rescue nil
|
||||
@@ -17,7 +43,7 @@ class Admin::UniversalTablesController < OrbitAdminController
|
||||
if params[:q].present?
|
||||
@entries = search_data(@table)
|
||||
else
|
||||
@entries = @table.table_entries.criteria.sorting(params: params,table: @table,page_num: params[:page],per: 10)
|
||||
@entries = TableEntry.where(u_table_id: @table.id).sorting(params: params,table: @table,page_num: params[:page],per: 10)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -88,6 +114,8 @@ class Admin::UniversalTablesController < OrbitAdminController
|
||||
skip = skip + 1
|
||||
end
|
||||
ce.text_translations = v
|
||||
when "integer"
|
||||
ce.number = (val.blank? ? nil : val)
|
||||
when "editor"
|
||||
v = {}
|
||||
@site_in_use_locales.sort.each_with_index do |locale,x|
|
||||
@@ -110,6 +138,7 @@ class Admin::UniversalTablesController < OrbitAdminController
|
||||
ce.period_to = val
|
||||
end
|
||||
ce.table_column_id = tc.id
|
||||
ce.u_table_id = table.id
|
||||
ce.save
|
||||
te.column_entries << ce
|
||||
end
|
||||
|
||||
@@ -34,13 +34,22 @@ class UniversalTablesController < ApplicationController
|
||||
sort_class = "sort hide"
|
||||
when "text"
|
||||
if tc.make_categorizable
|
||||
select_values = tc.column_entries.distinct(:text).uniq
|
||||
select_values = tc.column_entries.distinct(:text)
|
||||
form_field = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\"><select class='form-control' name='q'>"
|
||||
select_values.each do |sv|
|
||||
form_field = form_field + "<option value='#{sv[I18n.locale.to_s]}'>#{sv[I18n.locale.to_s]}</option>"
|
||||
end
|
||||
form_field = form_field + "</select>"
|
||||
end
|
||||
when "integer"
|
||||
if tc.make_categorizable
|
||||
select_values = tc.column_entries.distinct(:number)
|
||||
form_field = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\"><select class='form-control' name='q'>"
|
||||
select_values.each do |sv|
|
||||
form_field = form_field + "<option value='#{sv}'>#{sv}</option>"
|
||||
end
|
||||
form_field = form_field + "</select>"
|
||||
end
|
||||
end
|
||||
|
||||
if params["sortcolumn"] == tc.key
|
||||
@@ -77,6 +86,8 @@ class UniversalTablesController < ApplicationController
|
||||
case ce.type
|
||||
when "text"
|
||||
text = ce.text
|
||||
when "integer"
|
||||
text = ce.number
|
||||
when "editor"
|
||||
text = ce.content
|
||||
when "date"
|
||||
@@ -146,6 +157,8 @@ class UniversalTablesController < ApplicationController
|
||||
case ce.type
|
||||
when "text"
|
||||
text = ce.text
|
||||
when "integer"
|
||||
text = ce.number
|
||||
when "editor"
|
||||
text = ce.content
|
||||
when "date"
|
||||
@@ -215,6 +228,8 @@ class UniversalTablesController < ApplicationController
|
||||
case ce.type
|
||||
when "text"
|
||||
text = ce.text
|
||||
when "integer"
|
||||
text = ce.number
|
||||
when "editor"
|
||||
text = ce.content
|
||||
when "date"
|
||||
|
||||
Reference in new issue
Block a user