added filters and file and editor search
This commit is contained in:
parent
f00fe8a348
commit
77097850e0
|
|
@ -118,6 +118,7 @@ when "file"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_query(params)
|
def get_query(params)
|
||||||
if params["column"].present?
|
if params["column"].present?
|
||||||
q = {params["column"] => params["q"]}
|
q = {params["column"] => params["q"]}
|
||||||
|
|
@ -146,10 +147,15 @@ end
|
||||||
# regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
|
# regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
|
||||||
# end
|
# end
|
||||||
regex = Regexp.new(".*"+v+".*", "i")
|
regex = Regexp.new(".*"+v+".*", "i")
|
||||||
if column.type == "text"
|
case column.type
|
||||||
|
when "text"
|
||||||
columns = column.column_entries.any_of([{"text.en" => regex}, {"text.zh_tw" => regex}])
|
columns = column.column_entries.any_of([{"text.en" => regex}, {"text.zh_tw" => regex}])
|
||||||
elsif column.type == "editor"
|
when "editor"
|
||||||
columns = column.column_entries.any_of([{"content.en" => regex}, {"content.zh_tw" => regex}])
|
columns = column.column_entries.any_of([{"content.en" => regex}, {"content.zh_tw" => regex}])
|
||||||
|
when "file"
|
||||||
|
column_ids = column.column_entries.pluck(:id)
|
||||||
|
filtered_column_ids = ColumnEntryFile.where(:column_entry_id.in => column_ids).any_of([{ "file_title.en" => regex },{"file_title.zh_tw" => regex }]).pluck(:column_entry)
|
||||||
|
columns = ColumnEntry.where(:id.in => filtered_column_ids)
|
||||||
end
|
end
|
||||||
# .or(:"content.en" => regex).or(:"content.zh_tw" => regex)
|
# .or(:"content.en" => regex).or(:"content.zh_tw" => regex)
|
||||||
tmp = columns.pluck(:table_entry_id)
|
tmp = columns.pluck(:table_entry_id)
|
||||||
|
|
@ -292,7 +298,7 @@ end
|
||||||
# csrf_input = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\">"
|
# csrf_input = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\">"
|
||||||
csrf_input = ""
|
csrf_input = ""
|
||||||
have_serial_number = (page.layout != 'index1')
|
have_serial_number = (page.layout != 'index1')
|
||||||
table_heads = table.table_columns.where(:display_in_index => true).asc(:order).collect do |tc|
|
table_heads = table.table_columns.where(:is_searchable => true).asc(:order).collect do |tc|
|
||||||
field_key = tc.key
|
field_key = tc.key
|
||||||
field_value = params_q[field_key]
|
field_value = params_q[field_key]
|
||||||
field_value = nil if field_value.blank?
|
field_value = nil if field_value.blank?
|
||||||
|
|
@ -310,7 +316,7 @@ end
|
||||||
search = "hide"
|
search = "hide"
|
||||||
sort_url = "#"
|
sort_url = "#"
|
||||||
sort = "hide"
|
sort = "hide"
|
||||||
when "editor"
|
when "editor","file"
|
||||||
sort_url = "#"
|
sort_url = "#"
|
||||||
sort = "hide"
|
sort = "hide"
|
||||||
sort_class = "sort hide"
|
sort_class = "sort hide"
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,13 @@
|
||||||
<%= f.check_box :is_searchable %> Searchable
|
<%= f.check_box :is_searchable %> Searchable
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
|
<% if column.type == "file" || column.type == "editor" %>
|
||||||
|
<span class="link_to_show2">
|
||||||
|
<label class="checkbox inline attributes-checkbox ">
|
||||||
|
<%= f.check_box :is_searchable %> Searchable
|
||||||
|
</label>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
<% select_values = UTable::DATE_FORMATS.collect{|ft| [ft.upcase,ft]} %>
|
<% 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" %>">
|
<label class="checkbox date_format inline attributes-checkbox <%= column.type == "date" || column.type == "period" ? "" : "hide" %>">
|
||||||
Date Format <%= f.select :date_format, select_values%>
|
Date Format <%= f.select :date_format, select_values%>
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,14 @@
|
||||||
<td>
|
<td>
|
||||||
<%= table.table_entries.count %>
|
<%= table.table_entries.count %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="lasttd">
|
||||||
<% if can_edit %>
|
<% if can_edit %>
|
||||||
<form action="/admin/universal_tables/import_data_from_excel" method="post" enctype="multipart/form-data" class="import_from_excel_form">
|
<form action="/admin/universal_tables/import_data_from_excel" method="post" enctype="multipart/form-data" class="import_from_excel_form">
|
||||||
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
||||||
<input type="file" name="import_data" />
|
<input class="import_data" type="file" name="import_data" />
|
||||||
<button class="btn btn-primary btn-small"><i class="icons-upload"></i></button>
|
<button class="btn btn-primary btn-small"><i class="icons-upload"></i></button>
|
||||||
<input type="hidden" name="universal_table_id" value="<%= table.id.to_s %>" />
|
<input type="hidden" name="universal_table_id" value="<%= table.id.to_s %>" />
|
||||||
<a href="<%= admin_universal_table_export_structure_path(table, :format => "xlsx") %>"><%= t("universal_table.export_structure") %></a>
|
<a class="Downloadtablestructure" href="<%= admin_universal_table_export_structure_path(table, :format => "xlsx") %>"><%= t("universal_table.export_structure") %></a>
|
||||||
</form>
|
</form>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -47,3 +47,15 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<style>
|
||||||
|
.import_data{
|
||||||
|
max-width: 180px;
|
||||||
|
}
|
||||||
|
.lasttd{
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
.Downloadtablestructure{
|
||||||
|
padding-left: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -121,6 +121,13 @@
|
||||||
label.addClass("hide");
|
label.addClass("hide");
|
||||||
label.find("input[type=checkbox]").prop("checked",false);
|
label.find("input[type=checkbox]").prop("checked",false);
|
||||||
}
|
}
|
||||||
|
label = el.parent().find("span.link_to_show2");
|
||||||
|
if(el.val() == "editor" || el.val() == "file"){
|
||||||
|
label.removeClass("hide");
|
||||||
|
}else{
|
||||||
|
label.addClass("hide");
|
||||||
|
label.find("input[type=checkbox]").prop("checked",false);
|
||||||
|
}
|
||||||
label = el.parent().find("label.date_format");
|
label = el.parent().find("label.date_format");
|
||||||
if(el.val() == "date" || el.val() == "period"){
|
if(el.val() == "date" || el.val() == "period"){
|
||||||
label.removeClass("hide");
|
label.removeClass("hide");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue