combine archives which have multiple tags
This commit is contained in:
parent
dbed445f68
commit
f22e8ee17f
|
@ -6,9 +6,11 @@ class ArchivesController < ApplicationController
|
||||||
files_by_category_tag = files_by_cateogry[cat].group_by(&:tags)
|
files_by_category_tag = files_by_cateogry[cat].group_by(&:tags)
|
||||||
|
|
||||||
url_to_edit = OrbitHelper.user_has_cateogry?(cat) ? "/admin/archive_files?filters[category][]=#{cat.id.to_s}" : ""
|
url_to_edit = OrbitHelper.user_has_cateogry?(cat) ? "/admin/archive_files?filters[category][]=#{cat.id.to_s}" : ""
|
||||||
ts = files_by_category_tag.keys.collect do |t|
|
ts = []
|
||||||
|
files_by_category_tag.keys.each do |t|
|
||||||
archives = files_by_category_tag[t].collect do |archive|
|
|
||||||
|
archives = []
|
||||||
|
files_by_category_tag[t].each_with_index do |archive,index|
|
||||||
|
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
statuses = archive.statuses_with_classname.collect do |status|
|
||||||
{
|
{
|
||||||
|
@ -28,18 +30,30 @@ class ArchivesController < ApplicationController
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}"
|
"file-url" => "/xhr/archive/download?file=#{file.id}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{
|
a = {
|
||||||
"archive-title" => archive.title || "",
|
"archive-title" => archive.title || "",
|
||||||
"statuses" => statuses,
|
"statuses" => statuses,
|
||||||
"files" => files
|
"files" => files
|
||||||
}
|
}
|
||||||
|
if t.count > 1
|
||||||
|
t.each do |inner_tag|
|
||||||
|
index = ts.index{|tot| tot["tag-name"] == inner_tag.name}
|
||||||
|
if !index.nil?
|
||||||
|
ts[index]["archives"] << a
|
||||||
|
else
|
||||||
|
archives << a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
archives << a
|
||||||
|
end
|
||||||
end
|
end
|
||||||
{
|
ts << {
|
||||||
"tag-name" => (t[0].name rescue ""),
|
"tag-name" => (t[0].name rescue ""),
|
||||||
"archives" => archives
|
"archives" => archives
|
||||||
|
|
||||||
}
|
} if !archives.blank?
|
||||||
end
|
end
|
||||||
if(files_by_category_tag.empty?)
|
if(files_by_category_tag.empty?)
|
||||||
{
|
{
|
||||||
|
@ -84,18 +98,33 @@ class ArchivesController < ApplicationController
|
||||||
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 = []
|
||||||
archives = files_by_category_tag[t].collect do |archive|
|
files_by_category_tag.keys.each do |t|
|
||||||
{
|
archives = []
|
||||||
|
files_by_category_tag[t].each_with_index do |archive,index|
|
||||||
|
a = {
|
||||||
"archive-title" => archive.title,
|
"archive-title" => archive.title,
|
||||||
"archive_url" => OrbitHelper.widget_more_url
|
"archive_url" => OrbitHelper.widget_more_url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.count > 1
|
||||||
|
t.each do |inner_tag|
|
||||||
|
index = ts.index{|tot| tot["tag-name"] == inner_tag.name}
|
||||||
|
if !index.nil?
|
||||||
|
ts[index]["archives"] << a
|
||||||
|
else
|
||||||
|
archives << a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
archives << a
|
||||||
end
|
end
|
||||||
{
|
end
|
||||||
"tag-name" => (t[0].name rescue ""),
|
ts << {
|
||||||
"archives" => archives
|
"tag-name" => (t[0].name rescue ""),
|
||||||
|
"archives" => archives
|
||||||
|
|
||||||
}
|
} if !archives.blank?
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
"category-title" => cat.title,
|
"category-title" => cat.title,
|
||||||
|
|
Loading…
Reference in New Issue