diff --git a/app/controllers/curations_controller.rb b/app/controllers/curations_controller.rb
index 29c362b..7e43598 100644
--- a/app/controllers/curations_controller.rb
+++ b/app/controllers/curations_controller.rb
@@ -704,23 +704,7 @@ class CurationsController < ApplicationController
end
sections = []
sections = announcement.curation_post_sections.map do |section|
- if section.section_type == "universal_table"
- {
- "section" => section.title,
- "entries" => section.get_table_entries_for_frontend,
- "url_to_show" => "",
- "text" => ""
- }
- elsif section.section_type == "text"
- {
- "section" => section.title,
- "entries" => [],
- "uid" => "",
- "type" => section.section_type,
- "url_to_show" => "",
- "text" => section.text.html_safe
- }
- end
+ section.get_frontend_object
end
sections.compact!
diff --git a/app/models/curation_post.rb b/app/models/curation_post.rb
index c2193b8..32263c5 100644
--- a/app/models/curation_post.rb
+++ b/app/models/curation_post.rb
@@ -10,7 +10,7 @@ class CurationPost
include Slug
require 'curation/cache'
include Curation::Cache
- SECTION_TYPES = ["text", "universal_table"]
+
attr_accessor :org_tag_ids,:org_category_id
def tags=(ids)
self.org_tag_ids = self.tag_ids
diff --git a/app/models/curation_post_section.rb b/app/models/curation_post_section.rb
index 249eeec..28106f4 100644
--- a/app/models/curation_post_section.rb
+++ b/app/models/curation_post_section.rb
@@ -8,6 +8,9 @@ class CurationPostSection
field :text, localize: true
field :universal_table
field :table_entries
+ field :mind_map_id
+
+ SECTION_TYPES = ["text", "universal_table", "mind_map"]
belongs_to :curation_post
@@ -42,4 +45,44 @@ class CurationPostSection
tids = self.table_entries.split(',')
TableEntry.find(tids)
end
+
+ def get_frontend_object
+ case self.section_type
+ when "universal_table"
+ {
+ "section" => self.title,
+ "section_uid" => self.id.to_s[0..5],
+ "entries" => self.get_table_entries_for_frontend,
+ "url_to_show" => "",
+ "text" => "",
+ "mind_map_title" => "",
+ "mind_map_data" => ""
+ }
+ when "text"
+ {
+ "section" => self.title,
+ "section_uid" => self.id.to_s[0..5],
+ "entries" => [],
+ "uid" => "",
+ "type" => self.section_type,
+ "url_to_show" => "",
+ "text" => self.text.html_safe,
+ "mind_map_title" => "",
+ "mind_map_data" => ""
+ }
+ when "mind_map"
+ mm = MindMap.find(self.mind_map_id)
+ {
+ "section" => self.title,
+ "section_uid" => self.id.to_s[0..5],
+ "entries" => [],
+ "mind_map_title" => mm.title,
+ "mind_map_data" => mm.mind_map_data.to_json,
+ "uid" => "",
+ "type" => self.section_type,
+ "url_to_show" => "",
+ "text" => ""
+ }
+ end
+ end
end
diff --git a/app/views/admin/curations/_form.html.erb b/app/views/admin/curations/_form.html.erb
index 3558cee..8c1faf5 100644
--- a/app/views/admin/curations/_form.html.erb
+++ b/app/views/admin/curations/_form.html.erb
@@ -745,6 +745,16 @@
var parent = $(this).parents(".curation_section");
parent.find(".section_type_text").hide();
parent.find(".section_type_ut").hide();
+ parent.find(".section_type_mm").hide();
+ parent.find(".section_type_mm_mindmaps").hide();
+ if(parent.find(".section_type_text textarea").length > 0){
+ parent.find(".section_type_text textarea").each(function(index){
+ id = $(this).attr("id");
+ if(CKEDITOR.instances[id]){
+ CKEDITOR.instances[id].destroy(true);
+ }
+ });
+ }
if($(this).val() == "text"){
parent.find(".section_type_text").show();
parent.find(".section_type_text textarea").each(function(index){
@@ -753,12 +763,8 @@
});
}else if($(this).val() == "universal_table"){
parent.find(".section_type_ut").show();
- if(parent.find(".section_type_text textarea").length > 0){
- parent.find(".section_type_text textarea").each(function(index){
- id = $(this).attr("id");
- CKEDITOR.instances[id].destroy(true);
- });
- }
+ }else if($(this).val() == "mind_map"){
+ parent.find(".section_type_mm").show();
}
})
<% if defined? UniversalTable %>
@@ -813,14 +819,31 @@
$('.select2').each(function () {
const data = $(this).data('value');
if (data) {
- console.log($(this))
$(this).select2({
data: data,
multiple: true,
width: '100%'
}).val(data.map(i => i.id)).trigger('change');
}
- });
+ });
+ // mind map
+ $(document).on('change', '.section_type_mm select.mind_map_select_ut', function(){
+ var tableid = $(this).val();
+ var parent = $(this).parents(".curation_section");
+ var select = parent.find(".section_type_mm_mindmaps select.mind_map_select");
+ $.ajax({
+ type: "get",
+ url: '/admin/universal_tables/get_mindmaps?table=' + tableid,
+ processData: false,
+ contentType: "json"
+ }).done(function(data){
+ select.html("");
+ $.each(data, function(index, item) {
+ select.append("");
+ });
+ parent.find(".section_type_mm_mindmaps").show();
+ })
+ })
<% 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 e2eb893..e84e987 100644
--- a/app/views/admin/curations/_form_section_post.html.erb
+++ b/app/views/admin/curations/_form_section_post.html.erb
@@ -37,7 +37,7 @@
<%= t("curation.section_type") %>
- <%= f.select :section_type, CurationPost::SECTION_TYPES.map { |type| [t("curation.#{type}"), type] },
+ <%= f.select :section_type, CurationPostSection::SECTION_TYPES.map { |type| [t("curation.#{type}"), type] },
{ include_blank: t("curation.please_select"), selected: form_section_post.section_type },
class: 'form-control' %>
@@ -74,6 +74,29 @@
<% end %>
<% 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 mind_map_select_ut' %>
+
+ <% if !form_section_post.new_record? && form_section_post.section_type == "mind_map" %>
+
+ <% maps = UTable.where(:uid => form_section_post.universal_table).first.mind_maps %>
+ <%= t("curation.mind_map") %>
+ <%= f.select :mind_map_id, maps.map { |m| [m.title, m.id.to_s] },
+ { include_blank: t("curation.please_select"), selected: form_section_post.mind_map_id },
+ class: 'form-control mind_map_select' %>
+
+ <% else %>
+
+ <%= t("curation.mind_map") %>
+ <%= f.select :mind_map_id, [], {}, class: 'form-control mind_map_select' %>
+
+ <% end %>
+ <% end %>
+
<% if form_section_post.new_record? %>
@@ -85,8 +108,4 @@
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
-
-
diff --git a/app/views/curations/show.html.erb b/app/views/curations/show.html.erb
index 908c9e8..fada61e 100644
--- a/app/views/curations/show.html.erb
+++ b/app/views/curations/show.html.erb
@@ -1,4 +1,5 @@
<%
+ OrbitHelper.render_css_in_head(["mind_map/mindmap"])
params = OrbitHelper.params
page = @page || Page.where(url:params['url']).first
@show_back_and_next_flag = 0
@@ -68,6 +69,9 @@
a.prev{
margin-right: 1em;
}
+ .section_mind_map .mind_map{
+ height:500px !important;
+ }
<% end %>
<% if @show_back_and_next_flag==1 %>
@@ -211,3 +215,59 @@ $(".voice-player").on("click", function(){
return false;
})
+
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3ff6a27..305ad56 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -214,4 +214,5 @@ en:
tables: Tables
search_entries: Search Entries
title: Title
+ mind_map: Mind Map
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 139f9b2..a4435d7 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -203,4 +203,5 @@ zh_tw:
section_type: Section Type
tables: Tables
search_entries: Search Entries
- title: Title
\ No newline at end of file
+ title: Title
+ mind_map: Mind Map
\ No newline at end of file