Fix serial number in frontend index.

This commit is contained in:
邱博亞 2024-08-11 10:19:08 +08:00
parent e2b132c21d
commit 7c83a992d2
2 changed files with 20 additions and 16 deletions

View File

@ -17,6 +17,7 @@ class UniversalTablesController < ApplicationController
end
query_string += "&page_no=#{params_no}" if params_no.present?
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|
field_key = tc.key
field_value = params_q[field_key]
@ -97,9 +98,28 @@ class UniversalTablesController < ApplicationController
rows = []
entries = get_entries(params, table, page)
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|
cols = []
sort_value = ""
if have_serial_number
serial_number_count += 1
cols << {"text" => serial_number_count.to_s}
end
tablecolumns.each do |column|
ce = te.column_entries.where(:table_column_id => column.id).first rescue nil
if !ce.nil?

View File

@ -36,21 +36,9 @@
.universal-table-index tbody {
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 {
width: 4em;
}
.universal-th-icon {
border: 1px solid #eee;
padding: 5px 8px;
@ -102,7 +90,3 @@
<div>{{total_entries}}</div>
<div>{{export_button}}</div>
{{pagination_goes_here}}
<script>
$('.universal-table-index thead tr').prepend('<th></th>')
$('.universal-table-index tbody tr').prepend('<td></td>')
</script>