fix for backend and added frontend support
This commit is contained in:
parent
de407b718f
commit
afb146abb9
|
@ -686,6 +686,7 @@ class CurationsController < ApplicationController
|
||||||
end
|
end
|
||||||
announcement = CurationPost.where(:uid => uid).first if announcement.nil?
|
announcement = CurationPost.where(:uid => uid).first if announcement.nil?
|
||||||
return nil if announcement.nil?
|
return nil if announcement.nil?
|
||||||
|
return {} if (announcement.category.disable rescue false)
|
||||||
@bulletin = announcement
|
@bulletin = announcement
|
||||||
|
|
||||||
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/curations/#{announcement.id.to_s}/edit" : ""
|
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/curations/#{announcement.id.to_s}/edit" : ""
|
||||||
|
@ -701,8 +702,34 @@ class CurationsController < ApplicationController
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
module_app = ModuleApp.find_by_key("universal_table")
|
||||||
return {} if (announcement.category.disable rescue false)
|
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,
|
||||||
|
"text" => ""
|
||||||
|
}
|
||||||
|
elsif section.section_type == "text"
|
||||||
|
{
|
||||||
|
"section" => section.title,
|
||||||
|
"entries" => [],
|
||||||
|
"uid" => "",
|
||||||
|
"type" => section.section_type,
|
||||||
|
"url_to_show" => "",
|
||||||
|
"text" => section.text.html_safe
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !announcement.deadline.nil? && announcement.deadline < Time.now
|
if !announcement.deadline.nil? && announcement.deadline < Time.now
|
||||||
return {
|
return {
|
||||||
|
@ -819,6 +846,7 @@ class CurationsController < ApplicationController
|
||||||
"tags" => tags,
|
"tags" => tags,
|
||||||
"bulletin_files" => files,
|
"bulletin_files" => files,
|
||||||
"bulletin_links" => links,
|
"bulletin_links" => links,
|
||||||
|
"sections" => sections,
|
||||||
"data" => {
|
"data" => {
|
||||||
"title" => announcement.title,
|
"title" => announcement.title,
|
||||||
"subtitle_ann" => subtitle_ann,
|
"subtitle_ann" => subtitle_ann,
|
||||||
|
|
|
@ -806,7 +806,18 @@
|
||||||
parent.find('.section_type_ut_entries input.select2').select2('destroy');
|
parent.find('.section_type_ut_entries input.select2').select2('destroy');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
$('.select2').each(function () {
|
||||||
|
const data = $(this).data('value');
|
||||||
|
if (data) {
|
||||||
|
$(this).select2({
|
||||||
|
data: data,
|
||||||
|
multiple: true,
|
||||||
|
width: '100%'
|
||||||
|
}).val(data.map(i => i.id)).trigger('change');
|
||||||
|
} else {
|
||||||
|
$(this).select2({ multiple: true, width: '100%' });
|
||||||
|
}
|
||||||
|
});
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
$("#enable_sub_annc").click(function(){
|
$("#enable_sub_annc").click(function(){
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
class: 'form-control' %>
|
class: 'form-control' %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="tab-content section_type_text" style="display:none">
|
<span class="tab-content section_type_text" style="<%= !form_section_post.new_record? && form_section_post.section_type == 'text' ? '' : 'display:none' %>">
|
||||||
<span class="add-on"><%= t("curation.text") %></span>
|
<span class="add-on"><%= t("curation.text") %></span>
|
||||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||||
|
@ -53,18 +53,27 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<% if defined? UniversalTable %>
|
<% if defined? UniversalTable %>
|
||||||
<span class="tab-content section_type_ut" style="display:none">
|
<span class="tab-content section_type_ut" style="<%= !form_section_post.new_record? && form_section_post.section_type == 'universal_table' ? '' : 'display:none' %>">
|
||||||
<span class="add-on"><%= t("curation.tables") %></span>
|
<span class="add-on"><%= t("curation.tables") %></span>
|
||||||
<%= f.select :universal_table, UTable.all.map { |table| [table.title, table.uid] },
|
<%= f.select :universal_table, UTable.all.map { |table| [table.title, table.uid] },
|
||||||
{ include_blank: t("curation.please_select") },
|
{ include_blank: t("curation.please_select") },
|
||||||
class: 'form-control' %>
|
class: 'form-control' %>
|
||||||
</span>
|
</span>
|
||||||
|
<% if !form_section_post.new_record? && form_section_post.section_type == "universal_table" %>
|
||||||
|
<%
|
||||||
|
tbData = form_section_post.get_table_entries.map{|tb| {id: tb.id.to_s, text: tb.column_entries.first.text}}
|
||||||
|
%>
|
||||||
|
<span class="tab-content section_type_ut_entries">
|
||||||
|
<span class="add-on"><%= t("curation.table_entries") %></span>
|
||||||
|
<%= f.text_field :table_entries, :class => "select2", data: { value: tbData } %>
|
||||||
|
</span>
|
||||||
|
<% else %>
|
||||||
<span class="tab-content section_type_ut_entries" style="display:none">
|
<span class="tab-content section_type_ut_entries" style="display:none">
|
||||||
<span class="add-on"><%= t("curation.table_entries") %></span>
|
<span class="add-on"><%= t("curation.table_entries") %></span>
|
||||||
<%= f.text_field :table_entries, :class => "select2" %>
|
<%= f.text_field :table_entries, :class => "select2" %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% if form_section_post.new_record? %>
|
<% if form_section_post.new_record? %>
|
||||||
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
|
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
|
||||||
<a class="icon-trash"></a>
|
<a class="icon-trash"></a>
|
||||||
|
|
|
@ -70,7 +70,6 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @show_back_and_next_flag==1 %>
|
<% if @show_back_and_next_flag==1 %>
|
||||||
<%= content %>
|
<%= content %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -40,6 +40,17 @@
|
||||||
<div class="s-annc__subtitle">{{subtitle_ann}}</div>
|
<div class="s-annc__subtitle">{{subtitle_ann}}</div>
|
||||||
<div class="s-annc__post-body">{{body}}</div>
|
<div class="s-annc__post-body">{{body}}</div>
|
||||||
</section>
|
</section>
|
||||||
|
<div data-list="sections" data-level="0">
|
||||||
|
<div class="{{type}}">
|
||||||
|
<div>{{section}}</div>
|
||||||
|
<ul class="universal-table" data-list="entries" data-level="1">
|
||||||
|
<li>
|
||||||
|
<div><a href="{{url_to_show}}">{{text}}</a></div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="text">{{text}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="sub_anncs_list">{{sub_anncs_text}}</div>
|
<div id="sub_anncs_list">{{sub_anncs_text}}</div>
|
||||||
<ul class="s-annc__related-wrap list-unstyled no-print">
|
<ul class="s-annc__related-wrap list-unstyled no-print">
|
||||||
<li class="s-annc__related-file">
|
<li class="s-annc__related-file">
|
||||||
|
|
Loading…
Reference in New Issue