diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index 312cf6e614..7f043c5602 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -3,5 +3,86 @@ $govuk-new-link-styles: true; $govuk-assets-path: ""; @import "govuk-frontend/dist/govuk/all"; - @import "components/all"; +// // @import "govuk-frontend/govuk/base"; +// @import "govuk-frontend/dist/govuk/base"; +// @import "@ministryofjustice/frontend/moj/settings/all"; +// @import "@ministryofjustice/frontend/moj/helpers/all"; +// @import "@ministryofjustice/frontend/moj/objects/all"; + +// @import "@ministryofjustice/frontend/moj/components/primary-navigation/primary-navigation"; +// // @import "@ministryofjustice/frontend/moj/all"; +// $moj-images-path: "@ministryofjustice/frontend/moj/assets/images/"; +// $mobile-small-start: 400px; +// $mobile-small-end: 401px; +// $mobile-big-start: 500px; +// $mobile-big-end: 501px; +// $git-brand-colour: #159964; +.app-primary-navigation { + background-color: govuk-colour("light-grey"); +} + +.app-primary-navigation--justify-between { + display: flex; + justify-content: space-between; +} + +.app-primary-navigation__list { + @include govuk-clearfix; + list-style: none; + margin: 0; + padding: 0; +} + +.app-primary-navigation__item { + @include govuk-font($size: 19); + float: left; + margin-right: govuk-spacing(3); + margin-top: 0; + + &:last-child { + margin-right: 0; + } + + @include govuk-media-query($from: tablet) { + margin-right: govuk-spacing(4); + } +} + +.app-primary-navigation__item--align-right { + @include govuk-media-query($from: tablet) { + float: right; + } +} + +.app-primary-navigation__link { + @include govuk-link-common; + @include govuk-link-style-no-visited-state; + display: block; + font-weight: bold; + padding-bottom: govuk-spacing(3); + padding-top: govuk-spacing(3); + text-decoration: none; + + &:focus { + background-color: $govuk-focus-colour; + box-shadow: inset 0 -5px 0 0 $govuk-focus-text-colour; + color: $govuk-focus-text-colour; + outline: $govuk-focus-width solid transparent; + } + + &[aria-current] { + box-shadow: inset 0 -5px 0 0 $govuk-link-colour; + color: $govuk-link-colour; + + &:hover { + box-shadow: inset 0 -5px 0 0 $govuk-link-hover-colour; + color: $govuk-link-hover-colour; + } + + &:focus { + box-shadow: inset 0 -7px 0 0 $govuk-focus-text-colour; + color: $govuk-focus-text-colour; + } + } +} diff --git a/app/components/application_component.rb b/app/components/application_component.rb new file mode 100644 index 0000000000..6eb1b59f12 --- /dev/null +++ b/app/components/application_component.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ApplicationComponent < GovukComponent::Base + def initialize(classes: [], html_attributes: {}) + super(classes:, html_attributes:) + end + + private + + def default_attributes + {} + end +end diff --git a/app/components/navigation_bar.html.erb b/app/components/navigation_bar.html.erb new file mode 100644 index 0000000000..786cf53ec8 --- /dev/null +++ b/app/components/navigation_bar.html.erb @@ -0,0 +1,22 @@ +
+
+
+ +
+
+
diff --git a/app/components/navigation_bar.rb b/app/components/navigation_bar.rb new file mode 100644 index 0000000000..6046693aac --- /dev/null +++ b/app/components/navigation_bar.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class NavigationBar < ApplicationComponent + attr_reader :items, :current_path + + def initialize( + items:, + current_path:, + current_user: {}, + classes: [], + html_attributes: {} + ) + super(classes:, html_attributes:) + @items = items + @current_path = current_path + @current_user = current_user + end + + def item_link(item) + link_params.merge!(aria: { current: "page" }) if show_current_link?(item) + govuk_link_to(item[:name], item[:url], no_underline: true) + end + + def user_signed_in? + @current_user.present? + end + + private + + def show_current_link?(item) + item.fetch(:current, false) || + [item.fetch(:url), item[:additional_url]].compact.any? do |url| + current_path.include?(url) + end + end +end diff --git a/app/controllers/claims/pages_controller.rb b/app/controllers/claims/pages_controller.rb index 48810ac803..ce1d48e44d 100644 --- a/app/controllers/claims/pages_controller.rb +++ b/app/controllers/claims/pages_controller.rb @@ -1,2 +1,5 @@ class Claims::PagesController < ApplicationController + def index + @school = GiasSchool.first + end end diff --git a/app/helpers/navigation_bar_helper.rb b/app/helpers/navigation_bar_helper.rb new file mode 100644 index 0000000000..13533236fb --- /dev/null +++ b/app/helpers/navigation_bar_helper.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module NavigationBarHelper + def render_navigation_bar?(provider) + request.path.exclude?("support") && provider && !current_page?(root_path) && + !current_page?(publish_provider_path(provider.provider_code)) && + provider.recruitment_cycle + end + + def navigation_items(_provider) + [ + { + name: t("navigation_bar.users"), + url: "#", + additional_url: + "request_access_publish_provider_path(provider.provider_code)" + }, + name: t("navigation_bar.organisation_details"), + url: root_path, + active: request.path == root_path + ] + end +end diff --git a/app/views/claims/pages/index.html.erb b/app/views/claims/pages/index.html.erb index 5e1edfae85..49d57d2cd0 100644 --- a/app/views/claims/pages/index.html.erb +++ b/app/views/claims/pages/index.html.erb @@ -1,26 +1,49 @@ -
-
-

