diff --git a/app/assets/javascripts/mind_map/utils/custom.search.js b/app/assets/javascripts/mind_map/utils/custom.search.js
index 9110096..ec4e3f3 100644
--- a/app/assets/javascripts/mind_map/utils/custom.search.js
+++ b/app/assets/javascripts/mind_map/utils/custom.search.js
@@ -67,6 +67,32 @@ export class JsmindSearch {
// Ensure input event is not bound multiple times
inputField.removeEventListener('input', this.onInput)
inputField.addEventListener('input', this.onInput.bind(this, node))
+
+ inputField.removeEventListener('keydown', this.onKeyDown)
+ inputField.addEventListener('keydown', this.onKeyDown.bind(this, node))
+ }
+ /**
+ * 處理 Enter 鍵完成輸入
+ * Handle Enter key to finalize input
+ * @param {Object} node - 當前節點
+ * @param {KeyboardEvent} e - 鍵盤事件
+ */
+ onKeyDown(node, e) {
+ if (e.key === 'Enter') {
+ e.preventDefault()
+ const input = e.target.value.trim()
+ if (input) {
+ // 更新節點文字
+ node.data.text = input
+ this.jm.end_edit()
+ this.jm.update_node(node.id, input)
+
+ // 隱藏 suggestion box(避免未選建議但仍留下)
+ if (this.suggestionBox) {
+ this.suggestionBox.style.display = 'none'
+ }
+ }
+ }
}
/**
@@ -106,10 +132,22 @@ export class JsmindSearch {
// 更新建議框內容
// Update suggestion box content
this.suggestionBox.innerHTML = results
- .map(
- (item) =>
- `
+
<%= entry.column_entries.first.try(:text).to_s %>
+
+ <% entry.column_entries.each do |ce| %>
+ <% if ce.type == "file" %>
+
+ <% ce.column_entry_files.desc(:sort_number).each do |file| %>
+ <% next unless file.choose_lang_display(I18n.locale.to_s) %>
+ <% file_title = file.get_file_title %>
+ <% size = number_to_human_size(file.file.size) %>
+ <% link = file.get_link %>
+ <% if file.file.content_type.start_with?('audio/') %>
+
+
<%= file_title %>
+
+
+
+
+ <% else %>
+ -
+
+ <%= file_title %>
+
+ (<%= size %>)
+
+ ">
+ <%= file.download_count %>
+
+
+ <% end %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb
index dd6a210..a45b273 100644
--- a/app/controllers/admin/universal_tables_controller.rb
+++ b/app/controllers/admin/universal_tables_controller.rb
@@ -48,31 +48,53 @@ class Admin::UniversalTablesController < OrbitAdminController
end
end
- def get_entries
- table = UTable.where(:uid => params["uid"]).first rescue nil
- data = []
- if !table.nil?
- if params[:q].present?
- enteries = search_data(table, 50)
- ma = ModuleApp.find_by_key("universal_table")
- enteries.each do |entry|
- if params["links"].present?
- data << {
- "id" => entry.id.to_s,
- "text" => entry.column_entries.first.text,
- "link" => OrbitHelper.cal_url_to_show(ma,entry)
- }
- else
- data << {
- "id" => entry.id.to_s,
- "text" => entry.column_entries.first.text
- }
- end
- end
- end
- end
- render :json => data.to_json
- end
+def get_entries
+ table = UTable.where(:uid => params["uid"]).first rescue nil
+ data = []
+
+ if table && params[:q].present?
+ entries = search_data(table, 50)
+ ma = ModuleApp.find_by_key("universal_table")
+
+ entries.each 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)
+ next if text.blank?
+
+ # 包含連結的欄位處理
+ url = ct.is_link_to_show ? OrbitHelper.cal_url_to_show(ma, entry) : nil
+ rows << {
+ "title" => ct.title,
+ "text" => text,
+ "url" => url
+ }
+ end
+
+ # 加入 hashtags 欄位
+ # rows << {
+ # "title" => I18n.t("universal_table.hashtags"),
+ # "text" => entry.tags_for_frontend,
+ # "url" => nil
+ # }
+
+ # 加入主輸出結構
+ data << {
+ "id" => entry.id.to_s,
+ "link" => OrbitHelper.cal_url_to_show(ma, entry),
+ "text" => entry.column_entries.map(&:text).compact.reject(&:blank?).join(" / "),
+ "fields" => rows
+ }
+ end
+ end
+
+ render json: data
+end
+
def get_mindmaps
utable = UTable.where(:uid => params['table']).first
diff --git a/app/views/universal_tables/mind_map.html.erb b/app/views/universal_tables/mind_map.html.erb
index 30a1b23..7f5bb8a 100644
--- a/app/views/universal_tables/mind_map.html.erb
+++ b/app/views/universal_tables/mind_map.html.erb
@@ -1,6 +1,6 @@
<%
data = action_data
- OrbitHelper.render_css_in_head(["/mind_map/mindmap"])
+ OrbitHelper.render_css_in_head(["mind_map/mindmap"])
%>