Add is_searchable field.
This commit is contained in:
parent
184c1384c7
commit
e2b132c21d
|
@ -3,7 +3,8 @@ class UniversalTablesController < ApplicationController
|
|||
def index
|
||||
params = OrbitHelper.params
|
||||
table = UTable.where(:category_id => OrbitHelper.page_categories.first).first rescue nil
|
||||
page = Page.where(:page_id => params[:page_id]).first
|
||||
page = OrbitHelper.page rescue Page.where(:page_id => params[:page_id]).first
|
||||
searchable_columns = []
|
||||
if !table.nil?
|
||||
reset = "hide"
|
||||
csrf_value = (0...46).map { ('a'..'z').to_a[rand(26)] }.join
|
||||
|
@ -76,7 +77,7 @@ class UniversalTablesController < ApplicationController
|
|||
title_class = title_class + "no-sort" if sort == "sort"
|
||||
title_class = title_class + " no-search" if search == "hide"
|
||||
|
||||
{
|
||||
col = {
|
||||
"title" => tc.title,
|
||||
"type" => tc.type,
|
||||
"key" => field_key,
|
||||
|
@ -87,6 +88,10 @@ class UniversalTablesController < ApplicationController
|
|||
"sort-url" => sort_url,
|
||||
"title-class" => title_class
|
||||
}
|
||||
if tc.is_searchable
|
||||
searchable_columns << col
|
||||
end
|
||||
col
|
||||
end
|
||||
tablecolumns = table.table_columns.where(:display_in_index => true).asc(:order)
|
||||
rows = []
|
||||
|
@ -128,6 +133,7 @@ class UniversalTablesController < ApplicationController
|
|||
reset = ""
|
||||
end
|
||||
{
|
||||
"searchable-columns" => searchable_columns,
|
||||
"head-columns" => table_heads,
|
||||
"rows" => rows,
|
||||
"total_pages" => total_pages,
|
||||
|
|
|
@ -8,6 +8,7 @@ class TableColumn
|
|||
field :type
|
||||
field :date_format, default: "YYYY/MM/DD"
|
||||
field :is_link_to_show, type: Boolean, default: false
|
||||
field :is_searchable, type: Boolean
|
||||
field :order, type: Integer
|
||||
field :make_categorizable, type: Boolean, default: false
|
||||
field :default_ordered_field, type: Boolean, default: false
|
||||
|
@ -36,4 +37,21 @@ class TableColumn
|
|||
{period_from: direction,period_to: direction}
|
||||
end
|
||||
end
|
||||
|
||||
def is_searchable
|
||||
tmp = self[:is_searchable]
|
||||
if tmp.nil?
|
||||
case self.type
|
||||
when "date", "period","image"
|
||||
tmp = false
|
||||
else
|
||||
tmp = self.display_in_index
|
||||
end
|
||||
end
|
||||
tmp
|
||||
end
|
||||
|
||||
def self.filter_searchable
|
||||
self.any_of({is_searchable: true}, {is_searchable:nil, display_in_index: true, :type.nin=> ["date", "period","image"]})
|
||||
end
|
||||
end
|
|
@ -77,6 +77,9 @@
|
|||
<label class="checkbox inline attributes-checkbox">
|
||||
<%= f.check_box :make_categorizable %> Categorizable
|
||||
</label>
|
||||
<label class="checkbox inline attributes-checkbox ">
|
||||
<%= f.check_box :is_searchable %> Searchable
|
||||
</label>
|
||||
</span>
|
||||
<% select_values = UTable::DATE_FORMATS.collect{|ft| [ft.upcase,ft]} %>
|
||||
<label class="checkbox date_format inline attributes-checkbox <%= column.type == "date" || column.type == "period" ? "" : "hide" %>">
|
||||
|
|
Loading…
Reference in New Issue