From e4655b5985be45052e8184b52c3df6d62b1830af Mon Sep 17 00:00:00 2001 From: rulingcom Date: Mon, 9 Jun 2025 20:17:18 +0800 Subject: [PATCH] fixed index for universal --- app/controllers/curations_controller.rb | 12 ++-------- app/models/curation_post_section.rb | 27 +++++++++++++++++++++++ app/views/curations/show.html.erb | 29 +++++++++++++++++++++++++ modules/curation/show.html.erb | 6 +++-- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/app/controllers/curations_controller.rb b/app/controllers/curations_controller.rb index 56cdb31..29c362b 100644 --- a/app/controllers/curations_controller.rb +++ b/app/controllers/curations_controller.rb @@ -702,21 +702,13 @@ class CurationsController < ApplicationController return {} end end - module_app = ModuleApp.find_by_key("universal_table") sections = [] sections = announcement.curation_post_sections.map do |section| if section.section_type == "universal_table" - entries = section.get_table_entries.map do |entry| - { - "uid" => entry.uid, - "type" => section.section_type, - "url_to_show" => OrbitHelper.cal_url_to_show(module_app, entry), - "text" => entry.column_entries.first.text - } - end { "section" => section.title, - "entries" => entries, + "entries" => section.get_table_entries_for_frontend, + "url_to_show" => "", "text" => "" } elsif section.section_type == "text" diff --git a/app/models/curation_post_section.rb b/app/models/curation_post_section.rb index e168da3..249eeec 100644 --- a/app/models/curation_post_section.rb +++ b/app/models/curation_post_section.rb @@ -11,6 +11,33 @@ class CurationPostSection belongs_to :curation_post + def get_table_entries_for_frontend + module_app = ModuleApp.find_by_key("universal_table") + tids = self.table_entries.split(',') + table_entries = TableEntry.find(tids) + table_entries.map do |entry| + rows = [] + entry.column_entries.each do |ce| + ct = ce.table_column + next if ct.nil? + next if ct.display_in_index === false + text = ce.get_frontend_text(ct) + if ct.is_link_to_show + text = "#{text}" + end + rows << { + "title" => ct.title, + "text" => text + } if text != "" + end + { + "uid" => entry.uid, + "type" => self.section_type, + "rows" => rows + } + end + end + def get_table_entries tids = self.table_entries.split(',') TableEntry.find(tids) diff --git a/app/views/curations/show.html.erb b/app/views/curations/show.html.erb index bd2528a..908c9e8 100644 --- a/app/views/curations/show.html.erb +++ b/app/views/curations/show.html.erb @@ -182,3 +182,32 @@ <% end rescue nil %> + diff --git a/modules/curation/show.html.erb b/modules/curation/show.html.erb index 62fdf87..0e2a692 100644 --- a/modules/curation/show.html.erb +++ b/modules/curation/show.html.erb @@ -42,11 +42,13 @@
{{body}}
-
+
{{section}}
{{text}}