Fix serial number in frontend index.
This commit is contained in:
parent
e2b132c21d
commit
7c83a992d2
|
@ -17,6 +17,7 @@ class UniversalTablesController < ApplicationController
|
||||||
end
|
end
|
||||||
query_string += "&page_no=#{params_no}" if params_no.present?
|
query_string += "&page_no=#{params_no}" if params_no.present?
|
||||||
csrf_input = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\">"
|
csrf_input = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\">"
|
||||||
|
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(:display_in_index => 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]
|
||||||
|
@ -97,9 +98,28 @@ class UniversalTablesController < ApplicationController
|
||||||
rows = []
|
rows = []
|
||||||
entries = get_entries(params, table, page)
|
entries = get_entries(params, table, page)
|
||||||
total_pages = entries.total_pages
|
total_pages = entries.total_pages
|
||||||
|
if have_serial_number
|
||||||
|
page_no_offset = (params_no.present? ? [0, params_no.to_i - 1].max : 0)
|
||||||
|
serial_number_count = page_no_offset * OrbitHelper.page_data_count
|
||||||
|
table_heads.insert(0, {
|
||||||
|
"title" => "No.",
|
||||||
|
"type" => "",
|
||||||
|
"key" => "",
|
||||||
|
"search" => "hide",
|
||||||
|
"form-field" => "",
|
||||||
|
"sort" => "hide",
|
||||||
|
"sort-class" => "sort hide",
|
||||||
|
"sort-url" => "",
|
||||||
|
"title-class" => " no-search"
|
||||||
|
})
|
||||||
|
end
|
||||||
entries.each do |te|
|
entries.each do |te|
|
||||||
cols = []
|
cols = []
|
||||||
sort_value = ""
|
sort_value = ""
|
||||||
|
if have_serial_number
|
||||||
|
serial_number_count += 1
|
||||||
|
cols << {"text" => serial_number_count.to_s}
|
||||||
|
end
|
||||||
tablecolumns.each do |column|
|
tablecolumns.each do |column|
|
||||||
ce = te.column_entries.where(:table_column_id => column.id).first rescue nil
|
ce = te.column_entries.where(:table_column_id => column.id).first rescue nil
|
||||||
if !ce.nil?
|
if !ce.nil?
|
||||||
|
|
|
@ -36,21 +36,9 @@
|
||||||
.universal-table-index tbody {
|
.universal-table-index tbody {
|
||||||
counter-reset: item;
|
counter-reset: item;
|
||||||
}
|
}
|
||||||
|
|
||||||
.universal-table-index tbody > tr > td:first-child:before {
|
|
||||||
content: counter(item);
|
|
||||||
counter-increment: item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.universal-table-index thead > tr > th:first-child:before {
|
|
||||||
content: "No.";
|
|
||||||
}
|
|
||||||
|
|
||||||
.universal-table-index thead > tr > th:first-child {
|
.universal-table-index thead > tr > th:first-child {
|
||||||
width: 4em;
|
width: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.universal-th-icon {
|
.universal-th-icon {
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
|
@ -102,7 +90,3 @@
|
||||||
<div>{{total_entries}}</div>
|
<div>{{total_entries}}</div>
|
||||||
<div>{{export_button}}</div>
|
<div>{{export_button}}</div>
|
||||||
{{pagination_goes_here}}
|
{{pagination_goes_here}}
|
||||||
<script>
|
|
||||||
$('.universal-table-index thead tr').prepend('<th></th>')
|
|
||||||
$('.universal-table-index tbody tr').prepend('<td></td>')
|
|
||||||
</script>
|
|
||||||
|
|
Loading…
Reference in New Issue