fix hashtags and headers

This commit is contained in:
rulingcom 2025-08-05 22:00:48 +08:00
parent 0b1c690ecf
commit 6a846ea91e
2 changed files with 27 additions and 15 deletions

View File

@ -182,13 +182,13 @@ class UniversalTablesController < ApplicationController
if tag.nil?
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}).can_display.sorting(params: params,table: table,page_num: params["page_no"],per: OrbitHelper.page_data_count)
else
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}, :table_tag_ids => tag.id).can_display.sorting(params: params,table: table,page_num: params["page_no"],per: OrbitHelper.page_data_count)
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}, :table_tag_ids.in => [tag.id]).can_display.sorting(params: params,table: table,page_num: params["page_no"],per: OrbitHelper.page_data_count)
end
else
if tag.nil?
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}).can_display.sorting(params: params,table: table,paginated: false)
else
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}, :table_tag_ids => tag.id).can_display.sorting(params: params,table: table,paginated: false)
entries = TableEntry.where(:u_table_id=>table.id, "have_data.#{I18n.locale}" => {"$in" => [nil, true]}, :table_tag_ids.in => [tag.id]).can_display.sorting(params: params,table: table,paginated: false)
end
end
end
@ -298,7 +298,8 @@ class UniversalTablesController < ApplicationController
# csrf_input = "<input type=\"hidden\" name=\"authenticity_token\" value=\"#{csrf_value}\">"
csrf_input = ""
have_serial_number = (page.layout != 'index1')
table_heads = table.table_columns.where(:is_searchable => true).asc(:order).collect do |tc|
tablecolumns = table.table_columns.where(:display_in_index => true).asc(:order)
table_heads = tablecolumns.collect do |tc|
field_key = tc.key
field_value = params_q[field_key]
field_value = nil if field_value.blank?
@ -383,10 +384,21 @@ class UniversalTablesController < ApplicationController
end
col
end
tablecolumns = table.table_columns.where(:display_in_index => true).asc(:order)
rows = []
entries = get_entries(params, table, page)
total_pages = entries.total_pages
table_heads << {
"title" => t("universal_table.hashtags"),
"type" => "hashtag",
"key" => "",
"search" => "hide",
"form-field" => "",
"sort" => "hide",
"sort-class" => "sort hide",
"sort-url" => "",
"title-class" => " no-search"
}
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

View File

@ -27,28 +27,28 @@ namespace :universal_table_tasks do
desc "Import entries from XLSX file"
task :import, [:file_path, :table_id, :site_locales] => :environment do |t, args|
def create_get_table_tags(entry,new_tags=nil)
if new_tags.nil?
new_tags = params["table_tags"].split(",")
end
def create_get_table_tags(entry,new_tags=nil,table)
tags = []
entry.table_tags = []
new_tags.each do |tag|
if is_uuid?(tag) === false
tt = get_tag(tag, table)
if tt.nil?
tt = TableTag.new
tt.u_table_id = entry.u_table.id
tt.title = tag.downcase.strip
tt.save
tt.table_entry_ids << entry.id
entry.table_tags << tt
else
tt = TableTag.find(tag)
tt.table_entry_ids << entry.id
entry.table_tags << tt
end
entry.save
tt.save
end
return tags
end
def is_uuid?(str)
!!(str =~ /\A[\da-f]{24}\z/i || str =~ /\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i)
def get_tag(str, table)
TableTag.where(:title => str, :u_table_id => table.id).first rescue nil
end
file_path = args[:file_path]
@ -163,7 +163,7 @@ namespace :universal_table_tasks do
end
tags_text = row.cells[-2].value.to_s rescue ""
create_get_table_tags(te, tags_text.split(";")) if row.cells.count >= 2
create_get_table_tags(te, tags_text.split(";"), table) if row.cells.count >= 2
related_uids = row.cells[-1].value.to_s.split(";").map(&:strip)
related_ids = TableEntry.where(:uid.in => related_uids).pluck(:id)