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

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