It works! 🎉

+<%= render(NavigationBar.new( + items: navigation_items(@provider), + current_path: request.path, + current_user: User.first + )) %> +
+

+
+

Organisation details

+ <%= govuk_summary_list do |summary_list| + summary_list.with_row do |row| + row.with_key(text: "Organisation name") + row.with_value(text: @school.name) + end;summary_list.with_row do |row| + row.with_key(text: "UK provider reference number (UKPRN)") + row.with_value(text: @school.ukprn) + end;summary_list.with_row do |row| + row.with_key(text: "Unique reference number (URN)") + row.with_value(text: @school.urn) + end;end %> -

- Your application is ready - so long as this page rendered without any errors you're good to go. -

- - <%= govuk_summary_list( - rows: [ - { key: { text: "Service" }, value: { text: "Claims" } }, - { key: { text: "Rails version" }, value: { text: Rails.version } }, - { key: { text: "Ruby version" }, value: { text: RUBY_VERSION } }, - { key: { - text: "GOV.UK Frontend" }, - value: { - text: JSON - .parse(File.read(Rails.root.join("package.json"))) - .dig("dependencies", "govuk-frontend") - .tr("^", "") - } - } - ] - ) %> -
-
+

Contact details

+ <%= govuk_summary_list do |summary_list| + summary_list.with_row do |row| + row.with_key(text: 'Email address') + row.with_value do %> + contact@example.com + <% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details') + end;summary_list.with_row do |row| + row.with_key(text: 'Telephone number') + row.with_value(text: @school.telephone) + row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details') + end;summary_list.with_row do |row| + row.with_key(text: 'Website') + row.with_value do %> + <%= @school.website %> + <% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details') + end;summary_list.with_row do |row| + row.with_key(text: 'Address') + row.with_value do %> +

+ <%= @school.address1 %>
+ <%= @school.address2 %>
+ <%= @school.address3 %>
+

