Add pagination to bulletin index and remove ajax to make it simple
This commit is contained in:
parent
32519f308f
commit
6c50aa5243
|
@ -39,11 +39,6 @@ $(document).ready(function(){
|
|||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.sort-header > .sort', function() {
|
||||
$.getScript($(this).attr('rel'));
|
||||
});
|
||||
|
||||
|
||||
var $role = $('.select-role');
|
||||
var method =$('.privacy:eq(1)').attr('checked');
|
||||
|
|
|
@ -8,19 +8,19 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
# @bulletins = Bulletin.desc("postdate desc")
|
||||
get_categorys(params[:bulletin_category_id])
|
||||
get_tags
|
||||
|
||||
|
||||
# @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id]
|
||||
|
||||
# @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.desc("postdate")
|
||||
@bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all.desc("postdate").page(params[:page]).per(10)
|
||||
@bulletin_categories = BulletinCategory.all
|
||||
|
||||
|
||||
@bulletin_link = BulletinLink.new
|
||||
@link_url = panel_announcement_back_end_bulletins_path
|
||||
@link_url = panel_announcement_back_end_bulletins_path
|
||||
|
||||
@bulletin_file = BulletinFile.new
|
||||
@file_url = panel_announcement_back_end_bulletins_path
|
||||
@file_url = panel_announcement_back_end_bulletins_path
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
@ -299,7 +299,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
bulletins = Bulletin.all
|
||||
case params[:sort]
|
||||
when 'postdate', 'deadline'
|
||||
bulletins.order_by([params[:sort], params[:direction]])
|
||||
bulletins.order_by([params[:sort], params[:direction]]).page(params[:page]).per(10)
|
||||
when 'category'
|
||||
category_ids = bulletins.distinct(:bulletin_category_id)
|
||||
categories = BulletinCategory.find(category_ids) rescue nil
|
||||
|
@ -308,7 +308,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries }
|
||||
sorted_categorys.flatten
|
||||
sorted_categorys.flatten!
|
||||
Kaminari.paginate_array(sorted_categorys).page(params[:page]).per(10)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
@ -316,9 +317,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
h = Hash.new
|
||||
bulletins.each { |bulletin| h[bulletin.title[I18n.locale]] = bulletin }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
sorted.collect {|a| a[1] }
|
||||
sorted_titles = sorted.collect {|a| a[1] }
|
||||
Kaminari.paginate_array(sorted_titles).page(params[:page]).per(10)
|
||||
when 'status'
|
||||
bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction])
|
||||
bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).page(params[:page]).per(10)
|
||||
when 'update_user_id'
|
||||
user_ids = bulletins.distinct(:update_user_id)
|
||||
users = User.find(user_ids) rescue nil
|
||||
|
@ -327,7 +329,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
users.each { |user| h[user.name] = user.id }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries }
|
||||
sorted_users.flatten
|
||||
sorted_users.flatten!
|
||||
Kaminari.paginate_array(sorted_users).page(params[:page]).per(10)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
@ -335,7 +338,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
a = Array.new
|
||||
AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins }
|
||||
a.flatten!
|
||||
a.uniq
|
||||
a.uniq!
|
||||
Kaminari.paginate_array(a).page(params[:page]).per(10)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,39 +1,3 @@
|
|||
<!--<thead>
|
||||
<tr class="sort-header">
|
||||
<th class="span1 strong">
|
||||
<input type="checkbox">
|
||||
<a href class="list-remove"><i class="icon-trash"></i></a>
|
||||
</th>
|
||||
<th class="sort span1 <%= is_sort_active?('status') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('status')) %>">
|
||||
<%= t('bulletin.status') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('status')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('category') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('category')) %>">
|
||||
<%= t('bulletin.category') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('category')) %>
|
||||
</th>
|
||||
<th class="sort span7 <%= is_sort_active?('title') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('title')) %>">
|
||||
<%= t('bulletin.title') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('title')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('postdate') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('postdate')) %>">
|
||||
<%= t('bulletin.start_date') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('postdate')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('deadline') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('deadline')) %>">
|
||||
<%= t('bulletin.end_date') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('deadline')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('tags') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('tags')) %>">
|
||||
<%= t('bulletin.tags') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('tags')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('update_user_id') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %>">
|
||||
<%= t('bulletin.last_modified') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('update_user_id')) %>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>-->
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1"></th>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="subnav">
|
||||
<div id='filter' class="subnav">
|
||||
<ul class="nav nav-pills filter">
|
||||
<li class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
|
@ -61,33 +61,26 @@
|
|||
<input type="checkbox">
|
||||
<a href class="list-remove"><i class="icon-trash"></i></a>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('status') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('status')) %>">
|
||||
<%= t('bulletin.status') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('status')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('status') %>">
|
||||
<%= link_to t('bulletin.status') + content_tag(:b, nil, :class => is_sort?('status')), panel_announcement_back_end_bulletins_path(sortable('status')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('category') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('category')) %>">
|
||||
<%= t('bulletin.category') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('category')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('category') %>">
|
||||
<%= link_to t('bulletin.category') + content_tag(:b, nil, :class => is_sort?('category')), panel_announcement_back_end_bulletins_path(sortable('category')) %>
|
||||
</th>
|
||||
<th class="sort span7 <%= is_sort_active?('title') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('title')) %>">
|
||||
<%= t('bulletin.title') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('title')) %>
|
||||
<th class="sort span7 <%= is_sort_active?('title') %>">
|
||||
<%= link_to t('bulletin.title') + content_tag(:b, nil, :class => is_sort?('title')), panel_announcement_back_end_bulletins_path(sortable('title')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('postdate') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('postdate')) %>">
|
||||
<%= t('bulletin.start_date') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('postdate')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('postdate') %>">
|
||||
<%= link_to t('bulletin.start_date') + content_tag(:b, nil, :class => is_sort?('postdate')), panel_announcement_back_end_bulletins_path(sortable('postdate')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('deadline') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('deadline')) %>">
|
||||
<%= t('bulletin.end_date') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('deadline')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('deadline') %>">
|
||||
<%= link_to t('bulletin.end_date') + content_tag(:b, nil, :class => is_sort?('deadline')), panel_announcement_back_end_bulletins_path(sortable('deadline')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('tags') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('tags')) %>">
|
||||
<%= t('bulletin.tags') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('tags')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('tags') %>">
|
||||
<%= link_to t('bulletin.tags') + content_tag(:b, nil, :class => is_sort?('tags')), panel_announcement_back_end_bulletins_path(sortable('tags')) %>
|
||||
</th>
|
||||
<th class="sort span1-2 <%= is_sort_active?('update_user_id') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %>">
|
||||
<%= t('bulletin.last_modified') %>
|
||||
<%= content_tag(:b, nil, :class => is_sort?('update_user_id')) %>
|
||||
<th class="sort span1-2 <%= is_sort_active?('update_user_id') %>">
|
||||
<%= link_to t('bulletin.last_modified') + content_tag(:b, nil, :class => is_sort?('update_user_id')), panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<%= render 'bulletins' %>
|
||||
</table>
|
||||
|
||||
<%= paginate @bulletins %>
|
||||
|
||||
<div id="bulletin_link_qe">
|
||||
<div id="modal-link" class="modal fade">
|
||||
<%= render :partial => "bulletin_link_qe" %>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
$("#bulettin_sort_list").html("<%= j render 'bulletins' %>")
|
Loading…
Reference in New Issue