diff --git a/app/controllers/curations_controller.rb b/app/controllers/curations_controller.rb
index 89bea1c..f970b7b 100644
--- a/app/controllers/curations_controller.rb
+++ b/app/controllers/curations_controller.rb
@@ -686,6 +686,7 @@ class CurationsController < ApplicationController
end
announcement = CurationPost.where(:uid => uid).first if announcement.nil?
return nil if announcement.nil?
+ return {} if (announcement.category.disable rescue false)
@bulletin = announcement
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/curations/#{announcement.id.to_s}/edit" : ""
@@ -701,8 +702,34 @@ class CurationsController < ApplicationController
return {}
end
end
-
- return {} if (announcement.category.disable rescue false)
+ 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,
+ "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
return {
@@ -819,6 +846,7 @@ class CurationsController < ApplicationController
"tags" => tags,
"bulletin_files" => files,
"bulletin_links" => links,
+ "sections" => sections,
"data" => {
"title" => announcement.title,
"subtitle_ann" => subtitle_ann,
diff --git a/app/views/admin/curations/_form.html.erb b/app/views/admin/curations/_form.html.erb
index 75e02d4..ec93d65 100644
--- a/app/views/admin/curations/_form.html.erb
+++ b/app/views/admin/curations/_form.html.erb
@@ -758,55 +758,66 @@
}
})
<% if defined? UniversalTable %>
- var selectedUTable = null;
- var select2Options = {
- maximumSelectionSize: 10,
- minimumResultsForSearch: Infinity,
- multiple: true,
- minimumInputLength: 2,
- placeholder: "<%= t("curation.search_entries") %>",
- ajax: {
- type: 'get',
- url: "",
- allowClear: true,
- dataType: 'json',
- delay: 250,
- data: function (term) {
- var query = {
- q: term
- }
- return query;
+ var selectedUTable = null;
+ var select2Options = {
+ maximumSelectionSize: 10,
+ minimumResultsForSearch: Infinity,
+ multiple: true,
+ minimumInputLength: 2,
+ placeholder: "<%= t("curation.search_entries") %>",
+ ajax: {
+ type: 'get',
+ url: "",
+ allowClear: true,
+ dataType: 'json',
+ delay: 250,
+ data: function (term) {
+ var query = {
+ q: term
+ }
+ return query;
+ },
+ results: function(data, page) {
+ return {
+ results: data
+ };
+ },
+ cache: true
},
- results: function(data, page) {
- return {
- results: data
- };
- },
- cache: true
- },
- formatResult: function(i) {
- return '
' + i.text + '
';
- }, // Formats results in drop down
- formatSelection: function(i) {
- return '' + i.text + '
';
- }, //Formats result that is selected
- escapeMarkup: function(m) {
- return m;
- } // we do not want to escape markup since we are displaying html in results
- }
- $(document).on('change', '.section_type_ut select', function(){
- var parent = $(this).parents(".curation_section");
- if($(this).val()){
- selectedUTable = $(this).val();
- parent.find(".section_type_ut_entries").show();
- select2Options.ajax.url = "/admin/universal_tables/get_entries?uid=" + selectedUTable;
- parent.find('.section_type_ut_entries input.select2').select2(select2Options);
- }else{
- parent.find(".section_type_ut_entries").hide();
- parent.find('.section_type_ut_entries input.select2').select2('destroy');
+ formatResult: function(i) {
+ return '' + i.text + '
';
+ }, // Formats results in drop down
+ formatSelection: function(i) {
+ return '' + i.text + '
';
+ }, //Formats result that is selected
+ escapeMarkup: function(m) {
+ return m;
+ } // we do not want to escape markup since we are displaying html in results
}
- })
-
+ $(document).on('change', '.section_type_ut select', function(){
+ var parent = $(this).parents(".curation_section");
+ if($(this).val()){
+ selectedUTable = $(this).val();
+ parent.find(".section_type_ut_entries").show();
+ select2Options.ajax.url = "/admin/universal_tables/get_entries?uid=" + selectedUTable;
+ parent.find('.section_type_ut_entries input.select2').select2(select2Options);
+ }else{
+ parent.find(".section_type_ut_entries").hide();
+ 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 %>
$("#enable_sub_annc").click(function(){
diff --git a/app/views/admin/curations/_form_section_post.html.erb b/app/views/admin/curations/_form_section_post.html.erb
index 47299f1..e2eb893 100644
--- a/app/views/admin/curations/_form_section_post.html.erb
+++ b/app/views/admin/curations/_form_section_post.html.erb
@@ -42,7 +42,7 @@
class: 'form-control' %>
-
+
<%= t("curation.text") %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<%= locale %>">
@@ -53,18 +53,27 @@
<% end %>
<% if defined? UniversalTable %>
-
+
<%= t("curation.tables") %>
<%= f.select :universal_table, UTable.all.map { |table| [table.title, table.uid] },
{ include_blank: t("curation.please_select") },
class: 'form-control' %>
-
- <%= t("curation.table_entries") %>
- <%= f.text_field :table_entries, :class => "select2" %>
-
+ <% 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}}
+ %>
+
+ <%= t("curation.table_entries") %>
+ <%= f.text_field :table_entries, :class => "select2", data: { value: tbData } %>
+
+ <% else %>
+
+ <%= t("curation.table_entries") %>
+ <%= f.text_field :table_entries, :class => "select2" %>
+
+ <% end %>
<% end %>
-
<% if form_section_post.new_record? %>
diff --git a/app/views/curations/show.html.erb b/app/views/curations/show.html.erb
index 9779ecc..bd2528a 100644
--- a/app/views/curations/show.html.erb
+++ b/app/views/curations/show.html.erb
@@ -70,7 +70,6 @@
}
<% end %>
-
<% if @show_back_and_next_flag==1 %>
<%= content %>
<% end %>
@@ -182,4 +181,4 @@
<%= t('curation.send_comment') %>
-<% end rescue nil %>
\ No newline at end of file
+<% end rescue nil %>
diff --git a/modules/curation/show.html.erb b/modules/curation/show.html.erb
index 03a8232..c514a14 100644
--- a/modules/curation/show.html.erb
+++ b/modules/curation/show.html.erb
@@ -40,6 +40,17 @@
{{subtitle_ann}}
{{body}}
+
+
+
{{section}}
+
+
{{text}}
+
+
{{sub_anncs_text}}