From 19105f4d91667ff7d0f63a29b0382c8003b67d2f Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 3 Jan 2024 14:01:34 +0000 Subject: [PATCH] feat: add flex styling to match designs --- app/frontend/styles/_data_box.scss | 27 +++++++++++-- app/helpers/home_helper.rb | 60 +++++++++++++++++++-------- app/views/home/_data_box.html.erb | 14 +++---- app/views/home/index.html.erb | 65 +++++++++++++++++++----------- 4 files changed, 114 insertions(+), 52 deletions(-) diff --git a/app/frontend/styles/_data_box.scss b/app/frontend/styles/_data_box.scss index e3ba85d04..a18c96baf 100644 --- a/app/frontend/styles/_data_box.scss +++ b/app/frontend/styles/_data_box.scss @@ -1,10 +1,29 @@ -.app-data-box__pair { +.app-data-box-group { @include govuk-font($size: 19); font-weight: bold; + white-space: nowrap; + width: 100%; +} +@media (min-width: 72.5em) { + .app-data-box-group { + display: flex; + justify-content: space-between; + column-gap: govuk-spacing(4); + } +} +@media (min-width: 72.5em) { + .app-data-box-one-third { + width: 33.3333333%; + float: left; + } +} +@media (min-width: 72.5em) { + .app-data-box-one-half { + width: 50%; + float: left; + } } - .app-data-box__upper { - @include govuk-responsive-margin(4, "right"); @include govuk-responsive-margin(2, "bottom"); @include govuk-responsive-padding(4); @@ -13,7 +32,7 @@ } .app-data-box__lower { - @include govuk-responsive-margin(4, "right"); + @include govuk-responsive-margin(4, "bottom"); @include govuk-responsive-padding(4); background-color: govuk-colour("blue"); diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb index 5ffd48c6b..e49209630 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -1,10 +1,17 @@ module HomeHelper - - def in_progress_count(user, type) - case type - when "lettings" then user.lettings_logs.in_progress.count - when "sales" then user.sales_logs.in_progress.count - when "schemes" then user.schemes.incomplete.count + def data_count(user, type) + if user.data_provider? + case type + when "lettings" then user.lettings_logs.in_progress.where(created_by: user).count + when "sales" then user.sales_logs.in_progress.where(created_by: user).count + when "misc" then user.lettings_logs.completed.where(created_by: user).count + end + else + case type + when "lettings" then user.lettings_logs.in_progress.count + when "sales" then user.sales_logs.in_progress.count + when "schemes" then user.schemes.incomplete.count + end end end @@ -16,26 +23,47 @@ module HomeHelper end end - def in_progress_subheading(user, type) - if type == "schemes" - return"Incomplete schemes" + def data_subheading(user, type) + case type + when "schemes" + "Incomplete schemes" + when "misc" + "Your completed lettings" + else + "#{user.role == 'data_provider' ? :"Your " : nil}#{type} in progress".capitalize end - "#{user.role == "data_provider" ? :"Your " : nil}#{type} in progress".capitalize end - def in_progress_path(type) - case type - when "lettings" then lettings_logs_path(status: [:in_progress]) - when "sales" then sales_logs_path(status: [:in_progress]) - when "schemes" then schemes_path(status: [:incomplete]) + def data_path(user, type) + if user.data_provider? + case type + when "lettings" then lettings_logs_path(status: [:in_progress], assigned_to: "you") + when "sales" then sales_logs_path(status: [:in_progress], assigned_to: "you") + when "misc" then lettings_logs_path(status: [:completed], assigned_to: "you") + end + else + case type + when "lettings" then lettings_logs_path(status: [:in_progress]) + when "sales" then sales_logs_path(status: [:in_progress]) + when "schemes" then schemes_path(status: [:incomplete]) + end end end - def clear_filter_path_for_type(type) + def view_all_path(type) case type when "lettings" then clear_filters_path(filter_type: "lettings_logs") when "sales" then clear_filters_path(filter_type: "sales_logs") when "schemes" then clear_filters_path(filter_type: "schemes") + when "misc" then clear_filters_path(filter_type: "schemes") + end + end + + def view_all_text(type) + if type == "misc" + "View all schemes" + else + "View all #{type}" end end end diff --git a/app/views/home/_data_box.html.erb b/app/views/home/_data_box.html.erb index 04cc7d972..d2a26d1b4 100644 --- a/app/views/home/_data_box.html.erb +++ b/app/views/home/_data_box.html.erb @@ -1,9 +1,7 @@ -
- -
- <%= govuk_link_to "View all #{type}", clear_filter_path_for_type(type), class: "govuk-link--inverse" %> -
+ +
+ <%= govuk_link_to view_all_text(type), view_all_path(type), class: "govuk-link--inverse" %>
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 848dc8aed..2259528dc 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,28 +1,45 @@
-
-
- <%= "Welcome back, #{@current_user.name}" %> -

<%= heading_for_user_role(@current_user) %>

-
-
- <% if @current_user.support? %> -
- <%= render partial: "home/data_box", locals: {type: "lettings"} %> -
-
- <%= render partial: "home/data_box", locals: {type: "sales"} %> -
-
- <%= render partial: "home/data_box", locals: {type: "schemes"} %> -
- <% else %> -
- <%= render partial: "home/data_box", locals: {type: "lettings"} %> -
-
- <%= render partial: "home/data_box", locals: {type: "sales"} %> -
- <% end %> +
+
+
+ <%= "Welcome back, #{@current_user.name}" %> +

<%= heading_for_user_role(@current_user) %>

+
+
+
+ <% if @current_user.support? || (@current_user.data_coordinator? && @current_user.sales_logs.present?)%> +
+ <%= render partial: "home/data_box", locals: {type: "lettings"} %> +
+
+ <%= render partial: "home/data_box", locals: {type: "sales"} %> +
+
+ <%= render partial: "home/data_box", locals: {type: "schemes"} %> +
+ <% else %> +
+ <%= render partial: "home/data_box", locals: {type: "lettings"} %> +
+ <% if @current_user.data_coordinator? %> +
+ <%= render partial: "home/data_box", locals: {type: "schemes"} %> +
+ <% elsif @current_user.sales_logs.present? %> +
+ <%= render partial: "home/data_box", locals: {type: "sales"} %> +
+ <% else %> +
+ <%= render partial: "home/data_box", locals: {type: "misc"} %> +
+ <% end %> + <% end %> +
+
+
+
+