views for kaminari
This commit is contained in:
parent
b2ce16fb69
commit
a3741d18a2
|
|
@ -14,7 +14,7 @@ module Admin
|
|||
# GET /admin/courses/1
|
||||
# GET /admin/courses/1.json
|
||||
def show
|
||||
@weeks = @course.weeks
|
||||
@weeks = @course.weeks.page(params[:page])
|
||||
end
|
||||
|
||||
# GET /admin/courses/new
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module Admin
|
|||
# POST /admin/weeks.json
|
||||
def create
|
||||
@week = Week.new(admin_week_params)
|
||||
@course = Course.find(@week.course_id)
|
||||
@course = @week.course# .find(@week.course_id)
|
||||
params[:course_id] = @course.id
|
||||
respond_to do |format|
|
||||
if @week.save
|
||||
|
|
@ -75,10 +75,11 @@ module Admin
|
|||
def set_object
|
||||
@week = Week.find(params[:id])
|
||||
@course = @week.course
|
||||
params[:course_id] = @course.id
|
||||
end
|
||||
|
||||
def collection
|
||||
@weeks = Week.by_course(params[:course_id])
|
||||
@weeks = Week.by_course(params[:course_id]).page(paramas[:page])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,19 @@ module ViewsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def paginator(object)
|
||||
paginate(object, remote: true, theme: 'twitter-bootstrap-4',
|
||||
pagination_class: 'justify-content-center',
|
||||
nav_class: 'pg-right', params: normalize_pagination_params)
|
||||
end
|
||||
|
||||
def normalize_pagination_params
|
||||
params.to_unsafe_h.inject({}) do |params_hash, p|
|
||||
params_hash[p[0]] = nil unless p[0] == 'controller' || p[0] == 'search'
|
||||
params_hash
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginate @courses, remote: true, theme: 'twitter-bootstrap-4', pagination_class: 'justify-content-center' %>
|
||||
<%= paginator @courses %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
$('#ajax_list').html("<%= escape_javascript(render('/admin/weeks/partials/weeks')) %>");
|
||||
|
|
@ -0,0 +1 @@
|
|||
$('#ajax_list').html("<%= escape_javascript(render('/admin/weeks/partials/weeks')) %>");
|
||||
|
|
@ -22,4 +22,5 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginator @weeks, params: { controller: 'admin/weeks', action: :index } %>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue