Skip to content

Commit

Permalink
Add stars to forms
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrax committed Feb 26, 2025
1 parent 061ee3a commit 1dfbcb0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
23 changes: 22 additions & 1 deletion app/front_assets/components/inputs/SirenInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export default function SirenInput({

const ministry = document.getElementById("ministry-choice");
const ministryClassList = ministry.classList;
const sectorBloc = document.getElementById("sector-choice-block");
const sectorBlocClassList = sectorBloc.classList;
const sector = document.getElementById("sector-choice");
// TODO pub/sub with broadcasting would be better
// because both jsx and stimulus send events to the containers (show/hide)
ministryClassList.add("d-none"); // default
Expand All @@ -151,9 +154,27 @@ export default function SirenInput({
const hiddenField = document.getElementById("hidden-public-private-field") .children[0];
hiddenField.value = is_public;
toggleContainer(hiddenField, true);

if (is_public) {
ministry.removeAttribute("style");
ministryClassList.remove("d-none");

// For public establishments

sectorBlocClassList.add("d-none");
// Safely check and select "Fonction publique" option
if (sector && sector.options) {
for (let i = 0; i < sector.options.length; i++) {
if (sector.options[i].text.toLowerCase().includes('fonction publique')) {
sector.value = sector.options[i].value;
break;
}
}
}
} else {
// For private companies
sectorBlocClassList.remove("d-none");
sector.value = "";
}
}
};
Expand Down Expand Up @@ -224,7 +245,7 @@ export default function SirenInput({
htmlFor: `${resourceName}_siren`,
})}
>
Indiquez le nom ou le SIRET de la structure daccueil *
Indiquez le nom ou le SIRET de la structure d'accueil *
{railsEnv === "development"
? " (dev only : 21950572400209)"
: ""}
Expand Down
10 changes: 6 additions & 4 deletions app/views/dashboard/stepper/entreprises/_form_fields.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data-ministry-fields-new-record-value="#{resource.new_record?}"
data-ministry-fields-is-entreprise-public-value="#{resource.try(:is_public) ? 'true' : 'false'}" ]
.row
.col-12= form.rg2a_explain_required_asterisk(p_class_name: "mb-0")
.col-md-6.order-md-2.order-1.d-none.d-md-block
- if form.object.new_record? && show_resume
= render 'dashboard/stepper/summary_card', form: form
Expand Down Expand Up @@ -72,23 +73,24 @@
#ministry-choice.row.fr-mt-3w.bloc-tooggle.d-none [data-ministry-fields-target="groupNamePublic"]
.col-12
= form.label :group_id, class: 'fr-label' do
= "Type d’employeur public"
= "Type d’employeur public *"

= form.select :group_id,
options_for_select(options_for_public_groups, resource.group.try(:id)),
{ prompt: '-- Choisissez votre ministère de tutelle --' },
{ },
class: "fr-select ",
required: false,
:'data-ministry-fields-target' => 'selectGroupName'
div class="row fr-mt-3w bloc-tooggle #{form.object.persisted? ? '' : 'd-none'}"
div#sector-choice-block class="row fr-mt-3w bloc-tooggle #{form.object.persisted? ? '' : 'd-none'}"
.col-12
= form.label :sector_id , class: 'fr-label'do
= "Indiquez le secteur d'activité de votre structure"
= "Indiquez le secteur d'activité de votre structure *"
= form.select :sector_id,
options_from_collection_for_select(Sector.all.order(:name), :id, :name, resource.sector_id),
{ prompt: sectors_options_for_default },
class: "fr-select",
required: true,
id: "sector-choice",
data: { :'fill-card-target' => "sectorInput",
:'mandatory-fields-target' => "mandatoryField",
data: { action: "input->mandatory-fields#fieldChange change->fill-card#sectorChanged"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
data-mandatory-fields-with-coordinates-minimum-length-value="6"
data-mandatory-fields-with-coordinates-maximum-length-value="#{InternshipOffer::EMPLOYER_DESCRIPTION_MAX_CHAR_COUNT}"
data-mandatory-fields-with-coordinates-no-event-check-value="#{resource.id.present?}"]
.col-12= form.rg2a_explain_required_asterisk(p_class_name: "mb-0")
.col-md-6
.row.bloc-tooggle class=('d-old-none' if request.fullpath.include?('internship_occupations/nouveau'))
.col-12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
data-grade-initial-grades-value="#{resource.grades.compact&.map(&:short_name).join(',')}"]
= form.hidden_field :type, value: resource.type, data: { :"planning-candidates-target" => "type" } unless resource.is_a?(Planning)
.row
.col-12= form.rg2a_explain_required_asterisk(p_class_name: "mb-0")
.col-md-6.order-md-2.order-1.d-none.d-md-block
- if form.object.new_record? && !duplication
= render 'dashboard/stepper/summary_card', form: form
Expand Down

0 comments on commit 1dfbcb0

Please sign in to comment.