2019-08-06 11:02:54 +02:00
|
|
|
|
module Instructeurs
|
|
|
|
|
class ProceduresController < InstructeurController
|
2017-07-03 14:05:55 +02:00
|
|
|
|
before_action :ensure_ownership!, except: [:index]
|
2017-09-07 16:04:53 +02:00
|
|
|
|
before_action :redirect_to_avis_if_needed, only: [:index]
|
2017-07-03 14:05:55 +02:00
|
|
|
|
|
2017-10-05 13:28:24 +02:00
|
|
|
|
ITEMS_PER_PAGE = 25
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2017-07-03 14:05:55 +02:00
|
|
|
|
def index
|
2019-09-16 14:04:18 +02:00
|
|
|
|
@procedures = current_instructeur
|
2019-09-17 15:07:58 +02:00
|
|
|
|
.procedures
|
2020-04-22 15:16:21 +02:00
|
|
|
|
.kept
|
2019-09-17 11:11:08 +02:00
|
|
|
|
.with_attached_logo
|
|
|
|
|
.includes(:defaut_groupe_instructeur)
|
2019-12-18 13:28:29 +01:00
|
|
|
|
.order(closed_at: :desc, unpublished_at: :desc, published_at: :desc, created_at: :desc)
|
2017-07-03 14:05:55 +02:00
|
|
|
|
|
2019-09-12 17:26:59 +02:00
|
|
|
|
dossiers = current_instructeur.dossiers.joins(:groupe_instructeur)
|
|
|
|
|
@dossiers_count_per_procedure = dossiers.all_state.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
|
|
|
|
@dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
|
|
|
|
@dossiers_archived_count_per_procedure = dossiers.archived.group('groupe_instructeurs.procedure_id').count
|
|
|
|
|
@dossiers_termines_count_per_procedure = dossiers.termine.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
2019-08-26 15:35:40 +02:00
|
|
|
|
|
2019-09-12 17:26:59 +02:00
|
|
|
|
groupe_ids = current_instructeur.groupe_instructeurs.pluck(:id)
|
2017-07-03 14:05:55 +02:00
|
|
|
|
|
2019-09-12 17:26:59 +02:00
|
|
|
|
@followed_dossiers_count_per_procedure = current_instructeur
|
2017-07-17 11:22:12 +02:00
|
|
|
|
.followed_dossiers
|
2019-09-12 17:26:59 +02:00
|
|
|
|
.joins(:groupe_instructeur)
|
2017-07-17 11:22:12 +02:00
|
|
|
|
.en_cours
|
2019-09-12 17:26:59 +02:00
|
|
|
|
.where(groupe_instructeur_id: groupe_ids)
|
|
|
|
|
.group('groupe_instructeurs.procedure_id')
|
2017-07-17 11:22:12 +02:00
|
|
|
|
.reorder(nil)
|
|
|
|
|
.count
|
2020-06-25 15:19:54 +02:00
|
|
|
|
|
2020-09-10 12:10:38 +02:00
|
|
|
|
@all_dossiers_counts = {
|
|
|
|
|
'à suivre' => @dossiers_a_suivre_count_per_procedure.sum { |_, v| v },
|
|
|
|
|
'suivis' => @followed_dossiers_count_per_procedure.sum { |_, v| v },
|
|
|
|
|
'traités' => @dossiers_termines_count_per_procedure.sum { |_, v| v },
|
|
|
|
|
'dossiers' => @dossiers_count_per_procedure.sum { |_, v| v },
|
|
|
|
|
'archivés' => @dossiers_archived_count_per_procedure.sum { |_, v| v }
|
|
|
|
|
}
|
2020-09-10 21:03:50 +02:00
|
|
|
|
|
|
|
|
|
@procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours)
|
|
|
|
|
@procedure_ids_termines_with_notifications = current_instructeur.procedure_ids_with_notifications(:termine)
|
2017-07-03 14:05:55 +02:00
|
|
|
|
end
|
2017-06-29 15:30:42 +02:00
|
|
|
|
|
2017-07-11 16:09:03 +02:00
|
|
|
|
def show
|
|
|
|
|
@procedure = procedure
|
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
@current_filters = current_filters
|
|
|
|
|
@available_fields_to_filters = available_fields_to_filters
|
2018-10-03 14:46:12 +02:00
|
|
|
|
# Technically, procedure_presentation already sets the attribute.
|
|
|
|
|
# Setting it here to make clear that it is used by the view
|
|
|
|
|
@procedure_presentation = procedure_presentation
|
2017-10-02 17:03:38 +02:00
|
|
|
|
@displayed_fields_values = displayed_fields_values
|
|
|
|
|
|
2019-09-18 13:44:00 +02:00
|
|
|
|
@a_suivre_dossiers = current_instructeur
|
2017-07-11 16:09:03 +02:00
|
|
|
|
.dossiers
|
2019-09-18 13:44:00 +02:00
|
|
|
|
.for_procedure(procedure)
|
2017-07-11 16:09:03 +02:00
|
|
|
|
.without_followers
|
|
|
|
|
.en_cours
|
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
@followed_dossiers = current_instructeur
|
2017-07-11 16:09:03 +02:00
|
|
|
|
.followed_dossiers
|
2019-09-18 13:44:00 +02:00
|
|
|
|
.where(groupe_instructeur: current_instructeur.groupe_instructeurs)
|
|
|
|
|
.for_procedure(procedure)
|
2017-07-11 16:09:03 +02:00
|
|
|
|
.en_cours
|
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
@followed_dossiers_id = current_instructeur
|
2017-07-31 18:35:34 +02:00
|
|
|
|
.followed_dossiers
|
2019-09-18 13:44:00 +02:00
|
|
|
|
.where(groupe_instructeur: current_instructeur.groupe_instructeurs)
|
|
|
|
|
.for_procedure(procedure)
|
2017-07-31 18:35:34 +02:00
|
|
|
|
.pluck(:id)
|
|
|
|
|
|
2019-09-18 13:44:00 +02:00
|
|
|
|
@termines_dossiers = current_instructeur
|
|
|
|
|
.dossiers
|
|
|
|
|
.for_procedure(procedure)
|
|
|
|
|
.termine
|
2017-07-11 16:09:03 +02:00
|
|
|
|
|
2019-09-18 13:44:00 +02:00
|
|
|
|
@all_state_dossiers = current_instructeur
|
|
|
|
|
.dossiers
|
|
|
|
|
.for_procedure(procedure)
|
|
|
|
|
.all_state
|
2017-07-11 16:09:03 +02:00
|
|
|
|
|
2019-09-18 13:44:00 +02:00
|
|
|
|
@archived_dossiers = current_instructeur
|
|
|
|
|
.dossiers
|
|
|
|
|
.for_procedure(procedure)
|
|
|
|
|
.archived
|
2017-07-11 15:40:09 +02:00
|
|
|
|
|
2017-09-28 19:07:18 +02:00
|
|
|
|
@dossiers = case statut
|
2017-07-11 15:40:09 +02:00
|
|
|
|
when 'a-suivre'
|
|
|
|
|
@a_suivre_dossiers
|
|
|
|
|
when 'suivis'
|
|
|
|
|
@followed_dossiers
|
|
|
|
|
when 'traites'
|
|
|
|
|
@termines_dossiers
|
|
|
|
|
when 'tous'
|
|
|
|
|
@all_state_dossiers
|
|
|
|
|
when 'archives'
|
|
|
|
|
@archived_dossiers
|
|
|
|
|
end
|
2017-09-21 16:47:43 +02:00
|
|
|
|
|
2020-10-14 15:47:52 +02:00
|
|
|
|
@has_en_cours_notifications = current_instructeur.notifications_for_procedure(@procedure, :en_cours).exists?
|
|
|
|
|
@has_termine_notifications = current_instructeur.notifications_for_procedure(@procedure, :termine).exists?
|
|
|
|
|
|
2020-09-14 13:52:28 +02:00
|
|
|
|
@not_archived_notifications_dossier_ids = current_instructeur.notifications_for_procedure(@procedure, :not_archived).pluck(:id)
|
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
sorted_ids = procedure_presentation.sorted_ids(@dossiers, current_instructeur)
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
if @current_filters.count > 0
|
2018-10-03 19:17:22 +02:00
|
|
|
|
filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut)
|
2019-09-12 11:26:22 +02:00
|
|
|
|
filtered_sorted_ids = sorted_ids.filter { |id| filtered_ids.include?(id) }
|
2017-09-28 11:04:18 +02:00
|
|
|
|
else
|
|
|
|
|
filtered_sorted_ids = sorted_ids
|
|
|
|
|
end
|
|
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
|
page = params[:page].presence || 1
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
filtered_sorted_paginated_ids = Kaminari
|
|
|
|
|
.paginate_array(filtered_sorted_ids)
|
2017-09-27 15:16:07 +02:00
|
|
|
|
.page(page)
|
|
|
|
|
.per(ITEMS_PER_PAGE)
|
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
@dossiers = @dossiers.where(id: filtered_sorted_paginated_ids)
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2019-02-19 16:57:45 +01:00
|
|
|
|
@dossiers = procedure_presentation.eager_load_displayed_fields(@dossiers)
|
2017-10-02 17:03:38 +02:00
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
@dossiers = @dossiers.sort_by { |d| filtered_sorted_paginated_ids.index(d.id) }
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
kaminarize(page, filtered_sorted_ids.count)
|
2019-12-11 17:42:44 +01:00
|
|
|
|
|
|
|
|
|
assign_exports
|
2017-07-11 16:09:03 +02:00
|
|
|
|
end
|
|
|
|
|
|
2020-03-20 17:59:16 +01:00
|
|
|
|
def deleted_dossiers
|
|
|
|
|
@procedure = procedure
|
2020-03-24 13:53:15 +01:00
|
|
|
|
@deleted_dossiers = @procedure
|
2020-03-31 14:33:30 +02:00
|
|
|
|
.deleted_dossiers
|
2020-03-24 13:53:15 +01:00
|
|
|
|
.order(:dossier_id)
|
|
|
|
|
.page params[:page]
|
2020-03-20 17:59:16 +01:00
|
|
|
|
end
|
|
|
|
|
|
2017-10-02 17:03:38 +02:00
|
|
|
|
def update_displayed_fields
|
|
|
|
|
values = params[:values]
|
|
|
|
|
|
|
|
|
|
if values.nil?
|
|
|
|
|
values = []
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
fields = values.map do |value|
|
2019-02-13 18:24:41 +01:00
|
|
|
|
find_field(*value.split('/'))
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-02 16:27:03 +01:00
|
|
|
|
procedure_presentation.update(displayed_fields: fields)
|
2017-10-02 17:03:38 +02:00
|
|
|
|
|
2017-09-27 15:16:07 +02:00
|
|
|
|
current_sort = procedure_presentation.sort
|
2019-02-13 17:50:33 +01:00
|
|
|
|
if !values.include?(field_id(current_sort))
|
2018-03-02 16:27:03 +01:00
|
|
|
|
procedure_presentation.update(sort: Procedure.default_sort)
|
2017-09-27 15:16:07 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
2017-09-27 15:16:07 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update_sort
|
|
|
|
|
current_sort = procedure_presentation.sort
|
|
|
|
|
table = params[:table]
|
|
|
|
|
column = params[:column]
|
|
|
|
|
|
|
|
|
|
if table == current_sort['table'] && column == current_sort['column']
|
|
|
|
|
order = current_sort['order'] == 'asc' ? 'desc' : 'asc'
|
|
|
|
|
else
|
|
|
|
|
order = 'asc'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
sort = {
|
|
|
|
|
'table' => table,
|
|
|
|
|
'column' => column,
|
|
|
|
|
'order' => order
|
2018-09-20 17:02:28 +02:00
|
|
|
|
}
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2018-03-02 16:27:03 +01:00
|
|
|
|
procedure_presentation.update(sort: sort)
|
2017-09-27 15:16:07 +02:00
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
def add_filter
|
2017-12-06 17:26:23 +01:00
|
|
|
|
if params[:value].present?
|
2020-06-08 14:33:58 +02:00
|
|
|
|
procedure_presentation.add_filter(statut, params[:field], params[:value])
|
2017-12-06 17:26:23 +01:00
|
|
|
|
end
|
2017-09-28 11:04:18 +02:00
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
2017-09-28 11:04:18 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def remove_filter
|
|
|
|
|
filters = procedure_presentation.filters
|
|
|
|
|
|
2019-02-19 18:20:12 +01:00
|
|
|
|
to_remove = params.values_at(:table, :column, :value)
|
|
|
|
|
filters[statut].reject! { |filter| filter.values_at('table', 'column', 'value') == to_remove }
|
2017-09-28 11:04:18 +02:00
|
|
|
|
|
2018-09-20 16:18:21 +02:00
|
|
|
|
procedure_presentation.update(filters: filters)
|
2017-09-28 11:04:18 +02:00
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
2017-09-28 11:04:18 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-10-03 15:35:31 +02:00
|
|
|
|
def download_export
|
2020-01-29 12:16:38 +01:00
|
|
|
|
export_format = params[:export_format]
|
2019-12-11 17:43:24 +01:00
|
|
|
|
groupe_instructeurs = current_instructeur
|
|
|
|
|
.groupe_instructeurs
|
|
|
|
|
.where(procedure: procedure)
|
2019-09-30 11:57:21 +02:00
|
|
|
|
|
2020-01-29 12:16:38 +01:00
|
|
|
|
export = Export.find_or_create_export(export_format, groupe_instructeurs)
|
2019-12-11 17:43:24 +01:00
|
|
|
|
|
|
|
|
|
if export.ready?
|
2020-01-29 12:16:38 +01:00
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js do
|
|
|
|
|
@procedure = procedure
|
|
|
|
|
assign_exports
|
2020-04-02 15:54:31 +02:00
|
|
|
|
flash.notice = "L’export au format \"#{export_format}\" est prêt. Vous pouvez le <a href=\"#{export.file.service_url}\">télécharger</a>"
|
2020-01-29 12:16:38 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
format.html do
|
|
|
|
|
redirect_to export.file.service_url
|
|
|
|
|
end
|
|
|
|
|
end
|
2019-12-11 17:43:24 +01:00
|
|
|
|
else
|
2019-10-16 11:40:19 +02:00
|
|
|
|
respond_to do |format|
|
2019-12-11 17:43:24 +01:00
|
|
|
|
notice_message = "Nous générons cet export. Veuillez revenir dans quelques minutes pour le télécharger."
|
2020-01-29 12:16:38 +01:00
|
|
|
|
|
2019-10-16 11:40:19 +02:00
|
|
|
|
format.js do
|
|
|
|
|
@procedure = procedure
|
2019-12-11 17:43:24 +01:00
|
|
|
|
assign_exports
|
2020-01-29 12:16:38 +01:00
|
|
|
|
if !params[:no_progress_notification]
|
|
|
|
|
flash.notice = notice_message
|
|
|
|
|
end
|
2019-12-11 17:43:24 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
format.html do
|
|
|
|
|
redirect_to instructeur_procedure_url(procedure), notice: notice_message
|
2019-10-16 11:40:19 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2019-10-02 15:51:37 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-03-13 17:37:07 +01:00
|
|
|
|
def email_notifications
|
|
|
|
|
@procedure = procedure
|
|
|
|
|
@assign_to = assign_to
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update_email_notifications
|
2020-02-11 15:51:15 +01:00
|
|
|
|
assign_to.update!(assign_to_params)
|
2019-03-13 17:37:07 +01:00
|
|
|
|
flash.notice = 'Vos notifications sont enregistrées.'
|
2019-08-06 11:02:54 +02:00
|
|
|
|
redirect_to instructeur_procedure_path(procedure)
|
2019-03-13 17:37:07 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-07-30 14:37:00 +02:00
|
|
|
|
def stats
|
|
|
|
|
@procedure = procedure
|
2019-09-17 15:52:38 +02:00
|
|
|
|
@usual_traitement_time = @procedure.stats_usual_traitement_time
|
|
|
|
|
@dossiers_funnel = @procedure.stats_dossiers_funnel
|
|
|
|
|
@termines_states = @procedure.stats_termines_states
|
2019-07-30 14:37:00 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-06-29 15:30:42 +02:00
|
|
|
|
private
|
|
|
|
|
|
2020-02-11 15:51:15 +01:00
|
|
|
|
def assign_to_params
|
2020-04-09 11:43:23 +02:00
|
|
|
|
params.require(:assign_to)
|
|
|
|
|
.permit(:instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :daily_email_notifications_enabled, :weekly_email_notifications_enabled)
|
2020-02-11 15:51:15 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-12-11 17:42:44 +01:00
|
|
|
|
def assign_exports
|
|
|
|
|
groupe_instructeurs_for_procedure = current_instructeur.groupe_instructeurs.where(procedure: procedure)
|
|
|
|
|
@xlsx_export = Export.find_for_format_and_groupe_instructeurs(:xlsx, groupe_instructeurs_for_procedure)
|
|
|
|
|
@csv_export = Export.find_for_format_and_groupe_instructeurs(:csv, groupe_instructeurs_for_procedure)
|
|
|
|
|
@ods_export = Export.find_for_format_and_groupe_instructeurs(:ods, groupe_instructeurs_for_procedure)
|
|
|
|
|
end
|
|
|
|
|
|
2019-02-13 18:24:41 +01:00
|
|
|
|
def find_field(table, column)
|
|
|
|
|
procedure_presentation.fields.find { |c| c['table'] == table && c['column'] == column }
|
|
|
|
|
end
|
|
|
|
|
|
2019-02-13 17:50:33 +01:00
|
|
|
|
def field_id(field)
|
2019-02-13 17:53:41 +01:00
|
|
|
|
field.values_at('table', 'column').join('/')
|
2019-02-13 17:50:33 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-03-13 17:37:07 +01:00
|
|
|
|
def assign_to
|
2019-08-26 16:17:25 +02:00
|
|
|
|
current_instructeur.assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure: procedure })
|
2019-03-13 17:37:07 +01:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-28 19:07:18 +02:00
|
|
|
|
def statut
|
2018-03-06 13:44:29 +01:00
|
|
|
|
@statut ||= (params[:statut].presence || 'a-suivre')
|
2017-09-28 19:07:18 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-06-29 15:30:42 +02:00
|
|
|
|
def procedure
|
|
|
|
|
Procedure.find(params[:procedure_id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ensure_ownership!
|
2019-10-09 18:28:03 +02:00
|
|
|
|
if !current_instructeur.procedures.include?(procedure)
|
2020-01-29 12:16:38 +01:00
|
|
|
|
flash[:alert] = "Vous n’avez pas accès à cette démarche"
|
2017-06-29 15:30:42 +02:00
|
|
|
|
redirect_to root_path
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-09-07 16:04:53 +02:00
|
|
|
|
|
|
|
|
|
def redirect_to_avis_if_needed
|
2019-09-17 15:07:58 +02:00
|
|
|
|
if current_instructeur.procedures.count == 0 && current_instructeur.avis.count > 0
|
2020-04-16 17:52:58 +02:00
|
|
|
|
redirect_to instructeur_all_avis_path
|
2017-09-07 16:04:53 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2017-10-02 17:03:38 +02:00
|
|
|
|
|
|
|
|
|
def procedure_presentation
|
2018-10-23 10:55:59 +02:00
|
|
|
|
@procedure_presentation ||= get_procedure_presentation
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_procedure_presentation
|
2019-08-06 11:02:54 +02:00
|
|
|
|
procedure_presentation, errors = current_instructeur.procedure_presentation_and_errors_for_procedure_id(params[:procedure_id])
|
2018-10-23 11:39:54 +02:00
|
|
|
|
if errors.present?
|
|
|
|
|
flash[:alert] = "Votre affichage a dû être réinitialisé en raison du problème suivant : " + errors.full_messages.join(', ')
|
|
|
|
|
end
|
|
|
|
|
procedure_presentation
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def displayed_fields_values
|
2019-02-13 17:50:33 +01:00
|
|
|
|
procedure_presentation.displayed_fields.map { |field| field_id(field) }
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-28 11:04:18 +02:00
|
|
|
|
def current_filters
|
|
|
|
|
@current_filters ||= procedure_presentation.filters[statut]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def available_fields_to_filters
|
2019-02-13 14:41:31 +01:00
|
|
|
|
procedure_presentation.fields_for_select
|
2017-09-28 11:04:18 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-27 15:16:07 +02:00
|
|
|
|
def kaminarize(current_page, total)
|
|
|
|
|
@dossiers.instance_eval <<-EVAL
|
|
|
|
|
def current_page
|
|
|
|
|
#{current_page}
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
2017-09-27 15:16:07 +02:00
|
|
|
|
def total_pages
|
|
|
|
|
(#{total} / #{ITEMS_PER_PAGE}.to_f).ceil
|
|
|
|
|
end
|
2017-10-05 13:28:24 +02:00
|
|
|
|
def limit_value
|
2017-09-27 15:16:07 +02:00
|
|
|
|
#{ITEMS_PER_PAGE}
|
|
|
|
|
end
|
|
|
|
|
def first_page?
|
|
|
|
|
current_page == 1
|
|
|
|
|
end
|
|
|
|
|
def last_page?
|
|
|
|
|
current_page == total_pages
|
|
|
|
|
end
|
2018-07-17 17:25:09 +02:00
|
|
|
|
EVAL
|
2017-10-02 17:03:38 +02:00
|
|
|
|
end
|
2017-06-29 15:30:42 +02:00
|
|
|
|
end
|
|
|
|
|
end
|