From 236f68ba84ca136a9fc6c28cb010b7c86bafa294 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 6 Feb 2013 16:26:17 +0800 Subject: [PATCH] Fix archive module back end pagination and front end html --- .../back_end/archive_files_controller.rb | 1 + .../app/models/archive_file_category.rb | 4 ++++ ...e_files.html.erb => _archive_file.html.erb} | 18 +++++++++--------- .../back_end/archive_files/index.html.erb | 13 +++++-------- .../back_end/archive_files/index.js.erb | 2 ++ .../front_end/archive_files/index.html.erb | 18 +++++++++--------- .../built_in_modules/archive/config/routes.rb | 1 - 7 files changed, 30 insertions(+), 27 deletions(-) rename vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/{_archive_files.html.erb => _archive_file.html.erb} (53%) create mode 100644 vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.js.erb diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb index 3d3a6b21..41a4fb1a 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb @@ -13,6 +13,7 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController respond_to do |format| format.html # index.html.erb + format.js format.xml { render :xml => @archive_files } end end diff --git a/vendor/built_in_modules/archive/app/models/archive_file_category.rb b/vendor/built_in_modules/archive/app/models/archive_file_category.rb index f3d2fcd9..cd1a011f 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file_category.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file_category.rb @@ -12,5 +12,9 @@ class ArchiveFileCategory has_many :archive_files validates :title, :at_least_one => true + + def self.from_id(id) + ArchiveFileCategory.find(id) rescue nil + end end \ No newline at end of file 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_file.html.erb similarity index 53% rename from vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_files.html.erb rename to vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_archive_file.html.erb index 36d57f4e..2246d525 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_file.html.erb @@ -1,30 +1,30 @@ - + - <% if post.is_top? %> + <% if archive_file.is_top? %> <%= t(:top) %> <% end %> - <% if post.is_hot? %> + <% if archive_file.is_hot? %> <%= t(:hot) %> <% end %> - <% if post.is_hidden? %> + <% if archive_file.is_hidden? %> <%= t(:hidden) %> <% end %> <% if is_manager?%>
<%end%> - <%= post.archive_file_category.title %> + <%= archive_file.archive_file_category.title %> - <%= link_to post.title, panel_archive_front_end_archive_file_path(post) %> + <%= link_to archive_file.title, panel_archive_front_end_archive_file_path(archive_file) %> - <% post.tags.each do |tag| %> + <% archive_file.tags.each do |tag| %> <%= tag[I18n.locale] %> <% 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 d1bfa6c1..dd54bcb5 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 @@ -10,14 +10,11 @@ <%= t('archive_file.tags') %> - - - <% @archive_files.each do |post| %> - <%= render :partial => 'archive_files', :locals => {:post => post} %> - <% end %> - + + <%= render :partial => 'archive_file', :collection => @archive_files %> -<%= paginate @archive_files %> - +
+ <%= paginate @archive_files %> +
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.js.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.js.erb new file mode 100644 index 00000000..7608ab33 --- /dev/null +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/index.js.erb @@ -0,0 +1,2 @@ +$("#tbody_archive").html("<%= j render :partial => 'archive_file', :collection => @archive_files %>"); +$("#archive_pagination").html("<%= j paginate @archive_files %>"); \ No newline at end of file diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb index cfcf47f9..2fa34389 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb @@ -4,17 +4,17 @@ <%#= paginate @archive_files, :params => {:inner => false}%> -<% if @title %> -

<%= @title %>

-<% end %> +<%# if @title %> + +<%# end %> - + + <%# @archive_file_categorys.each do |afcpost| %> + + <%# end %> + -

<%= @archive_files.first.archive_file_category.title rescue nil %>

+

<%= @current_category.title rescue nil %>

<% @archive_files.each do |post| %> diff --git a/vendor/built_in_modules/archive/config/routes.rb b/vendor/built_in_modules/archive/config/routes.rb index ad23d554..ea923bba 100644 --- a/vendor/built_in_modules/archive/config/routes.rb +++ b/vendor/built_in_modules/archive/config/routes.rb @@ -3,7 +3,6 @@ Rails.application.routes.draw do namespace :panel do namespace :archive do namespace :back_end do - root :to => "archive_files#index" resources :archive_files resources :archive_file_categorys resources :tags