diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb
index 8a1edda..8c3bd29 100644
--- a/app/controllers/admin/universal_tables_controller.rb
+++ b/app/controllers/admin/universal_tables_controller.rb
@@ -195,6 +195,7 @@ class Admin::UniversalTablesController < OrbitAdminController
def add_entry
entry = TableEntry.new(table_entry_params)
+ create_get_table_tags(@entry)
entry.save
entry.fix_have_data
table = UTable.find(params[:table_entry][:u_table_id])
@@ -220,6 +221,7 @@ class Admin::UniversalTablesController < OrbitAdminController
def update_entry
entry = TableEntry.find(params[:id])
+ create_get_table_tags(entry)
entry.update_attributes(table_entry_params)
entry.fix_have_data # when new column insert
table = entry.u_table
@@ -311,4 +313,25 @@ class Admin::UniversalTablesController < OrbitAdminController
def table_entry_params
params.require(:table_entry).permit!
end
+
+ def create_get_table_tags(entry)
+ new_tags = params["table_tags"].split(",")
+ tags = []
+ entry.table_tags = []
+ new_tags.each do |tag|
+ if is_uuid?(tag) === false
+ tt = TableTag.new
+ tt.title = tag.downcase
+ tt.save
+ entry.table_tags << tt
+ else
+ tt = TableTag.find(tag)
+ entry.table_tags << tt
+ end
+ end
+ return tags
+ end
+ def is_uuid?(str)
+ !!(str =~ /\A[\da-f]{24}\z/i || str =~ /\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i)
+ end
end
diff --git a/app/models/column_entry.rb b/app/models/column_entry.rb
index 44c3845..ed35731 100644
--- a/app/models/column_entry.rb
+++ b/app/models/column_entry.rb
@@ -89,10 +89,14 @@ class ColumnEntry
self.column_entry_files.desc(:sort_number).each do |entry_file|
next unless entry_file.choose_lang_display(locale)
file_title = entry_file.get_file_title
- text += "
#{file_title}(#{number_to_human_size(entry_file.file.size)})#{entry_file.download_count}"
+ if entry_file.file.content_type.start_with?('audio/')
+ text += ""
+ else
+ text += "#{file_title}(#{number_to_human_size(entry_file.file.size)})#{entry_file.download_count}"
+ end
end
text += ""
end
text
end
-end
\ No newline at end of file
+end
diff --git a/app/models/table_entry.rb b/app/models/table_entry.rb
index 2f23c79..965f2c2 100644
--- a/app/models/table_entry.rb
+++ b/app/models/table_entry.rb
@@ -10,13 +10,14 @@ class TableEntry
has_many :column_entries, :dependent => :destroy
belongs_to :u_table, index: true
+ has_and_belongs_to_many :table_tags, inverse_of: :table_entries
accepts_nested_attributes_for :column_entries, :allow_destroy => true
I18n.available_locales.each do |locale|
index({"have_data.#{locale}" => 1}, { unique: false, background: true })
end
-
+
before_save do
if self[:sort_number].nil?
other_record = self.class.where(:u_table_id=> self.u_table_id, :id.ne=> self.id).order_by(sort_number: :desc).first
@@ -100,7 +101,7 @@ class TableEntry
if field.nil? || direction.nil?
table, field, direction = self.get_sort_field(params: params, table: table)
end
-
+
if (field=='created_at' || field == 'sort_number')
if column_entries.nil?
values = self.order_by({field => direction})
@@ -146,4 +147,4 @@ class TableEntry
end
values
end
-end
\ No newline at end of file
+end
diff --git a/app/models/table_tag.rb b/app/models/table_tag.rb
new file mode 100644
index 0000000..66d1341
--- /dev/null
+++ b/app/models/table_tag.rb
@@ -0,0 +1,7 @@
+class TableTag
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :title, type: String
+ has_and_belongs_to_many :table_entries, inverse_of: :table_tags
+end
diff --git a/app/models/u_table.rb b/app/models/u_table.rb
index 534b9e4..d170eb0 100644
--- a/app/models/u_table.rb
+++ b/app/models/u_table.rb
@@ -20,6 +20,7 @@ class UTable
FIELD_TYPES = ["text", "integer", "editor", "image", "date", "period", "file"]
DATE_FORMATS = ["yyyy/MM/dd hh:mm", "yyyy/MM/dd","yyyy/MM", "yyyy"]
+ AUDIO_EXTENSIONS = %w[.mp3 .wav .ogg .m4a .aac .flac]
def default_ordered
if self.ordered_with_created_at
sort_column = 'created_at'
diff --git a/app/views/admin/universal_tables/_entry_form.html.erb b/app/views/admin/universal_tables/_entry_form.html.erb
index e454f8c..b3fd844 100644
--- a/app/views/admin/universal_tables/_entry_form.html.erb
+++ b/app/views/admin/universal_tables/_entry_form.html.erb
@@ -3,13 +3,27 @@
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
+ <%= stylesheet_link_tag "select2/select2" %>
+ <%= javascript_include_tag "select2/select2.min" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/universal_tables/show.html.erb b/app/views/admin/universal_tables/show.html.erb
index 2710e73..c8f6eae 100644
--- a/app/views/admin/universal_tables/show.html.erb
+++ b/app/views/admin/universal_tables/show.html.erb
@@ -58,7 +58,12 @@
<% ce.column_entry_files.desc(:sort_number).each do |entry_file| %>
<% next unless entry_file.choose_lang_display(locale) %>
- - <%= link_to entry_file.get_file_title, entry_file.file.url, target: "_blank" %>
+ <% if entry_file.file.content_type.start_with?('audio/') %>
+ <%= entry_file.get_file_title %>
+
+ <% else %>
+ - <%= link_to entry_file.get_file_title, entry_file.file.url, target: "_blank" %>
+ <% end %>
<% end %>
<% end %>
@@ -89,10 +94,33 @@
+
\ No newline at end of file
diff --git a/app/views/universal_tables/index.html.erb b/app/views/universal_tables/index.html.erb
index 648b75c..67d24b0 100644
--- a/app/views/universal_tables/index.html.erb
+++ b/app/views/universal_tables/index.html.erb
@@ -1 +1,31 @@
-<%= render_view %>
\ No newline at end of file
+<%= render_view %>
+
\ No newline at end of file
diff --git a/app/views/universal_tables/show.html.erb b/app/views/universal_tables/show.html.erb
index 648b75c..67d24b0 100644
--- a/app/views/universal_tables/show.html.erb
+++ b/app/views/universal_tables/show.html.erb
@@ -1 +1,31 @@
-<%= render_view %>
\ No newline at end of file
+<%= render_view %>
+
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 4e3c47b..333490e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -29,4 +29,5 @@ en:
text_color: Text Color
disable_editing: Disable editing
enable_editing: Enable editing
- save_mind_map: Save mind map
\ No newline at end of file
+ save_mind_map: Save mind map
+ hashtags: Hashtags
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index b0f30c5..a447ef4 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -29,4 +29,5 @@ zh_tw:
text_color: 文字顏色
disable_editing: Disable editing
enable_editing: Enable editing
- save_mind_map: Save mind map
\ No newline at end of file
+ save_mind_map: Save mind map
+ hashtags: Hashtags
\ No newline at end of file