Browse Source

feat: add flex styling to match designs

pull/2115/head
natdeanlewissoftwire 12 months ago
parent
commit
19105f4d91
  1. 27
      app/frontend/styles/_data_box.scss
  2. 60
      app/helpers/home_helper.rb
  3. 14
      app/views/home/_data_box.html.erb
  4. 65
      app/views/home/index.html.erb

27
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");

60
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

14
app/views/home/_data_box.html.erb

@ -1,9 +1,7 @@
<div class="app-data-box__pair">
<div class="app-data-box__upper">
<div class="app-data-box__count"><%= in_progress_count(@current_user, type) %></div>
<a><%= govuk_link_to in_progress_subheading(@current_user, type), in_progress_path(type), class: "govuk-link--no-visited-state" %></a>
</div>
<div class="app-data-box__lower">
<%= govuk_link_to "View all #{type}", clear_filter_path_for_type(type), class: "govuk-link--inverse" %>
</div>
<div class="app-data-box__upper ">
<div class="app-data-box__count"><%= data_count(@current_user, type) %></div>
<a><%= govuk_link_to data_subheading(@current_user, type), data_path(@current_user, type), class: "govuk-link--no-visited-state" %></a>
</div>
<div class="app-data-box__lower">
<%= govuk_link_to view_all_text(type), view_all_path(type), class: "govuk-link--inverse" %>
</div>

65
app/views/home/index.html.erb

@ -1,28 +1,45 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-!-margin-bottom-7">
<span class="govuk-body-l"><%= "Welcome back, #{@current_user.name}" %></span>
<h1 class="govuk-heading-l"><%= heading_for_user_role(@current_user) %></h1>
</div>
<div class="govuk-grid-row">
<% if @current_user.support? %>
<div class="govuk-grid-column-one-third">
<span><%= render partial: "home/data_box", locals: {type: "lettings"} %></span>
</div>
<div class="govuk-grid-column-one-third">
<span><%= render partial: "home/data_box", locals: {type: "sales"} %></span>
</div>
<div class="govuk-grid-column-one-third">
<span><%= render partial: "home/data_box", locals: {type: "schemes"} %></span>
</div>
<% else %>
<div class="govuk-grid-column-one-half">
<span><%= render partial: "home/data_box", locals: {type: "lettings"} %></span>
</div>
<div class="govuk-grid-column-one-half">
<span><%= render partial: "home/data_box", locals: {type: "sales"} %></span>
</div>
<% end %>
<div class="govuk-width-container">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-row govuk-!-margin-bottom-7">
<span class="govuk-body-l"><%= "Welcome back, #{@current_user.name}" %></span>
<h1 class="govuk-heading-l"><%= heading_for_user_role(@current_user) %></h1>
</div>
<div class="govuk-grid-row">
<div class="app-data-box-group">
<% if @current_user.support? || (@current_user.data_coordinator? && @current_user.sales_logs.present?)%>
<div class="app-data-box-one-third app-data-box__margin_right">
<span><%= render partial: "home/data_box", locals: {type: "lettings"} %></span>
</div>
<div class="app-data-box-one-third app-data-box__margin_right">
<span><%= render partial: "home/data_box", locals: {type: "sales"} %></span>
</div>
<div class="app-data-box-one-third">
<span><%= render partial: "home/data_box", locals: {type: "schemes"} %></span>
</div>
<% else %>
<div class="app-data-box-one-half app-data-box__margin_right">
<span><%= render partial: "home/data_box", locals: {type: "lettings"} %></span>
</div>
<% if @current_user.data_coordinator? %>
<div class="app-data-box-one-half">
<span><%= render partial: "home/data_box", locals: {type: "schemes"} %></span>
</div>
<% elsif @current_user.sales_logs.present? %>
<div class="app-data-box-one-half">
<span><%= render partial: "home/data_box", locals: {type: "sales"} %></span>
</div>
<% else %>
<div class="app-data-box-one-half">
<span><%= render partial: "home/data_box", locals: {type: "misc"} %></span>
</div>
<% end %>
<% end %>
</div>
</div>
<div class="govuk-grid-row">
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
</div>
</div>
</div>
</div>

Loading…
Cancel
Save