Browse Source

correctly looking table

pull/704/head
JG 3 years ago
parent
commit
7aa22aa874
  1. 5
      app/helpers/tab_nav_helper.rb
  2. 152
      app/views/schemes/check_answers.html.erb
  3. 71
      app/views/schemes/locations.html.erb

5
app/helpers/tab_nav_helper.rb

@ -6,6 +6,11 @@ module TabNavHelper
[govuk_link_to(link_text, user), "<span class=\"govuk-visually-hidden\">User </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"].join("\n") [govuk_link_to(link_text, user), "<span class=\"govuk-visually-hidden\">User </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"].join("\n")
end end
def location_cell(location)
link_text = location.postcode
[govuk_link_to(link_text, "locations"), "<span class=\"govuk-visually-hidden\">Location </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{location.scheme.service_name}</span>"].join("\n")
end
def scheme_cell(scheme) def scheme_cell(scheme)
link_text = scheme.service_name link_text = scheme.service_name
[govuk_link_to(link_text, scheme), "<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>"].join("\n") [govuk_link_to(link_text, scheme), "<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>"].join("\n")

152
app/views/schemes/check_answers.html.erb

@ -2,64 +2,110 @@
<%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %> <%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %>
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
<% component.tab(label: "Scheme") do %>
<%= govuk_summary_list do |summary_list| %> <div class="govuk-grid-row">
<% @scheme.check_details_attributes.each do |attr| %> <div class="govuk-grid-column-three-quarters-from-desktop">
<% next if current_user.data_coordinator? && attr[:name] == ("Managed by") %> <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>
<%= summary_list.row do |row| %> <% component.tab(label: "Scheme") do %>
<% row.key { attr[:name].to_s } %> <%= govuk_summary_list do |summary_list| %>
<% row.value { details_html(attr) } %> <% @scheme.check_details_attributes.each do |attr| %>
<% row.action( <% next if current_user.data_coordinator? && attr[:name] == ("Managed by") %>
text: "Change", <%= summary_list.row do |row| %>
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true), <% row.key { attr[:name].to_s } %>
) %> <% row.value { details_html(attr) } %>
<% end %> <% row.action(
<% end %> text: "Change",
<% @scheme.check_primary_client_attributes.each do |attr| %> href: scheme_details_path(scheme_id: @scheme.id, check_answers: true),
<%= summary_list.row do |row| %> ) %>
<% row.key { attr[:name].to_s } %> <% end %>
<% row.value { details_html(attr) } %> <% end %>
<% row.action( <% @scheme.check_primary_client_attributes.each do |attr| %>
text: "Change", <%= summary_list.row do |row| %>
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true), <% row.key { attr[:name].to_s } %>
) %> <% row.value { details_html(attr) } %>
<% end %> <% row.action(
<% end %> text: "Change",
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %> href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true),
<%= summary_list.row do |row| %> ) %>
<% row.key { attr[:name].to_s } %> <% end %>
<% row.value { details_html(attr) } %> <% end %>
<% row.action( <% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %>
text: "Change", <%= summary_list.row do |row| %>
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), <% row.key { attr[:name].to_s } %>
) %> <% row.value { details_html(attr) } %>
<% end %> <% row.action(
<% end %> text: "Change",
<% if @scheme.has_other_client_group == "Yes" %> href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
<% @scheme.check_secondary_client_attributes.each do |attr| %> ) %>
<%= summary_list.row do |row| %> <% end %>
<% row.key { attr[:name].to_s } %> <% end %>
<% row.value { details_html(attr) } %> <% if @scheme.has_other_client_group == "Yes" %>
<% row.action( <% @scheme.check_secondary_client_attributes.each do |attr| %>
text: "Change", <%= summary_list.row do |row| %>
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), <% row.key { attr[:name].to_s } %>
) %> <% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% end %>
<% @scheme.check_support_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% @scheme.check_support_attributes.each do |attr| %> <% component.tab(label: "Locations") do %>
<%= summary_list.row do |row| %> <%= govuk_table do |table| %>
<% row.key { attr[:name].to_s } %> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<% row.value { details_html(attr) } %> <%= location_caption %>
<% row.action( <% end %>
text: "Change", <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true), <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "schemes", path: request.path)) %>
) %> <% end %>
<%= table.head do |head| %>
<%= head.row do |row| %>
<% row.cell(header: true, text: "Code", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Postcode", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Units", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Actions", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @scheme.locations.each do |location| %>
<%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_cell(location), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.total_units) %>
<% row.cell(text: location.type_of_unit) %>
<% row.cell(text: "Delete") %>
<% end %>
<% end %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> </div>
<% end %> </div>
<%= govuk_button_link_to "Create scheme", schemes_path(scheme_id: @scheme.id), html: { method: :get } %> <%= govuk_button_link_to "Create scheme", schemes_path(scheme_id: @scheme.id), html: { method: :get } %>

71
app/views/schemes/locations.html.erb

@ -1,44 +1,51 @@
<% title = @scheme.service_name %> <% title = @scheme.service_name %>
<% content_for :title, title %> <% content_for :title, title %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}", href: "/schemes/#{@scheme.id}",
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, location_caption)) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters"> <div class="govuk-grid-column-three-quarters">
<% @locations.each do |location| %> <%= govuk_table do |table| %>
<section class="x-govuk-summary-card govuk-!-margin-bottom-6"> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<header class="x-govuk-summary-card__header"> <strong><%= @scheme.locations.count %></strong> <%= @scheme.locations.count.eql?(1) ? "location" : "locations" %>.
<h2 class="x-govuk-summary-card__title"> <% end %>
<%= location.name %> <%= table.head do |head| %>
</h2> <%= head.row do |row| %>
</header> <% row.cell(header: true, text: "Code", html_attributes: {
<div class="x-govuk-summary-card__body"> scope: "col",
<dl class="govuk-summary-list"> }) %>
<% location.display_attributes.each do |attribute| %> <% row.cell(header: true, text: "Postcode", html_attributes: {
<div class="govuk-summary-list__row"> scope: "col",
<dt class="govuk-summary-list__key"> }) %>
<%= attribute[:name] %> <% row.cell(header: true, text: "Units", html_attributes: {
</dt> scope: "col",
<dd class="govuk-summary-list__value app-!-font-tabular"> }) %>
<span class="govuk-!-margin-right-4"><%= attribute[:value] %></span> <% row.cell(header: true, text: "Common unit type", html_attributes: {
<% if attribute[:suffix] %> scope: "col",
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= attribute[:suffix] %></span> }) %>
<% end %> <% row.cell(header: true, text: "Actions", html_attributes: {
</dd> scope: "col",
</div> }) %>
<% end %> <% end %>
</dl> <% end %>
</div> <% @locations.each do |location| %>
</section> <%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell(text: location.id) %>
<% row.cell(text: location.postcode) %>
<% row.cell(text: location.total_units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == "Yes" ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ""}")) %>
<% row.cell(text: "Delete") %>
<% end %>
<% end %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

Loading…
Cancel
Save