+ <% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details') + end;end %> +
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7b9287fcf6..90a3111976 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,7 +25,9 @@ <%= govuk_skip_link %> - <%= govuk_header(homepage_url: "https://www.gov.uk", service_name: t(".#{current_service}.header.service_name"), service_url: "/") %> + <%= govuk_header(homepage_url: "https://www.gov.uk") do |header| %> + <%= header.with_product_name(name: t(".#{current_service}.header.service_name")) %> + <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index f2a772fd9d..58a87a2912 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -47,3 +47,7 @@ en: placements: heading: Placements news and updates contents: Contents + navigation_bar: + organisation_details: Organisation details + users: Users + diff --git a/spec/factories/gias_schools.rb b/spec/factories/gias_schools.rb index 6fee982692..3851d294f4 100644 --- a/spec/factories/gias_schools.rb +++ b/spec/factories/gias_schools.rb @@ -24,5 +24,11 @@ factory :gias_school do sequence(:urn) { _1 } name { "Hogwarts" } + ukprn { "fake_uprn" } + telephone { "0123456789" } + website { "www.hogwarts.com" } + address1 { "Hogwarts Castle" } + address2 { "Scotland" } + address3 { "United Kingdom" } end end diff --git a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb index 926cbf3cc5..ef2cc74213 100644 --- a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb +++ b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb @@ -9,6 +9,7 @@ scenario "I sign in as persona Anne" do given_there_is_an_existing_claims_persona_for("Anne") + and_given_i_have_a_school when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Anne") when_i_click_sign_in_as("Anne") @@ -18,6 +19,7 @@ scenario "I sign in as persona Patricia" do given_there_is_an_existing_claims_persona_for("Patricia") + and_given_i_have_a_school when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Patricia") when_i_click_sign_in_as("Patricia") @@ -27,6 +29,7 @@ scenario "I sign in as persona Mary" do given_there_is_an_existing_claims_persona_for("Mary") + and_given_i_have_a_school when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Mary") when_i_click_sign_in_as("Mary") @@ -36,6 +39,7 @@ scenario "I sign in as persona colin" do given_there_is_an_existing_claims_persona_for("Colin") + and_given_i_have_a_school when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Colin") when_i_click_sign_in_as("Colin") @@ -50,6 +54,10 @@ def given_there_is_an_existing_claims_persona_for(persona_name) create(:persona, persona_name.downcase.to_sym, service: "claims") end +def and_given_i_have_a_school + create(:gias_school) +end + def when_i_visit_the_claims_personas_page visit personas_path end diff --git a/spec/system/claims/pages/home_spec.rb b/spec/system/claims/pages/home_spec.rb new file mode 100644 index 0000000000..b95f43623d --- /dev/null +++ b/spec/system/claims/pages/home_spec.rb @@ -0,0 +1,46 @@ +require "rails_helper" + +RSpec.feature "Home Page" do + after { Capybara.app_host = nil } + + scenario "User visits the claims homepage" do + given_there_is_an_existing_persona_for("Mary") + given_i_am_on_the_claims_site + + when_i_visit_home_page + i_can_see_organisation_details + i_can_see_contact_details + + end + + private + + def given_i_am_on_the_claims_site + Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}" + end + + def when_i_visit_home_page + visit "/" + end + + def given_there_is_an_existing_persona_for(persona_name) + user = create(:persona, persona_name.downcase.to_sym,service:"claims") + create(:gias_school) + DfESignInUser.load_from_session({"dfe_sign_in_user"=>{"email"=>user.email},"service" =>:claims}) + end + + def i_can_see_organisation_details + expect(page).to have_css(".govuk-summary-list__value", text: "Hogwarts") + expect(page).to have_css(".govuk-summary-list__value", text: "fake_uprn") + expect(page).to have_css(".govuk-summary-list__value", text: 1) + end + + def i_can_see_contact_details + expect(page).to have_css(".govuk-summary-list__value", text: "contact@example.com") + expect(page).to have_css(".govuk-summary-list__value", text: "0123456789") + expect(page).to have_css(".govuk-summary-list__value", text: "www.hogwarts.com") + expect(page).to have_css(".govuk-summary-list__value", text: "Hogwarts Castle") + expect(page).to have_css(".govuk-summary-list__value", text: "Scotland") + expect(page).to have_css(".govuk-summary-list__value", text: "United Kingdom") + end +end diff --git a/spec/system/home_page_spec.rb b/spec/system/home_page_spec.rb index e53ca22d70..a35e322fb8 100644 --- a/spec/system/home_page_spec.rb +++ b/spec/system/home_page_spec.rb @@ -5,6 +5,7 @@ scenario "User visits the claims homepage" do given_i_am_on_the_claims_site + and_given_i_have_a_school and_i_am_on_the_start_page i_can_see_the_claims_service_name_in_the_header and_i_can_see_the_claims_service_value_in_the_page @@ -27,6 +28,10 @@ def given_i_am_on_the_placements_site Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}" end + def and_given_i_have_a_school + create(:gias_school) + end + def and_i_am_on_the_start_page visit "/" end @@ -44,7 +49,7 @@ def i_can_see_the_placements_service_name_in_the_header end def and_i_can_see_the_claims_service_value_in_the_page - expect(page).to have_css(".govuk-summary-list__value", text: "Claims") + expect(page).to have_css(".app-primary-navigation__link", text: "Claims") end def and_i_can_see_the_placements_service_value_in_the_page