2018-05-31 15:18:06 +02:00
|
|
|
module Manager
|
|
|
|
class DossiersController < Manager::ApplicationController
|
2018-07-23 13:02:25 +02:00
|
|
|
#
|
|
|
|
# Administrate overrides
|
|
|
|
#
|
|
|
|
|
|
|
|
# Override this if you have certain roles that require a subset
|
|
|
|
# this will be used to set the records shown on the `index` action.
|
|
|
|
def scoped_resource
|
|
|
|
if unfiltered_list?
|
2020-03-25 18:08:32 +01:00
|
|
|
# Don't display discarded dossiers in the unfiltered list…
|
2022-03-09 10:27:43 +01:00
|
|
|
Dossier.visible_by_administration
|
2018-07-23 13:02:25 +02:00
|
|
|
else
|
|
|
|
# … but allow them to be searched and displayed.
|
2022-03-09 10:27:43 +01:00
|
|
|
Dossier
|
2018-07-23 13:02:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-27 11:19:32 +01:00
|
|
|
def transfer_edit
|
|
|
|
@dossier = Dossier.find params[:id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def transfer
|
2023-11-28 11:09:10 +01:00
|
|
|
transfer = DossierTransfer.create(email: params[:email], dossiers: [Dossier.find(params[:id])], from_support: true)
|
2023-11-27 11:19:32 +01:00
|
|
|
if transfer.persisted?
|
|
|
|
flash[:success] = "Une invitation de transfert a été envoyée à #{params[:email]}"
|
|
|
|
else
|
|
|
|
flash[:alert] = transfer.errors.full_messages.join("<br>")
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to manager_dossier_path(params[:id])
|
|
|
|
end
|
|
|
|
|
2023-11-28 09:04:36 +01:00
|
|
|
def transfer_destroy
|
|
|
|
dossier = Dossier.find(params[:id])
|
|
|
|
dossier.transfer.destroy_and_nullify
|
|
|
|
redirect_to manager_dossier_path(dossier), notice: t("users.dossiers.transferer.destroy")
|
|
|
|
end
|
|
|
|
|
2018-07-23 13:02:25 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def unfiltered_list?
|
|
|
|
action_name == "index" && !params[:search]
|
|
|
|
end
|
2022-11-15 12:21:20 +01:00
|
|
|
|
|
|
|
def paginate_resources(_resources)
|
|
|
|
super.without_count
|
|
|
|
end
|
2023-09-15 11:34:20 +02:00
|
|
|
|
|
|
|
def find_resource(param)
|
|
|
|
DossierPreloader.load_one(Dossier.find(param))
|
|
|
|
end
|
2018-05-31 15:18:06 +02:00
|
|
|
end
|
|
|
|
end
|