remove old logic
This commit is contained in:
parent
6c188a867d
commit
9004dd9758
8 changed files with 6 additions and 264 deletions
|
@ -1,82 +0,0 @@
|
|||
class Procedure::RoutingRulesComponent < ApplicationComponent
|
||||
include Logic
|
||||
|
||||
def initialize(revision:, groupe_instructeurs:)
|
||||
@revision = revision
|
||||
@groupe_instructeurs = groupe_instructeurs
|
||||
@procedure_id = revision.procedure_id
|
||||
end
|
||||
|
||||
def rows
|
||||
@groupe_instructeurs.active.map do |gi|
|
||||
if gi.routing_rule.present?
|
||||
[gi.routing_rule.left, gi.routing_rule.right, gi]
|
||||
else
|
||||
[empty, empty, gi]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def can_route?
|
||||
available_targets_for_select.present?
|
||||
end
|
||||
|
||||
def targeted_champ_tag(targeted_champ, row_index)
|
||||
select_tag(
|
||||
'targeted_champ',
|
||||
options_for_select(targeted_champs_for_select, selected: targeted_champ.to_json),
|
||||
id: input_id_for('targeted_champ', row_index)
|
||||
)
|
||||
end
|
||||
|
||||
def value_tag(targeted_champ, value, row_index)
|
||||
select_tag(
|
||||
'value',
|
||||
options_for_select(
|
||||
values_for_select(targeted_champ, row_index),
|
||||
selected: value.to_json
|
||||
),
|
||||
id: input_id_for('value', row_index)
|
||||
)
|
||||
end
|
||||
|
||||
def hidden_groupe_instructeur_tag(groupe_instructeur_id)
|
||||
hidden_field_tag(
|
||||
'groupe_instructeur_id',
|
||||
groupe_instructeur_id
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def targeted_champs_for_select
|
||||
empty_target_for_select + available_targets_for_select
|
||||
end
|
||||
|
||||
def empty_target_for_select
|
||||
[[t('.select'), empty.to_json]]
|
||||
end
|
||||
|
||||
def available_targets_for_select
|
||||
@revision.types_de_champ_public
|
||||
.filter { |tdc| [:drop_down_list].include?(tdc.type_champ.to_sym) }
|
||||
.map { |tdc| [tdc.libelle, champ_value(tdc.stable_id).to_json] }
|
||||
end
|
||||
|
||||
def available_values_for_select(targeted_champ)
|
||||
return [] if targeted_champ.is_a?(Logic::Empty)
|
||||
targeted_champ
|
||||
.options(@revision.types_de_champ_public)
|
||||
.map { |tdc| [tdc.first, constant(tdc.first).to_json] }
|
||||
end
|
||||
|
||||
def values_for_select(targeted_champ, row_index)
|
||||
(empty_target_for_select + available_values_for_select(targeted_champ))
|
||||
# add id to help morph render selected option
|
||||
.map { |(libelle, json)| [libelle, json, { id: "#{row_index}-option-#{libelle}" }] }
|
||||
end
|
||||
|
||||
def input_id_for(name, row_index)
|
||||
"#{name}-#{row_index}"
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
---
|
||||
fr:
|
||||
select: Sélectionner
|
||||
apply_routing_rules: Règles de routage
|
||||
routing_rules_notice_html: |
|
||||
<p>Ajoutez des règles de routage à partir de champs « choix simple » créés dans le <a href="%{path}">formulaire</a>.</p>
|
||||
<p>Les dossiers seront routées vers le premier groupe affiché dont la règle correspond.</p>
|
||||
routing_rules_warning_html: |
|
||||
<p>Pour appliquer des règles de routage, votre formulaire doit comporter
|
||||
au moins un champ « choix simple ».</p>
|
||||
<p>Ajoutez ce champ dans la page <a href="%{path}">« Configuration des champs »</a>.</p>
|
|
@ -1,40 +0,0 @@
|
|||
.card#routing-rules
|
||||
%h2.card-title= t('.apply_routing_rules')
|
||||
- if can_route?
|
||||
.notice
|
||||
= t('.routing_rules_notice_html', path: champs_admin_procedure_path(@procedure_id))
|
||||
.mt-2.width-100
|
||||
%table.routing-rules-table.mt-2.width-100
|
||||
%thead
|
||||
%tr
|
||||
%th.far-left Router vers
|
||||
%th.if
|
||||
%th.target Champ cible du routage
|
||||
%th.operator
|
||||
%th.value Valeur
|
||||
.mt-2.width-100
|
||||
- rows.each.with_index do |(targeted_champ, value, groupe_instructeur), row_index|
|
||||
= form_tag admin_procedure_routing_rules_path(@procedure_id),
|
||||
method: :post,
|
||||
class: "form width-100 gi-#{groupe_instructeur.id}",
|
||||
data: { controller: 'autosave' } do
|
||||
= hidden_groupe_instructeur_tag(groupe_instructeur.id)
|
||||
%table.routing-rules-table.condition-table.mt-2.width-100
|
||||
%tbody
|
||||
%tr
|
||||
%td.far-left= groupe_instructeur.label
|
||||
%td.if si
|
||||
%td.target= targeted_champ_tag(targeted_champ, row_index)
|
||||
%td.operator est égal à
|
||||
%td.value= value_tag(targeted_champ, value, row_index)
|
||||
|
||||
= form_tag admin_procedure_update_defaut_groupe_instructeur_path(@procedure_id),
|
||||
class: 'form flex align-baseline defaut-groupe',
|
||||
data: { controller: 'autosave' } do
|
||||
= label_tag :defaut_groupe_instructeur_id, 'Et si aucune règle ne correspond, router vers :'
|
||||
= select_tag :defaut_groupe_instructeur_id,
|
||||
options_for_select(@groupe_instructeurs.pluck(:label, :id), selected: @revision.procedure.defaut_groupe_instructeur.id),
|
||||
class: 'width-100'
|
||||
|
||||
- else
|
||||
.notice= t('.routing_rules_warning_html', path: champs_admin_procedure_path(@procedure_id))
|
|
@ -1,67 +0,0 @@
|
|||
- if groupes_instructeurs.many? && !procedure.feature_enabled?(:routing_rules)
|
||||
.card
|
||||
= form_for procedure,
|
||||
url: { action: :update_routing_criteria_name },
|
||||
html: { class: 'form' } do |f|
|
||||
|
||||
= f.label :routing_criteria_name do
|
||||
= t('.routing.title')
|
||||
%p.notice
|
||||
= f.text_field :routing_criteria_name, required: true
|
||||
= f.submit t('.button.rename'), class: 'button primary send'
|
||||
|
||||
.card
|
||||
%h2.card-title= t('.group_management.title')
|
||||
|
||||
= form_for :groupe_instructeur, html: { class: 'form' } do |f|
|
||||
= f.label :label do
|
||||
= t('.add_a_group.title')
|
||||
- if groupes_instructeurs.many?
|
||||
%p.notice
|
||||
= t('.add_a_group.notice', routing_criteria_name: procedure.routing_criteria_name)
|
||||
= f.text_field :label, required: true
|
||||
= f.submit t('.button.add_group'), class: "button primary send"
|
||||
|
||||
- csv_max_size = Administrateurs::GroupeInstructeursController::CSV_MAX_SIZE
|
||||
- if procedure.publiee_or_close?
|
||||
= form_tag import_admin_procedure_groupe_instructeurs_path(procedure), method: :post, multipart: true, class: "mt-4 form" do
|
||||
= label_tag t('.csv_import.title')
|
||||
%p.notice
|
||||
= t('.csv_import.notice_1_html',
|
||||
instructeurs_link: link_to(t('.csv_import.link_text'), t('.csv_import.instructeurs_file_path')),
|
||||
groupes_link: link_to(t('.csv_import.link_text'), t('.csv_import.groupes_file_path')))
|
||||
%p.notice
|
||||
= t('.csv_import.notice_2', csv_max_size: number_to_human_size(csv_max_size))
|
||||
= file_field_tag :csv_file, required: true, accept: 'text/csv', size: "1"
|
||||
= submit_tag t('.csv_import.import_file'), class: 'button primary send', data: { disable_with: "Envoi...", confirm: t('.csv_import.import_file_alert') }
|
||||
- else
|
||||
%p.mt-4.form.font-weight-bold.mb-2.text-lg
|
||||
= t('.csv_import.title')
|
||||
%p.notice
|
||||
= t('.csv_import.import_file_procedure_not_published')
|
||||
- if procedure.groupe_instructeurs.many?
|
||||
%table.table.mt-2
|
||||
%thead
|
||||
%tr
|
||||
// i18n-tasks-use t('.existing_groupe')
|
||||
%th{ colspan: 2 }= t(".existing_groupe", count: groupes_instructeurs.total_count)
|
||||
%th.actions
|
||||
= link_to "Exporter au format CSV", export_groupe_instructeurs_admin_procedure_groupe_instructeurs_path(procedure, format: :csv)
|
||||
%tbody
|
||||
- groupes_instructeurs.each do |group|
|
||||
%tr
|
||||
%td= group.label
|
||||
%td.setup= link_to t('.set_up'), admin_procedure_groupe_instructeur_path(procedure, group)
|
||||
- if group.can_delete?
|
||||
%td.actions
|
||||
= link_to admin_procedure_groupe_instructeur_path(procedure, group), { method: :delete, class: 'button', data: { confirm: t('.group_management.delete_confirmation', group_name: group.label) }} do
|
||||
%span.icon.delete
|
||||
= t('.group_management.delete')
|
||||
- else
|
||||
%td.actions
|
||||
= link_to reaffecter_dossiers_admin_procedure_groupe_instructeur_path(procedure, group), class: 'button', title: t('.group_management.move_files_confirmation') do
|
||||
%span.icon.follow
|
||||
= t('.group_management.move_files', count: group.dossiers.visible_by_administration.size)
|
||||
|
||||
|
||||
= paginate groupes_instructeurs, views_prefix: 'shared'
|
|
@ -1,14 +0,0 @@
|
|||
.card
|
||||
%h2.card-title L’autogestion des instructeurs
|
||||
%p.notice= t('.self_managment_notice_html')
|
||||
|
||||
= form_for procedure,
|
||||
method: :patch,
|
||||
url: update_instructeurs_self_management_enabled_admin_procedure_groupe_instructeurs_path(procedure),
|
||||
data: { controller: 'autosubmit', turbo: 'true' },
|
||||
html: { class: 'form procedure-form__column--form no-background' } do |f|
|
||||
%label.toggle-switch
|
||||
= f.check_box :instructeurs_self_management_enabled, class: 'toggle-switch-checkbox'
|
||||
%span.toggle-switch-control.round
|
||||
%span.toggle-switch-label.on
|
||||
%span.toggle-switch-label.off
|
|
@ -1,4 +0,0 @@
|
|||
.card
|
||||
%h2.card-title= t('.title')
|
||||
|
||||
%p.notice= t('.notice_html')
|
|
@ -8,7 +8,6 @@ en:
|
|||
groupe_instructeurs:
|
||||
index:
|
||||
procedures: Procedures
|
||||
instructors_group: Group of instructors
|
||||
add_instructeur:
|
||||
wrong_address:
|
||||
one: "%{emails} is not a valid email address"
|
||||
|
@ -40,45 +39,3 @@ en:
|
|||
existing_groupe:
|
||||
one: "%{count} groupe existe"
|
||||
other: "%{count} groupes existent"
|
||||
groupe:
|
||||
one: "%{count} groupe"
|
||||
other: "%{count} groupes"
|
||||
found:
|
||||
one: "trouvé"
|
||||
other: "trouvés"
|
||||
|
||||
edit:
|
||||
routing:
|
||||
title: Label of the groups list
|
||||
group_management:
|
||||
title: Group management
|
||||
delete: delete the group
|
||||
delete_confirmation: Are you sure you want to delete the group "%{group_name}"
|
||||
move_files:
|
||||
zero: move draft files
|
||||
one: move one file
|
||||
other: move the %{count} files
|
||||
move_files_confirmation: Reassign folders to another group so you can delete it
|
||||
add_a_group:
|
||||
title: Add a group
|
||||
notice: This group will be a choice from the list "%{routing_criteria_name}"
|
||||
set_up: set up
|
||||
button:
|
||||
add_group: Add group
|
||||
rename: Rename
|
||||
existing_groupe:
|
||||
one: "%{count} group exist"
|
||||
other: "%{count} groups exist"
|
||||
routing:
|
||||
title: Routing
|
||||
notice_html: |
|
||||
Routing is a feature for procedures requiring the sharing of instructions between different groups according to a specific criterion (territory, theme or other).
|
||||
<br><br>
|
||||
This feature makes it possible to route the files to each group, and to no longer need to filter its files among a large quantity of requests. It is therefore particularly suitable for national approaches instructed locally.
|
||||
<br><br>
|
||||
Instructors only see the files that concern them, and therefore do not have access to data outside their scope.
|
||||
<br><br>
|
||||
Routing is activated once there are at least two active instructors groups
|
||||
instructeurs_self_management:
|
||||
self_managment_notice_html: |
|
||||
Instructor Self-Management allows instructors to self-manage the list of Gait Instructors.
|
||||
|
|
|
@ -52,6 +52,12 @@ fr:
|
|||
found:
|
||||
one: "trouvé"
|
||||
other: "trouvés"
|
||||
ajout:
|
||||
procedures: Démarches
|
||||
options:
|
||||
procedures: Démarches
|
||||
simple_routing:
|
||||
procedures: Démarches
|
||||
edit:
|
||||
routing:
|
||||
title: Libellé de la liste de groupes
|
||||
|
@ -86,6 +92,3 @@ fr:
|
|||
button:
|
||||
self_managment_toggle: Activer l’autogestion des instructeurs
|
||||
add_group: Ajouter le groupe
|
||||
instructeurs_self_management:
|
||||
self_managment_notice_html: |
|
||||
L’autogestion des instructeurs permet aux instructeurs de gérer eux-mêmes la liste des instructeurs de la démarche.
|
||||
|
|
Loading…
Reference in a new issue