diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 1d789075..4fe5d602 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -94,17 +94,7 @@ <%= content_tag :li, :class => active_for_controllers('archive_files', 'tags', 'archive_file_categorys') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-archive') + t('admin.archive'), panel_archive_back_end_archive_files_path %> - <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%> - <%= content_tag :li, link_to(t('admin.all_articles'), panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %> - <%= content_tag :li, link_to(t('admin.add_new'), new_panel_archive_back_end_archive_file_path), :class => active_for_action('archive_file', 'new') %> - <%= content_tag :li, link_to(t('admin.categories'), panel_archive_back_end_archive_file_categorys_path), :class => active_for_action('archive_file_categorys', 'index') %> - <%= content_tag :li, link_to(t('admin.tags'), panel_archive_back_end_tags_path), :class => active_for_action('tags', 'index') %> - <% end -%> -<% end -%> - -<%= content_tag :li, :class => active_for_controllers('archive_files', 'tags', 'archive_file_categorys') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-archive') + t('admin.archive'), panel_archive_back_end_archive_files_path %> + <%= link_to content_tag(:i, nil, :class => 'icons-asset') + t('admin.archive'), panel_archive_back_end_archive_files_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%> <%= content_tag :li, link_to(t('admin.all_articles'), panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %> <%= content_tag :li, link_to(t('admin.add_new'), new_panel_archive_back_end_archive_file_path), :class => active_for_action('archive_file', 'new') %> diff --git a/vendor/built_in_modules/archive/app/models/archive_file.rb b/vendor/built_in_modules/archive/app/models/archive_file.rb index 61546825..3d9e7084 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file.rb @@ -5,8 +5,9 @@ class ArchiveFile include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + PAYMENT_TYPES = @site_valid_locales - has_one :name, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_and_belongs_to_many :tags, :class_name => "ArchiveTag" @@ -19,19 +20,23 @@ class ArchiveFile belongs_to :archive_file_category - validates_presence_of :name + has_many :archive_file_multiples, :autosave => true, :dependent => :destroy - before_save :set_key + accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true + + validates_presence_of :title + + after_save :save_archive_file_multiples def self.search( category_id = nil ) if category_id.to_s.size > 0 - find(:all, :conditions => {archive_file_category_id: category_id}).desc( :is_top, :name ) + find(:all, :conditions => {archive_file_category_id: category_id}).desc( :is_top, :title ) else - find(:all).desc( :is_top, :name) + find(:all).desc( :is_top, :title) end @@ -40,7 +45,7 @@ class ArchiveFile def self.widget_datas - where( :is_hidden => false ).desc(:is_top, :name) + where( :is_hidden => false ).desc(:is_top, :title) end @@ -48,15 +53,11 @@ class ArchiveFile self.is_top end - def name - @name ||= I18nVariable.first(:conditions => {:key => 'name', :language_value_id => self.id, :language_value_type => self.class}) rescue nil - end - - protected - - def set_key - if name.new_record? - name.key = 'name' + def save_archive_file_multiples + self.archive_file_multiples.each do |t| + if t.should_destroy + t.destroy + end end end diff --git a/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb new file mode 100644 index 00000000..35328438 --- /dev/null +++ b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb @@ -0,0 +1,20 @@ +class ArchiveFileMultiple + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + # field :filetitle + # field :description + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + + field :should_destroy, :type => Boolean + + belongs_to :archive_file + + has_many :archive_file_multiple_langs, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :archive_file_multiple_langs, :allow_destroy => true + +end diff --git a/vendor/built_in_modules/archive/app/models/archive_file_multiple_lang.rb b/vendor/built_in_modules/archive/app/models/archive_file_multiple_lang.rb new file mode 100644 index 00000000..9b100d24 --- /dev/null +++ b/vendor/built_in_modules/archive/app/models/archive_file_multiple_lang.rb @@ -0,0 +1,10 @@ +class ArchiveFileMultipleLang + + include Mongoid::Document + include Mongoid::Timestamps + + field :choose_lang + + belongs_to :archive_file_multiple + +end diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_files.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_files.html.erb index 701ba989..0aaccdae 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_files.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_files.html.erb @@ -19,7 +19,7 @@
File | +File Name | +<%= t('呈現語系')%> | ++ |
---|---|---|---|
+
+ <%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
+ ADD/新增
+
+ |
+