archive module: add sort to frontend module
Conflicts: vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb Conflicts: vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb Conflicts: vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb
This commit is contained in:
		
							parent
							
								
									e20df41db5
								
							
						
					
					
						commit
						e48a1ffece
					
				|  | @ -1,4 +1,5 @@ | ||||||
| class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController | class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController | ||||||
|  |   include AdminHelper | ||||||
| 
 | 
 | ||||||
|   def initialize |   def initialize | ||||||
|     super |     super | ||||||
|  | @ -30,27 +31,26 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController | ||||||
|     @archive_file_categorys = ArchiveFileCategory.all |     @archive_file_categorys = ArchiveFileCategory.all | ||||||
|     # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) |     # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) | ||||||
| 
 | 
 | ||||||
|     if params[:search_query] |  | ||||||
|       get_search_result |  | ||||||
|       @archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => @archive_file_categorys.collect{|t| t.id}).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) |  | ||||||
|     else |  | ||||||
|     if !params[:category_id].blank? && !params[:tag_id].blank? |     if !params[:category_id].blank? && !params[:tag_id].blank? | ||||||
|         @archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) |       @archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) | ||||||
| 
 | 
 | ||||||
|         @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil |         @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil | ||||||
| 
 | 
 | ||||||
|     elsif !params[:category_id].blank? |     elsif !params[:category_id].blank? | ||||||
|         @archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) |       @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) | ||||||
|       @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil |       @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil | ||||||
|     elsif !params[:tag_id].blank? |     elsif !params[:tag_id].blank? | ||||||
|         @archive_files = ArchiveFile.can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) |       @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) | ||||||
|     else |     else | ||||||
|         @archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) |       @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) | ||||||
|       end |  | ||||||
|     end |     end | ||||||
|        |        | ||||||
| 
 | 
 | ||||||
|     get_categorys |     get_categorys | ||||||
|  | 
 | ||||||
|  |     if params[:sort] | ||||||
|  |       @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) | ||||||
|  |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def show |   def show | ||||||
|  |  | ||||||
							
								
								
									
										56
									
								
								vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb
								
								
								
									vendored
								
								
									Normal file
								
							
							
						
						
									
										56
									
								
								vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/_index.html.erb
								
								
								
									vendored
								
								
									Normal file
								
							|  | @ -0,0 +1,56 @@ | ||||||
|  | <% # encoding: utf-8 %> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	<div class="o-archives layout-table"> | ||||||
|  | 
 | ||||||
|  | 		<table> | ||||||
|  | 			<thead> | ||||||
|  | 				<tr> | ||||||
|  | 					<th class="column-ctrl col-title"><%= sortable(:title, t("archive.Title"))%></th> | ||||||
|  | 					<th class="column-ctrl col-file"><%= t("archive.Files")%></th> | ||||||
|  | 					<th class="column-ctrl col-category"><%= sortable(:archive_file_category, t("archive.Category"))%></th> | ||||||
|  | 				</tr> | ||||||
|  | 			</thead> | ||||||
|  | 			<tbody> | ||||||
|  | 
 | ||||||
|  | 				<% @archive_files.each_with_index do |post,i| %> | ||||||
|  | 				<tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>> | ||||||
|  | 					<td><div class="o-archives-title"><%= post.title %></div></td> | ||||||
|  | 					<td> | ||||||
|  | 						<div class="o-archives-list-item"> | ||||||
|  | 							<% if !post.archive_file_multiples.blank? %> | ||||||
|  | 							<ol> | ||||||
|  | 								<% post.archive_file_multiples.asc(:_id).each do | afile |  %> | ||||||
|  | 									<%  if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> | ||||||
|  | 										<li> | ||||||
|  | 											<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> | ||||||
|  | 											<%= post.get_file_icon(afile.file.url) %> | ||||||
|  | 										</li> | ||||||
|  | 									<% end %> | ||||||
|  | 								<% end %> | ||||||
|  | 							</ol> | ||||||
|  | 							<% end %> | ||||||
|  | 						</div> | ||||||
|  | 					</td> | ||||||
|  | 					<td><div class="o-archives-category"> | ||||||
|  | 						<%= post.archive_file_category.title %> | ||||||
|  | 					</div></td> | ||||||
|  | 				</tr> | ||||||
|  | 				<% end %> | ||||||
|  | 
 | ||||||
|  | 			</tbody> | ||||||
|  | 		</table> | ||||||
|  | 	</div> | ||||||
|  | 
 | ||||||
|  | <%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %> | ||||||
|  | 
 | ||||||
|  | <%= stylesheet_link_tag "archive/archives" %> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -1,49 +1,10 @@ | ||||||
| <% # encoding: utf-8 %> | <%= stylesheet_link_tag "default_widget" %> | ||||||
|  | <script type='text/javascript' src='/assets/jquery.mu.image.resize.js'></script> | ||||||
|  | <script type='text/javascript' src='/assets/jquery.mu.image.resize.degsin.js'></script> | ||||||
| 
 | 
 | ||||||
| <%= render :partial => 'shared/search_header',:locals=>{:items=>@archive_files}  %> | <div id="archive_file_widget"> | ||||||
| 
 | 	<%= render 'index' %> | ||||||
| 	<div class="o-archives layout-table"> |  | ||||||
| 
 |  | ||||||
| 		<table> |  | ||||||
| 			<thead> |  | ||||||
| 				<tr> |  | ||||||
| 					<th class="column-ctrl col-title"><%= t("archive.Title")%></th> |  | ||||||
| 					<th class="column-ctrl col-file"><%= t("archive.Files")%></th> |  | ||||||
| 					<th class="column-ctrl col-category"><%= t("archive.Category")%></th> |  | ||||||
| 				</tr> |  | ||||||
| 			</thead> |  | ||||||
| 			<tbody> |  | ||||||
| 
 |  | ||||||
| 				<% @archive_files.each_with_index do |post,i| %> |  | ||||||
| 				<tr <% if i.even?%> class="even" <% end %>> |  | ||||||
| 					<td><div class="o-archives-title"><%= post.title %></div></td> |  | ||||||
| 					<td> |  | ||||||
| 						<div class="o-archives-list-item"> |  | ||||||
| 							<% if !post.archive_file_multiples.blank? %> |  | ||||||
| 							<ol> |  | ||||||
| 								<% post.archive_file_multiples.asc(:_id).each do | afile |  %>	 |  | ||||||
| 									<%  if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> |  | ||||||
| 										<li> |  | ||||||
| 											<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> |  | ||||||
| 											<%= post.get_file_icon(afile.file.url) %> |  | ||||||
| 										</li> |  | ||||||
| 									<% end %> |  | ||||||
| 								<% end %> |  | ||||||
| 							</ol> |  | ||||||
| 							<% end %> |  | ||||||
| </div> | </div> | ||||||
| 					</td> |  | ||||||
| 					<td><div class="o-archives-category"> |  | ||||||
| 						<%= post.archive_file_category.title %> |  | ||||||
| 					</div></td> |  | ||||||
| 				</tr> |  | ||||||
| 				<% end %> |  | ||||||
| 
 |  | ||||||
| 			</tbody> |  | ||||||
| 		</table> |  | ||||||
| 	</div> |  | ||||||
| 
 |  | ||||||
| <%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %> |  | ||||||
| 
 | 
 | ||||||
| <%= stylesheet_link_tag "archive/archives" %> | <%= stylesheet_link_tag "archive/archives" %> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb
								
								
								
									vendored
								
								
									Normal file
								
							
							
						
						
									
										1
									
								
								vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.js.erb
								
								
								
									vendored
								
								
									Normal file
								
							|  | @ -0,0 +1 @@ | ||||||
|  | $('#archive_file_widget').html("<%= j render 'index' %>") | ||||||
		Loading…
	
		Reference in New Issue