From 7d553acaec68331b34e3bc261fd9ac114478a929 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Mar 2012 15:53:57 +0800 Subject: [PATCH] fix announcement link & files --- app/assets/javascripts/bulletin_form.js.erb | 12 +- app/views/layouts/_side_bar.html.erb | 2 +- .../back_end/bulletin_links_controller.rb | 14 ++ .../back_end/bulletins_controller.rb | 2 +- .../bulletins/_bulletin_file.html.erb | 63 ++++--- .../bulletins/_bulletin_link.html.erb | 48 +++--- .../back_end/bulletins/_form.html.erb | 155 ++++++++++++------ .../bulletins/_quick_edit_links.html.erb | 12 +- .../back_end/bulletins/index.html.erb | 3 + .../announcement/config/routes.rb | 1 + 10 files changed, 200 insertions(+), 112 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 17f86060c..a427667df 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,13 +1,15 @@ -$('.bulletin_links_block a.delete').live('click', function(){ - $(this).parents('.list_item').remove(); +$('.bulletin_links_block a.remove_existing_record').live('click', function(){ + //$(this).parents('.list_item').remove(); + $(this).parents('tr.list_item').remove(); }); -$('.bulletin_files_block a.delete').live('click', function(){ - $(this).parents('.list_item').remove(); +$('.bulletin_files_block a.remove_existing_record').live('click', function(){ + //$(this).parents('.list_item').remove(); + $(this).parents('tr.list_item').remove(); }); $('.action a.remove_existing_record').live('click', function(){ $(this).next('.should_destroy').attr('value', 1); - $("#bulletin_" + $(this).prev().attr('value')).hide(); + //$("#bulletin_" + $(this).prev().attr('value')).hide(); $("tr#bulletin_" + $(this).prev().attr('value')).hide(); }); \ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 61e2c4d84..220781a70 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -13,7 +13,7 @@ <% end -%> <%= content_tag :li, :class => active_for_controllers('users') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %> + <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %> <% end -%> <%= content_tag :li, :class => active_for_controllers('page_contexts') do -%> diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb new file mode 100644 index 000000000..04a75fa63 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb @@ -0,0 +1,14 @@ +class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController + + layout 'new_admin' + + def index + @bulletin_links = BulletinLink.all + + respond_to do |format| + format.html # index.html.erb + # format.xml { render :xml => @bulletins } + format.js + end + +end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 09e94c2d6..77454b854 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -15,7 +15,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # @bulletins = Bulletin.search(params[:search], params[:category_id]) # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) - @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all + @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.limit(1).desc("postdate") @bulletin_categories = BulletinCategory.all respond_to do |format| diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb index 6da49ceb8..ef2d4bc7a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb @@ -1,36 +1,47 @@ -
" class='list_item'> -
- <%= f.label :file %> - <%#= file_field_tag 'bulletin[file]' %> - <%= f.file_field :file %> - - <%= f.label :file_title %> - <%#= f.text_field :filetitle %> - <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> + " class='list_item'> + +
+
+ <%= f.file_field :file %> +
+
+ + + <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> + <% @site_valid_locales.each do |locale| %> +
+ +
+ <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
+
+ <% end %> <% end %> - <% end %> - - <%= f.label :file_description %> - <%#= f.text_field :description %> - <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> + + + <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> + <% @site_valid_locales.each do |locale| %> +
+ +
+ <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
+
+ <% end %> <% end %> - <% end %> - + + <% if bulletin_file.new_record? %> - <%= t(:delete) %> + <% else %> <%= f.hidden_field :id %> - <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <% end %> -
-
+ + + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb index e0077384a..c8503083e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb @@ -1,27 +1,37 @@ -
" class='list_item'> -
- - <%= f.label :link_url %> - <%= f.text_field :url %> - - <%= f.label :link_name %> - <%#= f.text_field :name %> - <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> - + " class='list_item'> + + +
+
+ <%= f.text_field :url %> +
+
+ + + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
+
+ <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
+
+ + + + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> - <%= t(:delete) %> + <% else %> <%= f.hidden_field :id %> - <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <% end %> -
-
+ + 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 2e41f3020..3cefe3607 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 @@ -13,7 +13,8 @@

Picture

- + +
- - - + +
+ +
@@ -202,38 +229,60 @@
- +
-
- - - - -
- -
-

Bulletin files

- <%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %> - <%= t(:add) %> -
- - <%#= render :partial => 'file', :locals => { :bulletin_files => @bulletin.bulletin_files , :f => f} %> - - - <% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %> - <%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %> - <%= f.fields_for :bulletin_files, bulletin_file do |f| %> - <%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> - <% end %> - <% end %> - -
- -
-
+ + + + + +
+
+
+ +
+

File

+
+ + + + + + + + + + + + + + + + +
+ + <% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %> + <%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %> + <%= f.fields_for :bulletin_files, bulletin_file do |f| %> + <%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> + +
+ + +
FileName<%= t('description') %>
+
+ <%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %> + ADD/新增 +
+
+
+
+
- + @@ -252,13 +301,13 @@ var new_id = $(this).prev().attr('value'); var old_id = new RegExp("new_bulletin_links", "g"); $(this).prev().attr('value', parseInt(new_id) + 1); - $('#bulletin_links').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); }); $('#add_bulletin_file a.add').live('click', function(){ var new_id = $(this).prev().attr('value'); var old_id = new RegExp("new_bulletin_files", "g"); $(this).prev().attr('value', parseInt(new_id) + 1); - $('#bulletin_files').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); });