-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/219 faf do you have dfe sign in #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
780783d
start page - controller, route and view - tests passing
d2f7818
docker active storage error fix
7a92a31
Merge branch 'develop' into feature/217-FaF-support-request-start-page
d-a-v-e dae97d8
dsi_or_search route, action, view
d-a-v-e 67116b5
faf form, schema and step pattern
d-a-v-e 5f87535
fixed dsi error message
d-a-v-e c48cab6
merge develop => feature/219
d-a-v-e 3132df8
use base form and schema
d-a-v-e 52d8a2f
tidy up
d-a-v-e acf1624
fix spec
d-a-v-e cd5b50e
Merge branch 'develop' into feature/219-faf-do-you-have-dfe-sign-in
d-a-v-e 7fa643d
form and schema bases
d-a-v-e e1180e2
remove uneeded methods from support_form
d-a-v-e 4b6f52e
remove uneeded methods from support_form
d-a-v-e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,33 @@ | ||
| class FafsController < ApplicationController | ||
| skip_before_action :authenticate_user! | ||
|
|
||
| def index; end | ||
|
|
||
| def show; end | ||
|
|
||
| def new | ||
| @faf_form = FafForm.new(step: 1) | ||
| end | ||
|
|
||
| def create | ||
| @faf_form = form | ||
| @faf_form.advance! if validation.success? | ||
| render :new | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # @return [FafForm] form object populated with validation messages | ||
| def form | ||
| FafForm.new(step: form_params[:step], messages: validation.errors(full: true).to_h, **validation.to_h) | ||
| end | ||
|
|
||
| def form_params | ||
| params.require(:faf_form).permit(:step, :dsi) | ||
| end | ||
|
|
||
| # @return [FafFormSchema] validated form input | ||
| def validation | ||
| FafFormSchema.new.call(**form_params) | ||
| end | ||
| end |
This file contains hidden or 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,61 @@ | ||
| # @abstract Form Object for multi-step Find-a-Framework support questionnaire | ||
| # | ||
| class FafForm | ||
| extend Dry::Initializer | ||
|
|
||
| # @see https://design-system.service.gov.uk/components/error-summary/ | ||
| # | ||
| class ErrorSummary | ||
| extend Dry::Initializer | ||
|
|
||
| # @!attribute [r] messages | ||
| # | ||
| # @example | ||
| # { phone_number: ["size cannot be less than 10"] } | ||
| # | ||
| # @return [Hash] | ||
| param :messages, Types::Hash, default: proc { {} } | ||
|
|
||
| delegate :any?, to: :messages | ||
| end | ||
|
|
||
| # @!attribute [r] step | ||
| # @return [Integer] internal counter defaults to 1, coerces strings | ||
| option :step, Types::Params::Integer, default: proc { 1 } | ||
|
|
||
| # @!attribute [r] messages | ||
| # @return [Hash] field validation error messages | ||
| option :messages, Types::Hash, default: proc { {} } | ||
|
|
||
| # @!attribute [r] dsi | ||
| # @return [Boolean] | ||
| option :dsi, Types::Params::Bool, optional: true # 1 | ||
|
|
||
| # @see https://govuk-form-builder.netlify.app/introduction/error-handling/ | ||
| # | ||
| # @return [ErrorSummary] | ||
| def errors | ||
| ErrorSummary.new(messages) | ||
| end | ||
|
|
||
| # Proceed or skip to next questions | ||
| # | ||
| # @param num [Integer] number of steps to advance | ||
| # | ||
| # @return [Integer] next step position | ||
| def advance!(num = 1) | ||
| @step += num | ||
| end | ||
|
|
||
| # @return [Integer] previous step position | ||
| def back | ||
| @step - 1 | ||
| end | ||
|
|
||
| # @see SupportRequestsController#update | ||
| # | ||
| # @return [Hash] form parms as support request attributes | ||
| def to_h | ||
| self.class.dry_initializer.attributes(self).except(:step, :messages) | ||
| end | ||
| end |
This file contains hidden or 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,18 @@ | ||
| # | ||
| # Validate "find-a-framework support requests" | ||
| # | ||
| class FafFormSchema < Dry::Validation::Contract | ||
| import_predicates_as_macros | ||
|
|
||
| config.messages.backend = :i18n | ||
| config.messages.top_namespace = :forms | ||
| config.messages.load_paths << Rails.root.join("config/locales/validation/en.yml") | ||
|
|
||
| params do | ||
| optional(:dsi).value(:bool) | ||
| end | ||
|
|
||
| rule(:dsi) do | ||
| key.failure(:missing) unless key? | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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,6 @@ | ||
| <div class="govuk-grid-row"> | ||
| <div class="govuk-grid-column-two-thirds"> | ||
| <%= render "fafs/steps/form", path: fafs_path(@faf), verb: :patch %> | ||
| </div> | ||
| </div> | ||
|
|
This file contains hidden or 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,41 @@ | ||
| <%= content_for :title, I18n.t("faf.start_page.header") %> | ||
|
|
||
| <div class="govuk-grid-row"> | ||
| <div class="govuk-grid-column-full"> | ||
| <h1 class="govuk-heading-xl"><%= I18n.t("faf.start_page.header") %></h1> | ||
|
|
||
| <p class="govuk-body"><%= I18n.t("faf.start_page.overview_purpose") %></p> | ||
| <p class="govuk-body"><%= I18n.t("faf.start_page.you_can_ask_for") %>:</p> | ||
|
|
||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <% I18n.t("faf.start_page.overview_category_list").each do |list_item| %> | ||
| <li><%= list_item %></li> | ||
| <% end %> | ||
| </ul> | ||
|
|
||
| <p class="govuk-body"><%= I18n.t("faf.start_page.overview_response") %></p> | ||
|
|
||
|
|
||
|
|
||
| <%= link_to new_faf_path, | ||
| class: "govuk-button govuk-!-margin-top-2 govuk-!-margin-bottom-8 govuk-button--start" do %> | ||
| <%= I18n.t("generic.button.start") %> | ||
| <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false"> | ||
| <path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" /> | ||
| </svg> | ||
| <% end %> | ||
|
|
||
| <h2 class="govuk-heading-m"><%= I18n.t("faf.start_page.subheading") %></h2> | ||
| <p class="govuk-body"><%= I18n.t("faf.start_page.you_can") %>:</p> | ||
|
|
||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li>read <%= link_to "about frameworks", "https://www.gov.uk/guidance/buying-procedures-and-procurement-law-for-schools/find-the-right-way-to-buy" %></li> | ||
| <li>find out more about <%= link_to "planning for what you're buying", "https://buy-for-your-school-staging.herokuapp.com/beta/phase-6/gov/buying-for-schools" %></li> | ||
| <li>read information on <%= link_to "finding the right way to buy", "https://buy-for-your-school-staging.herokuapp.com/beta/phase-6/gov/buying-procedures-for-schools" %> for your school.</li> | ||
| <li><%= link_to "create a specification", "https://get-help-buying-for-schools.education.gov.uk/" %> if you don't have one yet</li> | ||
| </ul> | ||
|
|
||
|
|
||
|
|
||
| </div> | ||
| </div> |
This file contains hidden or 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,5 @@ | ||
| <div class="govuk-grid-row"> | ||
| <div class="govuk-grid-column-two-thirds"> | ||
| <%= render "fafs/steps/form", path: fafs_path, verb: :post %> | ||
| </div> | ||
| </div> |
This file contains hidden or 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,9 @@ | ||
| <%= form_with model: @faf_form, scope: :faf_form, url: path, method: verb do |form| %> | ||
| <%= form.govuk_error_summary %> | ||
|
|
||
| <%= form.hidden_field :step, value: @faf_form.step %> | ||
| <%= render "fafs/steps/step_#{@faf_form.step}", form: form %> | ||
|
|
||
| <%= form.submit I18n.t("generic.button.next"), class: "govuk-button", role: "button" %> | ||
| <% end %> | ||
|
|
This file contains hidden or 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,11 @@ | ||
| <span class="govuk-caption-l"> | ||
| <%= I18n.t("faf.dsi_or_search.subtitle") %> | ||
| </span> | ||
| <h1 class="govuk-heading-l"> | ||
| <%= I18n.t("faf.dsi_or_search.header") %> | ||
| </h1> | ||
|
|
||
| <%= form.govuk_radio_button :dsi, true, label: { text: I18n.t("faf.dsi_or_search.radios.dsi") } %> | ||
| <%= form.govuk_radio_button :dsi, false, label: { text: I18n.t("faf.dsi_or_search.radios.no_dsi") } %> | ||
|
|
||
| <br> |
This file contains hidden or 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,9 @@ | ||
| <span class="govuk-caption-l"> | ||
| step 2 | ||
| </span> | ||
| <h1 class="govuk-heading-l"> | ||
| Step 2 | ||
| </h1> | ||
|
|
||
|
|
||
| <br> | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| RSpec.feature "Faf - dsi or search" do | ||
| context "when the user is not signed in" do | ||
| before do | ||
| visit "/procurement-support/new" | ||
| end | ||
|
|
||
| it "loads the page" do | ||
| expect(find("h1")).to have_text "Do you have a DfE Sign-in account linked to the school you're requesting support for?" | ||
| end | ||
|
|
||
| it "errors if no selection is given" do | ||
| click_continue | ||
| expect(find(".govuk-error-summary__body")).to have_text "Select whether you want to use a DfE Sign-in account" | ||
| end | ||
| end | ||
|
|
||
| context "when the user is signed in" do | ||
| before do | ||
| user_is_signed_in | ||
| visit "/procurement-support/new" | ||
| end | ||
|
|
||
| it "loads the page" do | ||
| expect(find("h1")).to have_text "Do you have a DfE Sign-in account linked to the school you're requesting support for?" | ||
| end | ||
|
|
||
| it "errors if no selection is given" do | ||
| click_continue | ||
| expect(find(".govuk-error-summary__body")).to have_text "Select whether you want to use a DfE Sign-in account" | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.