Pagination

This commit is contained in:
manson 2014-07-18 15:02:35 +08:00
parent 698134007a
commit 8e5ab6e13e
4 changed files with 7 additions and 4 deletions

View File

@ -5,7 +5,7 @@ class Admin::ExperiencesController < OrbitMemberController
before_action :get_settings,:only => [:new, :edit, :setting] before_action :get_settings,:only => [:new, :edit, :setting]
def index def index
@experiences = Experience.all @experiences = Experience.order_by(:end_date=>'desc',:start_date=>'desc').page(params[:page]).per(10)
end end
def new def new

View File

@ -1,6 +1,6 @@
class PersonalExperiencesController < ApplicationController class PersonalExperiencesController < ApplicationController
def index def index
experiences = Experience.where(:is_hidden=>false).all experiences = Experience.where(:is_hidden=>false).order_by(:end_date=>'desc',:start_date=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
experience_list = experiences.collect do |experience| experience_list = experiences.collect do |experience|
{ {
"member" => experience.member_profile.name, "member" => experience.member_profile.name,
@ -21,7 +21,8 @@ class PersonalExperiencesController < ApplicationController
"th_department" => t('personal_experience.department'), "th_department" => t('personal_experience.department'),
"th_job_title" => t('personal_experience.job_title'), "th_job_title" => t('personal_experience.job_title'),
"th_detail" => t('detail') "th_detail" => t('detail')
} },
"total_pages" => experiences.total_pages
} }
end end

View File

@ -8,7 +8,7 @@
</tr> </tr>
</thead> </thead>
<tbody id="tbody_experiences" class="sort-holder"> <tbody id="tbody_experiences" class="sort-holder">
<%= render :partial => 'experience', :collection => @experiences %> <%= render 'experience' %>
</tbody> </tbody>
</table> </table>
@ -17,5 +17,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_experience_setting_path, :class => 'btn btn-primary pull-right' %> <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_experience_setting_path, :class => 'btn btn-primary pull-right' %>
</div> </div>
<div class="pagination pagination-centered"> <div class="pagination pagination-centered">
<%= content_tag :div, paginate(@experiences), class: "pagination pagination-centered" %>
</div> </div>
</div> </div>

View File

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