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