Put sorting in web_link, page_context and design
This commit is contained in:
1 parent
b48099d752
commit
f190ce18ee
23 files changed
+130
-259
No files matched your search
-82
@@ -331,87 +331,5 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
def get_sorted_and_filtered_bulletins
|
||||
bulletins = Bulletin.all
|
||||
case params[:sort]
|
||||
when 'postdate', 'deadline'
|
||||
bulletins = bulletins.order_by([params[:sort], params[:direction]])
|
||||
when 'category'
|
||||
category_ids = bulletins.distinct(:bulletin_category_id)
|
||||
categories = BulletinCategory.find(category_ids) rescue nil
|
||||
if categories
|
||||
h = Hash.new
|
||||
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 }
|
||||
bulletins = sorted_categorys.flatten!
|
||||
end
|
||||
when 'title'
|
||||
h = Array.new
|
||||
bulletins.each { |bulletin| h << [bulletin.title[I18n.locale].downcase, bulletin] }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
bulletins = sorted.collect {|a| a[1] }
|
||||
when 'status'
|
||||
bulletins = bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).order_by(:is_pending, params[:direction]).order_by(:is_checked, params[:direction]).order_by(:is_rejected, params[:direction])
|
||||
when 'update_user_id'
|
||||
user_ids = bulletins.distinct(:update_user_id)
|
||||
users = User.find(user_ids) rescue nil
|
||||
if users
|
||||
h = Array.new
|
||||
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 }
|
||||
bulletins = sorted_users.flatten
|
||||
end
|
||||
when 'tags'
|
||||
a = Array.new
|
||||
AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins }
|
||||
a.flatten!
|
||||
a.uniq!
|
||||
tmp = Array.new
|
||||
bulletins.where(:tag_ids => []).each { |bulletin| tmp << [bulletin.title[I18n.locale].downcase, bulletin] }
|
||||
sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
|
||||
sorted_titles = sorted.collect {|a| a[1] }
|
||||
a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles)
|
||||
bulletins = a.flatten
|
||||
end
|
||||
if @filter
|
||||
@filter.each do |key, value|
|
||||
case key
|
||||
when 'status'
|
||||
a = Array.new
|
||||
bulletins.each do |bulletin|
|
||||
value.each do |v|
|
||||
case v
|
||||
when 'pending'
|
||||
a << bulletin if bulletin.is_checked.nil?
|
||||
when 'rejected'
|
||||
a << bulletin if bulletin.is_checked.eql?(false)
|
||||
else
|
||||
a << bulletin if bulletin[v]
|
||||
end
|
||||
end
|
||||
end
|
||||
bulletins = a.uniq
|
||||
when 'categories'
|
||||
a = Array.new
|
||||
bulletins.each do |bulletin|
|
||||
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
|
||||
end
|
||||
bulletins = a.uniq
|
||||
when 'tags'
|
||||
a = Array.new
|
||||
bulletins.each do |bulletin|
|
||||
bulletin.tags.each do |tag|
|
||||
a << bulletin if value.include?(tag.id.to_s)
|
||||
end
|
||||
end
|
||||
bulletins = a.uniq
|
||||
end if value.size > 0
|
||||
end
|
||||
end
|
||||
Kaminari.paginate_array(bulletins).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
end
|
||||
Vendored
-82
@@ -333,86 +333,4 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
def get_sorted_and_filtered_news_bulletins
|
||||
news_bulletins = NewsBulletin.all
|
||||
case params[:sort]
|
||||
when 'postdate', 'deadline'
|
||||
news_bulletins = news_bulletins.order_by([params[:sort], params[:direction]])
|
||||
when 'category'
|
||||
category_ids = news_bulletins.distinct(:news_bulletin_category_id)
|
||||
categories = NewsBulletinCategory.find(category_ids) rescue nil
|
||||
if categories
|
||||
h = Hash.new
|
||||
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| news_bulletins.where(:news_bulletin_category_id => a[1]).entries }
|
||||
news_bulletins = sorted_categorys.flatten!
|
||||
end
|
||||
when 'title'
|
||||
h = Array.new
|
||||
news_bulletins.each { |news_bulletin| h << [news_bulletin.title[I18n.locale].downcase, news_bulletin] }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
news_bulletins = sorted.collect {|a| a[1] }
|
||||
when 'status'
|
||||
news_bulletins = news_bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).order_by(:is_pending, params[:direction]).order_by(:is_checked, params[:direction]).order_by(:is_rejected, params[:direction])
|
||||
when 'update_user_id'
|
||||
user_ids = news_bulletins.distinct(:update_user_id)
|
||||
users = User.find(user_ids) rescue nil
|
||||
if users
|
||||
h = Array.new
|
||||
users.each { |user| h << [user.name, user.id] }
|
||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||
sorted_users = sorted.collect {|a| news_bulletins.where(:update_user_id => a[1]).entries }
|
||||
news_bulletins = sorted_users.flatten
|
||||
end
|
||||
when 'tags'
|
||||
a = Array.new
|
||||
NewsTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.news_bulletins }
|
||||
a.flatten!
|
||||
a.uniq!
|
||||
tmp = Array.new
|
||||
news_bulletins.where(:tag_ids => []).each { |news_bulletin| tmp << [news_bulletin.title[I18n.locale].downcase, news_bulletin] }
|
||||
sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
|
||||
sorted_titles = sorted.collect {|a| a[1] }
|
||||
a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles)
|
||||
news_bulletins = a.flatten
|
||||
end
|
||||
if @filter
|
||||
@filter.each do |key, value|
|
||||
case key
|
||||
when 'status'
|
||||
a = Array.new
|
||||
news_bulletins.each do |news_bulletin|
|
||||
value.each do |v|
|
||||
case v
|
||||
when 'pending'
|
||||
a << news_bulletin if news_bulletin.is_checked.nil?
|
||||
when 'rejected'
|
||||
a << news_bulletin if news_bulletin.is_checked.eql?(false)
|
||||
else
|
||||
a << news_bulletin if news_bulletin[v]
|
||||
end
|
||||
end
|
||||
end
|
||||
news_bulletins = a.uniq
|
||||
when 'categories'
|
||||
a = Array.new
|
||||
news_bulletins.each do |news_bulletin|
|
||||
a << news_bulletin if value.include?(news_bulletin.news_bulletin_category.id.to_s)
|
||||
end
|
||||
news_bulletins = a.uniq
|
||||
when 'tags'
|
||||
a = Array.new
|
||||
news_bulletins.each do |news_bulletin|
|
||||
news_bulletin.tags.each do |tag|
|
||||
a << news_bulletin if value.include?(tag.id.to_s)
|
||||
end
|
||||
end
|
||||
news_bulletins = a.uniq
|
||||
end if value.size > 0
|
||||
end
|
||||
end
|
||||
Kaminari.paginate_array(news_bulletins).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
end
|
||||
+2
-1
@@ -5,11 +5,12 @@ class Panel::PageContent::BackEnd::PageContextsController < OrbitBackendControll
|
||||
|
||||
def index
|
||||
|
||||
@page_contexts = PageContext.where(:archived => false).desc(:updated_at).page(params[:page]).per(10)
|
||||
@page_contexts = params[:sort] ? get_sorted_and_filtered("page_contexts", {:archived => false}) : PageContext.where(:archived => false).page(params[:page]).per(10)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @page_contexts }
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<div id='filter' class="subnav">
|
||||
<div class="filters">
|
||||
<div id="sort_headers" class="table-label">
|
||||
<%= render 'sort_headers' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "sort_header" %>
|
||||
<% end %>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<%= render_sort_bar(false, ['name', 'page','span7', 'page_context.name'],
|
||||
['version', 'version', 'span2', 'page_context.version'],
|
||||
['update_time', 'updated_at', 'span2', 'page_context.update_time'],
|
||||
['last_modified', 'update_user_id', 'span2', 'page_context.last_modified']).html_safe %>
|
||||
+5
-21
@@ -1,22 +1,6 @@
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<div id="filter" class="subnav">
|
||||
<div class="filters">
|
||||
<div id="sort_headers" class="table-label">
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span7"><%= t('page_context.name') %></th>
|
||||
<th class="span2"><%= t('page_context.version') %></th>
|
||||
<th class="span2"><%= t('page_context.update_time') %></th>
|
||||
<th class="span2"><%= t('page_context.last_modified') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= render 'filter' %>
|
||||
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
@@ -27,13 +11,13 @@
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="tbody_page_contexts" class="sort-holder">
|
||||
|
||||
<%= render :partial => 'page_context', :collection => @page_contexts %>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate @page_contexts %>
|
||||
|
||||
|
||||
<div id="page_context_pagination" class="paginationFixed">
|
||||
<%= paginate @page_contexts, :params => {:direction => params[:direction], :sort => params[:sort]} %>
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
$("#sort_headers").html("<%= j render 'sort_headers' %>");
|
||||
$("#tbody_page_contexts").html("<%= j render :partial => 'page_context', :collection => @page_contexts %>");
|
||||
$("#page_context_pagination").html("<%= j paginate @page_contexts, :params => {:direction => params[:direction], :sort => params[:sort]} %>");
|
||||
+7
@@ -122,6 +122,13 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
if params[:to_delete]
|
||||
web_links = WebLink.any_in(:_id => params[:to_delete]).delete_all
|
||||
end
|
||||
redirect_to panel_web_resource_back_end_web_links_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<%= render_sort_bar(false, ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1', 'bulletin.status'],
|
||||
<%= render_sort_bar(true, ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1', 'bulletin.status'],
|
||||
['category', 'bulletin_category', 'span2', 'bulletin.category'],
|
||||
['name', 'name','span3', 'bulletin.title'],
|
||||
['tags', 'tags', 'span2', 'bulletin.tags']).html_safe %>
|
||||
+5
@@ -1,4 +1,9 @@
|
||||
<tr id="<%= dom_id web_link %>" class="with_action">
|
||||
<td>
|
||||
<% if (web_link.create_user_id == current_user.id) || is_manager? %>
|
||||
<%= check_box_tag 'to_delete[]', web_link.id, false, :class => "checkbox_in_list" %>
|
||||
<% end -%>
|
||||
</td>
|
||||
<td>
|
||||
<div class="label-group">
|
||||
<div class="label-td">
|
||||
|
||||
Vendored
+17
-14
@@ -1,17 +1,20 @@
|
||||
<%= render 'filter' %>
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1"></th>
|
||||
<th class="span2"></th>
|
||||
<th class="span3"></th>
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_web_links" class="sort-holder">
|
||||
<%= render :partial => 'web_link', :collection => @web_links %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= form_for :news_bulletins, :url => delete_panel_web_resource_back_end_web_links_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
|
||||
<%= render 'filter' %>
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1"></th>
|
||||
<th class="span1"></th>
|
||||
<th class="span2"></th>
|
||||
<th class="span3"></th>
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_web_links" class="sort-holder">
|
||||
<%= render :partial => 'web_link', :collection => @web_links %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<div id="web_link_pagination" class="paginationFixed">
|
||||
<%= paginate @web_links, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
|
||||
|
||||
+5
-1
@@ -4,7 +4,11 @@ Rails.application.routes.draw do
|
||||
namespace :web_resource do
|
||||
namespace :back_end do
|
||||
root :to => "web_links#index"
|
||||
resources :web_links
|
||||
resources :web_links do
|
||||
collection do
|
||||
post 'delete'
|
||||
end
|
||||
end
|
||||
resources :web_link_categorys
|
||||
resources :tags
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user