From a0391f0c1eb62c853617d33d7319d3a708de686d Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 5 Aug 2014 14:38:36 +0800 Subject: [PATCH] Add link_to_edit for frontend --- app/controllers/archives_controller.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index 5237d31..a81c3aa 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -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