Calendar view in admin/jobs#index optional
This commit is contained in:
@@ -6,22 +6,14 @@ class Admin::JobsController < ApplicationController
|
||||
@q = Job.ransack(params[:q])
|
||||
@q.sorts = "id asc" if @q.sorts.empty?
|
||||
# @pagy, @records = pagy(@q.result(distinct: true), limit: 20)
|
||||
@calendar, @pagy, @records = pagy_calendar(@q, year: {}, month: {}, pagy: {})
|
||||
@calendar, @pagy, @records = pagy_calendar(@q.result, year: {}, month: {}, pagy: {}, active: params[:calendar])
|
||||
end
|
||||
|
||||
def pagy_calendar_period(collection)
|
||||
if collection.is_a? Ransack::Search
|
||||
collection.result.minmax.map(&:created_at) if collection.result
|
||||
else
|
||||
collection.minmax.map(&:created_at) if collection
|
||||
end
|
||||
[ collection.minimum(:created_at).in_time_zone, collection.maximum(:created_at).in_time_zone ] if collection
|
||||
end
|
||||
|
||||
def pagy_calendar_filter(collection, from, to)
|
||||
if collection.is_a? Ransack::Search
|
||||
collection.result.where(created_at: from...to)
|
||||
else
|
||||
collection.where(created_at: from...to)
|
||||
end
|
||||
collection.where(created_at: from...to)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user