Skip to content

Commit

Permalink
Merge pull request #616 from etalab/feature/dat-654-formulaires-prere…
Browse files Browse the repository at this point in the history
…mplis-pour-les-cas-dusage-dimpot

Feature/dat 654 formulaires preremplis pour les cas dusage dimpot
  • Loading branch information
Samuelfaure authored Jan 6, 2025
2 parents da36713 + 9ad208b commit ff0e90e
Show file tree
Hide file tree
Showing 27 changed files with 496 additions and 67 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/facades/new_authorization_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(definition_id:)

def facade
return APIEntrepriseFacade if api_entreprise?
return APIImpotParticulierFacade if api_impot_particulier?

DefaultFacade
end
Expand All @@ -20,4 +21,8 @@ def facade
def api_entreprise?
definition_id == 'api_entreprise'
end

def api_impot_particulier?
definition_id == 'api_impot_particulier'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class NewAuthorizationRequest
class APIImpotParticulierFacade < Base
def public_available_forms_sandbox
AuthorizationRequestFormDecorator.decorate_collection(authorization_definition_sandbox.public_available_forms)
end

private

def authorization_definition_sandbox
AuthorizationDefinition.find('api_impot_particulier_sandbox')
end
end
end
4 changes: 1 addition & 3 deletions app/javascript/controllers/choose_stage_controller.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
static targets = ['defaultResult', 'editorResult', 'sandboxResult']
static targets = ['editorResult', 'sandboxResult']

