manual sort for archive top
This commit is contained in:
		
							parent
							
								
									01e55c7eea
								
							
						
					
					
						commit
						8d953e1336
					
				| 
						 | 
				
			
			@ -8,7 +8,7 @@ class ArchivesController < ApplicationController
 | 
			
		|||
				page.save
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		files_by_cateogry = ArchiveFile.where(is_hidden: false).filter_by_categories.filter_by_tags.order_by([:is_top, :desc],[:sort_number, :asc]).group_by(&:category)
 | 
			
		||||
		files_by_cateogry = ArchiveFile.where(is_hidden: false).filter_by_categories.filter_by_tags.group_by(&:category)
 | 
			
		||||
		categories = files_by_cateogry.keys
 | 
			
		||||
		cats = categories.collect do |category|
 | 
			
		||||
			url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
 | 
			
		||||
| 
						 | 
				
			
			@ -35,10 +35,12 @@ class ArchivesController < ApplicationController
 | 
			
		|||
					"archive-title" => archive.title,
 | 
			
		||||
					"statuses" => statuses,
 | 
			
		||||
					"sort_number" => archive.sort_number,
 | 
			
		||||
					"is_top" => (archive.is_top ? 1 : 0),
 | 
			
		||||
					"files" => files
 | 
			
		||||
				}
 | 
			
		||||
			end
 | 
			
		||||
			sorted = archives.sort_by{|k,v| k["sort_number"].to_i}
 | 
			
		||||
			sorted = sorted.sort_by{|k,v| v["is_top"]}
 | 
			
		||||
			{
 | 
			
		||||
				"category-title" => category.title,
 | 
			
		||||
				"archives" => sorted,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue