Pagination

This commit is contained in:
manson 2014-07-18 15:06:04 +08:00
parent 884f4a0e82
commit ee08037aad
4 changed files with 7 additions and 4 deletions

View File

@ -5,7 +5,7 @@ class Admin::ProjectsController < OrbitMemberController
before_action :get_settings,:only => [:new, :edit, :setting]
def index
@projects = Project.all
@projects = Project.order_by(:period_start_date=>'desc',:year=>'desc').page(params[:page]).per(10)
end
def new

View File

@ -1,6 +1,6 @@
class PersonalProjectsController < ApplicationController
def index
projects = Project.where(:is_hidden=>false).all
projects = Project.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
project_list = projects.collect do |project|
{
"duration" => project.duration,
@ -20,7 +20,8 @@ class PersonalProjectsController < ApplicationController
"th_job_title" => t('personal_project.job_title'),
"th_participator" => t("personal_project.participator"),
"th_authors" => t('users.name')
}
},
"total_pages" => projects.total_pages
}
end

View File

@ -10,7 +10,7 @@
</tr>
</thead>
<tbody id="tbody_projects" class="sort-holder">
<%= render :partial => 'project', :collection => @projects %>
<%= render 'project' %>
</tbody>
</table>
@ -19,5 +19,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_project_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@projects), class: "pagination pagination-centered" %>
</div>
</div>

View File

@ -14,6 +14,7 @@ module PersonalProject
frontend_enabled
icon_class_no_sidebar "icons-user"
data_count 1..10
end
end
end