chooseEditorWithSandbox (event) {
this.defaultResultTarget.classList.add('fr-hidden')

if (event.target.value === 'true') {
this.editorResultTarget.classList.remove('fr-hidden')
this.sandboxResultTarget.classList.add('fr-hidden')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<div
id="<%= dom_id(authorization_request_form) %>"
class="
fr-tile fr-tile--horizontal fr-enlarge-link authorization-request-form-card
fr-tile fr-tile--horizontal fr-enlarge-link authorization-request-form-card <%= 'fr-p-3w' if local_assigns[:compact] %>
"
>
<div class="fr-tile__body">
<div class="fr-tile__content">
<h3 class="fr-h6 fr-tile__title fr-text-title--blue-france">
<%= link_to authorization_request_form.name,
new_authorization_request_form_path(form_uid: authorization_request_form.id) %>
<%= link_to authorization_request_form.name, new_authorization_request_form_path(form_uid: authorization_request_form.id), **(local_assigns.fetch(:additional_link_attributes, {})) %>
</h3>
<p class="fr-tile__detail">
<p class="fr-tile__detail <%= 'fr-mt-0 fr-pb-7w' if local_assigns[:compact] %>">
<%= authorization_request_form.description %>
</p>
<% if authorization_request_form.service_provider %>
Expand All @@ -23,7 +22,7 @@
</div>
</div>
<% if authorization_request_form.use_case && File.exist?(Rails.root.join("app/assets/images/pictograms/authorization_requests/#{authorization_request_form.use_case}.svg")) %>
<div class="fr-tile__header">
<div class="fr-tile__header fr-mr-1w">
<div class="fr-tile__pictogram">
<%= dsfr_custom_pictogram(
"pictograms/authorization_requests/#{authorization_request_form.use_case}.svg",
Expand Down
96 changes: 80 additions & 16 deletions app/views/authorization_requests/new/api_impot_particulier.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
</div>

<div data-controller="choose-stage" data-choose-modalite-impot-particulier-target="nextStage" class="fr-hidden">
<h2 class="fr-h4"><%= t("authorization_requests.new.editor_with_sandbox.title") %></h2>
<h2 class="fr-h4"><%= t("authorization_requests.new.api_impot_particulier.editor_with_sandbox.title") %></h2>

<div class="fr-col-lg-9">
<p class=""><%= t("authorization_requests.new.editor_with_sandbox.subtitle").html_safe %></p>
<p class=""><%= t("authorization_requests.new.api_impot_particulier.editor_with_sandbox.subtitle").html_safe %></p>

<fieldset class="fr-fieldset" id="radio-rich" aria-labelledby="radio-rich-legend radio-rich-messages">
<% t("authorization_requests.new.editor_with_sandbox.options").each do |option| %>
<% t("authorization_requests.new.api_impot_particulier.editor_with_sandbox.options").each do |option| %>
<div class="fr-fieldset__element">
<div class="fr-radio-group fr-radio-rich">
<input value="<%= option[:value] %>"
Expand All @@ -92,18 +92,82 @@
</fieldset>
</div>

<ul class="fr-btns-group fr-btns-group--inline fr-btns-group--icon-left fr-btns-group--between">
<li class="fr-ml-auto" data-choose-stage-target="defaultResult">
<button class="fr-btn" disabled>
<%= t("authorization_request_forms.form.start_stage_generic") %>
</button>
</li>
<li class="fr-ml-auto fr-hidden" data-choose-stage-target="sandboxResult">
<%= link_to t('authorization_request_forms.form.start_first_stage'), new_authorization_request_form_path("api-impot-particulier-sandbox"), class: %w(fr-btn), "data-choose-modalite-impot-particulier-target": "links" %>
</li>
<li class="fr-ml-auto fr-hidden" data-choose-stage-target="editorResult">
<%= link_to t('authorization_request_forms.form.start_next_stage'), new_authorization_request_form_path("api-impot-particulier-production-avec-editeur"), class: %w(fr-btn), "data-choose-modalite-impot-particulier-target": "links" %>
</li>
</ul>
<div
data-choose-authorization-request-form-target="forms"
data-choose-stage-target="sandboxResult"
id="forms"
class="fr-hidden"
>
<h2 class="fr-h4"><%= t("authorization_requests.new.api_impot_particulier.choose_form_title.sandbox") %></h2>
<div class="fr-background-alt--blue-france fr-py-4w">
<div class="fr-grid-row">
<div class="fr-col-md-10 fr-col-offset-1">
<p class="center fr-px-5w fr-py-1w">
<%= t(
"authorization_requests.new.step3.use_case_intro_html",
name: @facade.authorization_definition_name,
base_url: "https://api.gouv.fr/les-api/impot-particulier",
use_cases_url: "https://api.gouv.fr/les-api/impot-particulier"
) %>
</p>

<div class="fr-grid-row fr-grid-row--center">
<% @facade.public_available_forms_sandbox.each do |authorization_request_form| %>
<div
data-choose-authorization-request-form-target="form"
data-choose-authorization-request-form-tags="<%= authorization_request_form.tags.to_json %>"
class="fr-col-md-4 fr-col-xl-4 fr-col-12 fr-p-2w"
>
<%= render partial: "authorization_request_forms/authorization_request_form_card",
locals: {
compact: true,
authorization_request_form:,
additional_link_attributes: { "data-choose-modalite-impot-particulier-target": "links" }
} %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div
data-choose-authorization-request-form-target="forms"
data-choose-stage-target="editorResult"
id="forms"
class="fr-hidden"
>
<h2 class="fr-h4"><%= t("authorization_requests.new.api_impot_particulier.choose_form_title.editor") %></h2>
<div class="fr-background-alt--blue-france fr-py-4w">
<div class="fr-grid-row">
<div class="fr-col-md-10 fr-col-offset-1">
<p class="center fr-px-5w fr-py-1w">
<%= t(
"authorization_requests.new.step3.use_case_intro_html",
name: @facade.authorization_definition_name,
base_url: "https://api.gouv.fr/les-api/impot-particulier",
use_cases_url: "https://api.gouv.fr/les-api/impot-particulier"
) %>
</p>
<div class="fr-grid-row fr-grid-row--center">
<% @facade.public_available_forms.each do |authorization_request_form| %>
<div
data-choose-authorization-request-form-target="form"
data-choose-authorization-request-form-tags="<%= authorization_request_form.tags.to_json %>"
class="fr-col-md-4 fr-col-xl-4 fr-col-12 fr-p-2w"
>
<%= render partial: "authorization_request_forms/authorization_request_form_card",
locals: {
compact: true,
authorization_request_form:,
additional_link_attributes: { "data-choose-modalite-impot-particulier-target": "links" }
} %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Loading

0 comments on commit ff0e90e

Please sign in to comment.