Add link_to_edit for frontend

This commit is contained in:
manson 2014-08-05 14:38:36 +08:00
parent 16ae9aa31f
commit a0391f0c1e
1 changed files with 7 additions and 11 deletions

View File

@ -4,20 +4,15 @@ class ArchivesController < ApplicationController
@categories = []
if categories.first == "all"
module_app = OrbitHelper.this_module_app
@categories = module_app.categories.collect do |cat|
{
"title" => cat.title || "",
"id" => cat.id.to_s
}
end
@categories = module_app.categories
else
categories.each do |cat|
c = Category.find(cat)
@categories << {"title" => c.title || "", "id" => c.id.to_s}
@categories << Category.find(cat)
end
end
cats = @categories.collect do |cat|
archives = ArchiveFile.where(:category_id => cat["id"]).order_by(:sort_number=>'asc').collect do |archive|
url_to_edit = OrbitHelper.user_has_cateogry?(cat) ? "/admin/archive_files?filters[category][]=#{cat.id.to_s}" : ""
archives = ArchiveFile.where(:category_id => cat.id).order_by(:sort_number=>'asc').collect do |archive|
statuses = archive.statuses_with_classname.collect do |status|
{
"status" => status["name"] || "",
@ -42,8 +37,9 @@ class ArchivesController < ApplicationController
}
end
{
"category-title" => cat["title"] || "",
"archives" => archives
"category-title" => cat.title || "",
"archives" => archives ,
"url_to_edit" => url_to_edit
}
end