This commit is contained in:
Harry Bomrah 2015-11-06 18:17:53 +08:00
parent e4bf9f829c
commit 251e6ee583
1 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class ArchivesController < ApplicationController
page.save
end
end
files_by_cateogry = ArchiveFile.filter_by_categories.filter_by_tags.group_by(&:category)
files_by_cateogry = ArchiveFile.filter_by_categories.filter_by_tags.asc(:sort_number).group_by(&:category)
categories = files_by_cateogry.keys
cats = categories.collect do |category|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
@ -64,9 +64,9 @@ class ArchivesController < ApplicationController
def group_by_category
cat_id = OrbitHelper.widget_categories.map {|cat_id| cat_id.to_s}
if OrbitHelper.widget_tags.first == "all"
files_by_cateogry = ArchiveFile.where(:category_id.in => OrbitHelper.widget_categories).with_tags(OrbitHelper.widget_module_app.tags.collect{|tag| tag.id.to_s}).group_by(&:category)
files_by_cateogry = ArchiveFile.where(:category_id.in => OrbitHelper.widget_categories).with_tags(OrbitHelper.widget_module_app.tags.collect{|tag| tag.id.to_s}).asc(:sort_number).group_by(&:category)
else
files_by_cateogry = ArchiveFile.where(:category_id.in => OrbitHelper.widget_categories).with_tags(OrbitHelper.widget_tags).group_by(&:category)
files_by_cateogry = ArchiveFile.where(:category_id.in => OrbitHelper.widget_categories).with_tags(OrbitHelper.widget_tags).asc(:sort_number).group_by(&:category)
end
cats = files_by_cateogry.keys.collect do |cat|
files_by_category_tag = files_by_cateogry[cat].group_by(&:tags)