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)
 | 
			
		||||
 | 
			
		||||
			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|
 | 
			
		||||
				
 | 
			
		||||
				archives = files_by_category_tag[t].collect do |archive|
 | 
			
		||||
			ts = []
 | 
			
		||||
			files_by_category_tag.keys.each do |t|
 | 
			
		||||
 | 
			
		||||
				archives = []
 | 
			
		||||
				files_by_category_tag[t].each_with_index do |archive,index|
 | 
			
		||||
				
 | 
			
		||||
					statuses = archive.statuses_with_classname.collect do |status|
 | 
			
		||||
				        {
 | 
			
		||||
| 
						 | 
				
			
			@ -28,18 +30,30 @@ class ArchivesController < ApplicationController
 | 
			
		|||
								"file-url" => "/xhr/archive/download?file=#{file.id}"
 | 
			
		||||
							}
 | 
			
		||||
						end
 | 
			
		||||
					end	
 | 
			
		||||
					{
 | 
			
		||||
					end
 | 
			
		||||
					a = {
 | 
			
		||||
						"archive-title" => archive.title || "",
 | 
			
		||||
						"statuses" => statuses,
 | 
			
		||||
						"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				
 | 
			
		||||
				{
 | 
			
		||||
				ts << {
 | 
			
		||||
					"tag-name" => (t[0].name rescue ""),
 | 
			
		||||
					"archives" => archives
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
				} if !archives.blank?
 | 
			
		||||
			end
 | 
			
		||||
			if(files_by_category_tag.empty?)
 | 
			
		||||
				{
 | 
			
		||||
| 
						 | 
				
			
			@ -84,18 +98,33 @@ class ArchivesController < ApplicationController
 | 
			
		|||
		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|
 | 
			
		||||
					{
 | 
			
		||||
			ts = []
 | 
			
		||||
			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_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
 | 
			
		||||
				{
 | 
			
		||||
					"tag-name" => (t[0].name rescue ""),
 | 
			
		||||
					"archives" => archives
 | 
			
		||||
			end
 | 
			
		||||
			ts << {
 | 
			
		||||
				"tag-name" => (t[0].name rescue ""),
 | 
			
		||||
				"archives" => archives
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
			} if !archives.blank?
 | 
			
		||||
			end
 | 
			
		||||
			{
 | 
			
		||||
				"category-title" => cat.title,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue