fixed index for universal

This commit is contained in:
rulingcom 2025-06-09 20:17:18 +08:00
parent 521a371808
commit e4655b5985
4 changed files with 62 additions and 12 deletions

View File

@ -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"

View File

@ -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 = "<a class='tabletitle' href='#{OrbitHelper.cal_url_to_show(module_app, entry)}'>#{text}</a>"
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)

View File

@ -182,3 +182,32 @@
</button>
</div>
<% end rescue nil %>
<script>
let audio;
$(".voice-player").on("click", function(){
let status = $(this).attr('status');
if (audio) {
audio.pause();
audio.currentTime = 0;
}
if (status == 'playing') {
$(this).attr('status', '');
$(this).find('i').removeClass('fa-pause');
$(this).find('i').addClass('fa-play');
} else {
let mp3_url = $(this).attr('data-content');
let _this = $(this);
audio = new Audio(mp3_url);
audio.play();
audio.onended = function() {
_this.attr('status', '');
_this.find('i').removeClass('fa-pause');
_this.find('i').addClass('fa-play');
};
$(this).find('i').removeClass('fa-play');
$(this).find('i').addClass('fa-pause');
$(this).attr('status', 'playing');
}
return false;
})
</script>

View File

@ -42,11 +42,13 @@
<div class="s-annc__post-body">{{body}}</div>
</section>
<div data-list="sections" data-level="0">
<div class="{{type}}">
<div class="type">
<div>{{section}}</div>
<ul class="universal-table" data-list="entries" data-level="1">
<li>
<div><a href="{{url_to_show}}" class="tabletitle">{{text}}</a></div>
<div data-list="rows" data-level="2">
<div>{{text}}</div>
</div>
</li>
</ul>
<div class="text">{{text}}</div>