diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
index 7a096ad0..ad362323 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
@@ -1,24 +1,28 @@
<%= check_box_tag 'to_delete[]', bulletin.id, false, :class => "checkbox_in_list" %> |
- <% if bulletin.is_top? %>
- <%= t(:top) %>
- <% end %>
- <% if bulletin.is_hot? %>
- <%= t(:hot) %>
- <% end %>
- <% if bulletin.is_hidden? %>
- <%= t(:hidden) %>
- <% end %>
- <% if bulletin.is_pending? %>
- <%= t(:pending) %>
- <% end %>
- <% if bulletin.is_checked? %>
- <%= t(:passed) %>
- <% end %>
- <% if bulletin.is_rejected? %>
- <%= t(:rejected) %>
- <% end %>
+
+
+ <% if bulletin.is_top? %>
+ <%= t(:top) %>
+ <% end %>
+ <% if bulletin.is_hot? %>
+ <%= t(:hot) %>
+ <% end %>
+ <% if bulletin.is_hidden? %>
+ <%= t(:hidden) %>
+ <% end %>
+ <% if bulletin.is_pending? %>
+ <%= t(:pending) %>
+ <% end %>
+ <% if bulletin.is_checked? %>
+ <%= t(:passed) %>
+ <% end %>
+ <% if bulletin.is_rejected? %>
+ <%= t(:rejected) %>
+ <% end %>
+
+
|
<%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> |
diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb
index c3fe0fbc..25c41606 100644
--- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb
+++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb
@@ -7,14 +7,32 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
get_categorys(params[:web_link_category_id])
+ @filter = params[:filter]
+ new_filter = params[:new_filter]
+
+ if @filter && params[:clear]
+ @filter.delete(params[:type])
+ elsif @filter && new_filter
+ if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
+ @filter[new_filter[:type]].delete(new_filter[:id].to_s)
+ elsif @filter.has_key?(new_filter[:type])
+ @filter[new_filter[:type]] << new_filter[:id].to_s
+ else
+ @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
+ end
+ elsif new_filter
+ @filter = {new_filter[:type] => [new_filter[:id].to_s]}
+ end
+
# @web_links = WebLink.search(params[:category_id])
- @web_links = WebLink.all.page(params[:page]).per(10)
+ @web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
get_tags
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @web_links }
+ format.js
end
end
@@ -115,5 +133,75 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
end
+
+ def get_sorted_and_filtered_web_links
+ web_links = WebLink.all
+ case params[:sort]
+ when 'category'
+ category_ids = web_links.distinct(:web_link_category_id)
+ categories = WebLinkCategory.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| web_links.where(:web_link_category_id => a[1]).entries }
+ web_links = sorted_categorys.flatten!
+ end
+ when 'name'
+ h = Array.new
+ web_links.each { |web_link| h << [web_link.name[I18n.locale].downcase, web_link] }
+ sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
+ web_links = sorted.collect {|a| a[1] }
+ when 'status'
+ web_links = web_links.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 'tags'
+ a = Array.new
+ WebResourceTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.web_links }
+ a.flatten!
+ a.uniq!
+ tmp = Array.new
+ web_links.where(:tag_ids => []).each { |web_link| tmp << [web_link.name[I18n.locale].downcase, web_link] }
+ sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
+ sorted_names = sorted.collect {|a| a[1] }
+ a = params[:direction].eql?('asc') ? (sorted_names + a) : (a + sorted_names)
+ web_links = a.flatten
+ end
+ # if @filter
+ # @filter.each do |key, value|
+ # case key
+ # when 'status'
+ # a = Array.new
+ # web_links.each do |web_link|
+ # value.each do |v|
+ # case v
+ # when 'pending'
+ # a << web_link if web_link.is_checked.nil?
+ # when 'rejected'
+ # a << web_link if web_link.is_checked.eql?(false)
+ # else
+ # a << web_link if web_link[v]
+ # end
+ # end
+ # end
+ # web_links = a.uniq
+ # when 'categories'
+ # a = Array.new
+ # web_links.each do |web_link|
+ # a << web_link if value.include?(web_link.web_link_category.id.to_s)
+ # end
+ # web_links = a.uniq
+ # when 'tags'
+ # a = Array.new
+ # web_links.each do |web_link|
+ # web_link.tags.each do |tag|
+ # a << web_link if value.include?(tag.id.to_s)
+ # end
+ # end
+ # web_links = a.uniq
+ # end if value.size > 0
+ # end
+ # end
+ Kaminari.paginate_array(web_links).page(params[:page]).per(10)
+ end
end
diff --git a/vendor/built_in_modules/web_resource/app/models/web_link.rb b/vendor/built_in_modules/web_resource/app/models/web_link.rb
index e6753fea..9bd06f05 100644
--- a/vendor/built_in_modules/web_resource/app/models/web_link.rb
+++ b/vendor/built_in_modules/web_resource/app/models/web_link.rb
@@ -60,6 +60,10 @@ class WebLink
def text
@text ||= I18nVariable.first(:conditions => {:key => 'text', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
+ end
+
+ def sorted_tags
+ tags.order_by(I18n.locale, :asc)
end
protected
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_filter.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_filter.html.erb
new file mode 100644
index 00000000..831fee17
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_filter.html.erb
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb
new file mode 100644
index 00000000..a09af38c
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb
@@ -0,0 +1,18 @@
+
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb
new file mode 100644
index 00000000..ad8f5ade
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb
@@ -0,0 +1,37 @@
+ |
+
+
+
+ <% if web_link.is_top? %>
+ <%= t(:top) %>
+ <% end %>
+ <% if web_link.is_hot? %>
+ <%= t(:hot) %>
+ <% end %>
+ <% if web_link.is_hidden? %>
+ <%= t(:hidden) %>
+ <% end %>
+
+
+ |
+ <%= web_link.web_link_category.i18n_variable[I18n.locale] %> |
+
+ <%= link_to web_link.name[I18n.locale], panel_web_resource_back_end_web_link_path(web_link) %>
+
+
+ - <%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(web_link) %>
+ - <%= link_to t('web_link.delete'), panel_web_resource_back_end_web_link_path(web_link), :confirm => t('sure?'), :method => :delete, :remote => true %>
+
+
+ |
+
+
+
+ <% web_link.sorted_tags.each do |tag| %>
+ <%= tag[I18n.locale] %>
+ <% end %>
+
+
+ |
+
+
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb
deleted file mode 100644
index e4212569..00000000
--- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- <% if post.is_top? %>
- <%= t(:top) %>
- <% end %>
- <% if post.is_hot? %>
- <%= t(:hot) %>
- <% end %>
- <% if post.is_hidden? %>
- <%= t(:hidden) %>
- <% end %>
- |
- <%= post.web_link_category.i18n_variable[I18n.locale] %> |
-
- <%= link_to post.name[I18n.locale], panel_web_resource_back_end_web_link_path(post) %>
-
-
- - <%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(post) %>
- - <%= link_to t('web_link.delete'), panel_web_resource_back_end_web_link_path(post), :confirm => t('sure?'), :method => :delete, :remote => true %>
-
-
- |
-
- <% post.tags.each do |tag| %>
- <%= tag[I18n.locale] %>
- <% end %>
- |
-
-
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb
index 555a048a..632eb4a1 100644
--- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb
@@ -1,21 +1,4 @@
-
-<%= flash_messages %>
-
+<%= render 'filter' %>
@@ -25,14 +8,11 @@
|
-
-
- <% @web_links.each do |post| %>
- <%= render :partial => 'web_links', :locals => {:post => post} %>
- <% end %>
-
+
+ <%= render :partial => 'web_link', :collection => @web_links %>
-<%= paginate @web_links %>
-
+
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.js.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.js.erb
new file mode 100644
index 00000000..abf256eb
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.js.erb
@@ -0,0 +1,3 @@
+$("#sort_headers").html("<%= j render 'sort_headers' %>");
+$("#tbody_web_links").html("<%= j render :partial => 'web_link', :collection => @web_links %>");
+$("#web_link_pagination").html("<%= j paginate @web_links, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>");
\ No newline at end of file