fix widget tags problem

This commit is contained in:
Ruling-Mac 2015-07-17 15:29:41 +08:00
parent 12c5cdbfe4
commit dbed445f68
1 changed files with 12 additions and 31 deletions

View File

@ -28,27 +28,15 @@ class ArchivesController < ApplicationController
"file-url" => "/xhr/archive/download?file=#{file.id}" "file-url" => "/xhr/archive/download?file=#{file.id}"
} }
end end
end end
{ {
"archive-title" => archive.title || "", "archive-title" => archive.title || "",
"statuses" => statuses, "statuses" => statuses,
"files" => files "files" => files
} }
end end
tag_name = ""
if(!t.nil?)
t.each do |item|
tag_name += item.name + " + "
end
end
tag_name = (tag_name[0...-2] rescue "")
{ {
"tag-name" => tag_name, "tag-name" => (t[0].name rescue ""),
"archives" => archives "archives" => archives
} }
@ -57,7 +45,7 @@ class ArchivesController < ApplicationController
{ {
"category-title" => "", "category-title" => "",
"tags" => ts, "tags" => ts,
"link_to_edit" => url_to_edit "url_to_edit" => url_to_edit
} }
else else
@ -87,13 +75,15 @@ class ArchivesController < ApplicationController
end end
def widget def widget
if OrbitHelper.widget_tags.first == "all"
files_by_cateogry = ArchiveFile.filter_by_widget_categories.with_tags(OrbitHelper.widget_module_app.tags.collect{|tag| tag.id.to_s}).group_by(&:category)
else
files_by_cateogry = ArchiveFile.filter_by_widget_categories.with_tags(OrbitHelper.widget_tags).group_by(&:category) files_by_cateogry = ArchiveFile.filter_by_widget_categories.with_tags(OrbitHelper.widget_tags).group_by(&:category)
end
cats = files_by_cateogry.keys.collect do |cat| cats = files_by_cateogry.keys.collect do |cat|
files_by_category_tag = files_by_cateogry[cat].group_by(&:tags) files_by_category_tag = files_by_cateogry[cat].group_by(&:tags)
ts = files_by_category_tag.keys.collect do |t| ts = files_by_category_tag.keys.collect do |t|
archives = files_by_category_tag[t].collect do |archive| archives = files_by_category_tag[t].collect do |archive|
{ {
@ -101,17 +91,8 @@ class ArchivesController < ApplicationController
"archive_url" => OrbitHelper.widget_more_url "archive_url" => OrbitHelper.widget_more_url
} }
end end
tag_name = ""
if(!t.nil?)
t.each do |item|
tag_name += item.name + " + "
end
end
tag_name = (tag_name[0...-2] rescue "")
{ {
"tag-name" => tag_name, "tag-name" => (t[0].name rescue ""),
"archives" => archives "archives" => archives
} }