diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index f48440e31..6ca208c94 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -49,17 +49,7 @@ <% 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 %> - <%= 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/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 9c997914a..30df4c9c3 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -134,14 +134,16 @@ <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
- <% @site_valid_locales.each_with_index do |locale, i| %> + <%# @site_valid_locales.each_with_index do |locale, i| %> + <% site_valid_locales_default_head.each_with_index do |locale, i| %>
"> 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 61546825a..3d9e7084a 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 000000000..353284383 --- /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 000000000..9b100d24b --- /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 701ba9890..0aaccdae8 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 @@ <%= post.archive_file_category.i18n_variable[I18n.locale] %> - <%= link_to post.name[I18n.locale], panel_archive_back_end_archive_file_path(post) %> + <%= link_to post.title[I18n.locale], panel_archive_back_end_archive_file_path(post) %> <% post.tags.each do |tag| %> diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb index ef3e223b7..d00dd91e9 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb @@ -46,7 +46,8 @@ <%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> @@ -57,8 +58,8 @@
">
- <%= f.label :name %> - <%= f.fields_for :name, (@archive_file.new_record? ? @archive_file.build_name : @archive_file.name ) do |f| %> + <%= f.label :title %> + <%= f.fields_for :title, (@archive_file.new_record? ? @archive_file.build_title : @archive_file.title ) do |f| %> <%= I18nVariable.from_locale(locale) %> <%= f.text_field locale, :class=>'post-title' %> <% end %> @@ -70,6 +71,50 @@
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + <% @archive_file.archive_file_multiples.each_with_index do |archive_file_multiple, i| %> + <%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %> + <%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> + +
FileFile Name<%= t('呈現語系')%>
+
+ <%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %> + ADD/新增 +
+
+ +
+ +
+ + + + +
@@ -81,4 +126,28 @@
+ + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "archive_form" %> + +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form_file.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form_file.html.erb new file mode 100644 index 000000000..6e90b0817 --- /dev/null +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form_file.html.erb @@ -0,0 +1,55 @@ +<% # encoding: utf-8 %> + + " class='list_item'> + +
+
+ <%= f.file_field :file %> +
+
+ + + +
+ + <% @site_valid_locales.each_with_index do |locale, i| %> + +
"> + + <%= f.fields_for :i18n_variable, (form_file.new_record? ? form_file.build_i18n_variable : form_file.i18n_variable ) do |f| %> +
+ +
+ <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
+
+ <% end %> + +
+ + <% end %> + +
+ + + + <% @site_valid_locales.each do |locale| %> + <%= check_box_tag 'archive_file[archive_file_multiple][archive_file_multiple_langs_attributes][choose_lang][]', locale %> + <%= I18nVariable.from_locale(locale) %> + <% end %> + + + + + <% if form_file.new_record? %> + + <% else %> + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + + + + + diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.html.erb index b00a3c4c5..d1bfa6c16 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.html.erb @@ -6,7 +6,7 @@ <%= t('archive_file.status') %> <%= t('archive_file.category') %> - <%= t('archive_file.name') %> + <%= t('archive_file.title') %> <%= t('archive_file.tags') %>