-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(champ.referentiel): 1st step of setup wizard [some options are p…
…resent but disable. will be enabled once implemented]
- Loading branch information
Showing
13 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/components/type_de_champ_referentiel/setup_datasource_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class TypeDeChampReferentiel::SetupDatasourceComponent < ApplicationComponent | ||
attr_reader :type_de_champ, :procedure | ||
def initialize(type_de_champ:, procedure:) | ||
@type_de_champ = type_de_champ | ||
@procedure = procedure | ||
end | ||
|
||
def id | ||
dom_id(type_de_champ, :setup_datasource) | ||
end | ||
|
||
def form_options | ||
{ id:, method: :patch, data: { turbo: 'true' }, html: { novalidate: 'novalidate' } } | ||
end | ||
|
||
def adatper?(value) | ||
type_de_champ.referentiel_adapter == value | ||
end | ||
|
||
private | ||
|
||
def force_autosubmit? = adatper?(nil) | ||
end |
32 changes: 32 additions & 0 deletions
32
...type_de_champ_referentiel/setup_datasource_component/setup_datasource_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
= form_with model: @type_de_champ, url: update_datasource_admin_procedure_type_de_champ_path(@procedure, @type_de_champ.stable_id), **form_options do |form| | ||
%div | ||
= render Dsfr::RadioButtonListComponent.new(form:, target: :referentiel_adapter, | ||
buttons: [ { label: 'À partir d’une URL', value: 'url', hint: 'Connectez un champ à une API', data: {controller: 'autosubmit'} } , | ||
{ label: 'À partir d’un fichier CSV', value: 'csv', hint: 'Connectez un champ à un CSV', disabled: true }]) do || | ||
Comment intéroger votre référentiel ? | ||
|
||
- if adatper?('url') | ||
= render Dsfr::InputComponent.new(form:, attribute: :referentiel_url) | ||
- elsif adatper?('csv') | ||
.fr-input-group | ||
= form.label :piece_justificative_template, class: 'fr-label', for: dom_id(@type_de_champ, :piece_justificative_template) do | ||
Fichier CSV | ||
%span.fr-text-hint Utilisez le modèle du fichier CSV fourni ci-dessous pour construire votre référentiel (le nombre de colonne n’est pas limité). | ||
= render Attachment::EditComponent.new(attached_file: @type_de_champ.piece_justificative_template, view_as: :link) | ||
|
||
%hr.fr-hr.fr-my-5w | ||
|
||
%div | ||
= render Dsfr::RadioButtonListComponent.new(form:, target: :referentiel_presenter, | ||
buttons: [ { label: 'Correspondance exacte', value: 'exact_match', hint: 'Vérification de l’existence de la donnée saisie dans la BDD du référentiel (exemple : plaque d’immatriculation, SIREN...)' } , | ||
{ label: 'Autosuggestion au fur et à mesure de la saisie de l’usager', value: 'autocomplete', hint: 'Affichage de données issues de la BDD du référentiel correspondant en partie ou en totalité à la donnée saisie par l’usager (exemple : BDD de médicaments, modèles de véhicules...)', disabled: true }]) do | ||
Mode de remplissage du champ par l’usager | ||
|
||
= render Dsfr::InputComponent.new(form:, attribute: :referentiel_hint) | ||
= render Dsfr::InputComponent.new(form:, attribute: :referentiel_test_data) | ||
|
||
%hr.fr-hr.fr-my-5w | ||
|
||
%ul.fr-btns-group.fr-btns-group--inline-sm | ||
%li= link_to "Annuler", champs_admin_procedure_path(@procedure), class: 'fr-btn fr-btn--secondary' | ||
%li= form.submit 'Étape suivante', class: 'fr-btn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
app/components/types_de_champ_editor/info_referentiel_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/views/administrateurs/types_de_champ/setup_datasource.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.fr-container.fr-mt-6w.fr-mb-15w | ||
= link_to " Champs du formulaire", champs_admin_procedure_path(@procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon--left fr-icon--sm' | ||
%h3.fr-my-3w | ||
Configuration du champ « #{@type_de_champ.libelle} » | ||
|
||
.fr-stepper | ||
%h2.fr-stepper__title | ||
Requête | ||
%span.fr-stepper__state Étape 1 sur 3 | ||
|
||
.fr-stepper__steps{ data: { "fr-current-step" => "1", "fr-steps" => "3" } } | ||
%p.fr-stepper__details | ||
%span.fr-text--bold Étape suivante : | ||
Réponse et mapping | ||
= render TypeDeChampReferentiel::SetupDatasourceComponent.new(type_de_champ: @type_de_champ, procedure: @procedure) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters