2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-21 16:32:17 +01:00
|
|
|
class Dossiers::BatchOperationComponent < ApplicationComponent
|
|
|
|
attr_reader :statut, :procedure
|
|
|
|
|
|
|
|
def initialize(statut:, procedure:)
|
|
|
|
@statut = statut
|
|
|
|
@procedure = procedure
|
|
|
|
end
|
|
|
|
|
|
|
|
def render?
|
2024-07-18 14:15:29 +02:00
|
|
|
['a-suivre', 'traites', 'suivis', 'archives', 'supprimes', 'expirant'].include?(@statut)
|
2022-11-21 16:32:17 +01:00
|
|
|
end
|
|
|
|
|
2023-01-06 20:07:53 +01:00
|
|
|
def operations_for_dossier(dossier)
|
|
|
|
case dossier.state
|
|
|
|
when Dossier.states.fetch(:en_construction)
|
2023-11-30 16:11:04 +01:00
|
|
|
[BatchOperation.operations.fetch(:passer_en_instruction), BatchOperation.operations.fetch(:repousser_expiration)]
|
2023-01-06 20:07:53 +01:00
|
|
|
when Dossier.states.fetch(:en_instruction)
|
2023-11-30 16:11:04 +01:00
|
|
|
[
|
|
|
|
BatchOperation.operations.fetch(:accepter), BatchOperation.operations.fetch(:refuser),
|
|
|
|
BatchOperation.operations.fetch(:classer_sans_suite), BatchOperation.operations.fetch(:repasser_en_construction)
|
|
|
|
]
|
2023-01-06 20:07:53 +01:00
|
|
|
when Dossier.states.fetch(:accepte), Dossier.states.fetch(:refuse), Dossier.states.fetch(:sans_suite)
|
2023-11-30 16:11:04 +01:00
|
|
|
[
|
|
|
|
BatchOperation.operations.fetch(:archiver), BatchOperation.operations.fetch(:desarchiver), BatchOperation.operations.fetch(:supprimer),
|
|
|
|
BatchOperation.operations.fetch(:restaurer), BatchOperation.operations.fetch(:repousser_expiration)
|
|
|
|
]
|
2023-01-06 20:07:53 +01:00
|
|
|
else
|
|
|
|
[]
|
2023-01-16 10:57:43 +01:00
|
|
|
end.append(BatchOperation.operations.fetch(:follow), BatchOperation.operations.fetch(:unfollow))
|
2023-01-06 20:07:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2022-11-21 16:32:17 +01:00
|
|
|
def available_operations
|
|
|
|
case @statut
|
2023-01-04 11:51:22 +01:00
|
|
|
when 'a-suivre' then
|
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
2023-11-30 11:50:37 +01:00
|
|
|
{
|
|
|
|
label: t(".operations.passer_en_instruction"),
|
|
|
|
operation: BatchOperation.operations.fetch(:passer_en_instruction)
|
|
|
|
},
|
2023-01-04 11:51:22 +01:00
|
|
|
{
|
|
|
|
label: t(".operations.follow"),
|
|
|
|
operation: BatchOperation.operations.fetch(:follow)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-11-29 22:36:55 +01:00
|
|
|
when 'archives' then
|
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: t(".operations.desarchiver"),
|
|
|
|
operation: BatchOperation.operations.fetch(:desarchiver)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-11-21 16:32:17 +01:00
|
|
|
when 'traites' then
|
2022-12-15 17:35:50 +01:00
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: t(".operations.archiver"),
|
|
|
|
operation: BatchOperation.operations.fetch(:archiver)
|
2023-11-16 10:30:16 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: t(".operations.supprimer"),
|
|
|
|
operation: BatchOperation.operations.fetch(:supprimer)
|
2022-12-15 17:35:50 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-11-30 16:11:04 +01:00
|
|
|
when 'expirant' then
|
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: t(".operations.repousser_expiration"),
|
|
|
|
operation: BatchOperation.operations.fetch(:repousser_expiration)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-07-18 14:15:29 +02:00
|
|
|
when 'supprimes' then
|
2023-11-29 19:40:51 +01:00
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: t(".operations.restaurer"),
|
|
|
|
operation: BatchOperation.operations.fetch(:restaurer)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-12-12 10:02:33 +01:00
|
|
|
when 'suivis' then
|
2022-12-15 17:35:50 +01:00
|
|
|
{
|
|
|
|
options:
|
|
|
|
[
|
|
|
|
|
|
|
|
{
|
|
|
|
label: t(".operations.passer_en_instruction"),
|
|
|
|
operation: BatchOperation.operations.fetch(:passer_en_instruction)
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2023-07-03 16:05:48 +02:00
|
|
|
instruction:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: t(".operations.accepter"),
|
|
|
|
operation_description: t(".operations.accepter_description"),
|
|
|
|
operation: BatchOperation.operations.fetch(:accepter),
|
2023-12-06 16:57:29 +01:00
|
|
|
operation_class_name: 'fr-icon-checkbox-circle-fill fr-text-default--success',
|
|
|
|
placeholder: t(".placeholders.accepter"),
|
|
|
|
instruction_operation: 'accept'
|
2023-07-03 16:05:48 +02:00
|
|
|
},
|
2023-01-11 11:05:19 +01:00
|
|
|
|
2023-07-03 16:05:48 +02:00
|
|
|
{
|
|
|
|
label: t(".operations.classer_sans_suite"),
|
|
|
|
operation_description: t(".operations.classer_sans_suite_description"),
|
|
|
|
operation: BatchOperation.operations.fetch(:classer_sans_suite),
|
2023-12-06 16:57:29 +01:00
|
|
|
operation_class_name: 'fr-icon-intermediate-circle-fill fr-text-mention--grey',
|
|
|
|
placeholder: t(".placeholders.classer_sans_suite"),
|
|
|
|
instruction_operation: 'without-continuation'
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
label: t(".operations.refuser"),
|
|
|
|
operation_description: t(".operations.refuser_description"),
|
|
|
|
operation: BatchOperation.operations.fetch(:refuser),
|
|
|
|
operation_class_name: 'fr-icon-close-circle-fill fr-text-default--warning',
|
|
|
|
placeholder: t(".placeholders.refuser"),
|
|
|
|
instruction_operation: 'refuse'
|
2023-07-03 16:05:48 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2023-01-13 15:09:24 +01:00
|
|
|
{
|
|
|
|
label: t(".operations.unfollow"),
|
|
|
|
operation: BatchOperation.operations.fetch(:unfollow)
|
|
|
|
},
|
|
|
|
|
2023-01-11 11:05:19 +01:00
|
|
|
{
|
|
|
|
label: t(".operations.repasser_en_construction"),
|
|
|
|
operation: BatchOperation.operations.fetch(:repasser_en_construction)
|
2022-12-15 17:35:50 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-11-21 16:32:17 +01:00
|
|
|
else
|
2022-12-15 17:35:50 +01:00
|
|
|
{
|
|
|
|
options: []
|
|
|
|
}
|
2022-11-21 16:32:17 +01:00
|
|
|
end
|
|
|
|
end
|
2022-12-12 10:28:23 +01:00
|
|
|
|
|
|
|
def icons
|
|
|
|
{
|
2023-01-04 11:51:22 +01:00
|
|
|
accepter: 'fr-icon-success-line',
|
2022-12-12 10:28:23 +01:00
|
|
|
archiver: 'fr-icon-folder-2-line',
|
2023-11-29 22:36:55 +01:00
|
|
|
desarchiver: 'fr-icon-upload-2-line',
|
2023-01-04 11:51:22 +01:00
|
|
|
follow: 'fr-icon-star-line',
|
2023-01-11 11:05:19 +01:00
|
|
|
passer_en_instruction: 'fr-icon-edit-line',
|
2023-01-13 15:09:24 +01:00
|
|
|
repasser_en_construction: 'fr-icon-draft-line',
|
2023-11-16 10:30:16 +01:00
|
|
|
supprimer: 'fr-icon-delete-line',
|
2023-11-29 19:40:51 +01:00
|
|
|
restaurer: 'fr-icon-refresh-line',
|
2023-01-13 15:09:24 +01:00
|
|
|
unfollow: 'fr-icon-star-fill'
|
2022-12-12 10:28:23 +01:00
|
|
|
}
|
|
|
|
end
|
2022-11-21 16:32:17 +01:00
|
|
|
end
|