Browse Source

Change status tag method

pull/1701/head
Kat 3 years ago
parent
commit
c372263eb6
  1. 2
      app/helpers/schemes_helper.rb
  2. 14
      app/helpers/tag_helper.rb
  3. 2
      app/views/locations/index.html.erb
  4. 2
      app/views/locations/show.html.erb
  5. 2
      app/views/schemes/_scheme_list.html.erb

2
app/helpers/schemes_helper.rb

@ -14,7 +14,7 @@ module SchemesHelper
{ name: "Level of support given", value: scheme.support_type },
{ name: "Intended length of stay", value: scheme.intended_stay },
{ name: "Availability", value: scheme_availability(scheme) },
{ name: "Status", value: status_tag(scheme.status) },
{ name: "Status", value: status_tag_from_resource(scheme) },
]
if user.data_coordinator?

14
app/helpers/tag_helper.rb

@ -27,13 +27,17 @@ module TagHelper
deactivated: "grey",
}.freeze
def status_tag(resource, classes = [])
display_status = resource.status
display_status = :active if resource.deactivates_in_more_than_6_months?
def status_tag(status, classes = [])
govuk_tag(
classes:,
colour: COLOUR[display_status.to_sym],
text: TEXT[display_status.to_sym],
colour: COLOUR[status.to_sym],
text: TEXT[status.to_sym],
)
end
def status_tag_from_resource(resource, classes = [])
status = resource.status
status = :active if resource.deactivates_in_more_than_6_months?
status_tag(status, classes)
end
end

2
app/views/locations/index.html.erb

@ -54,7 +54,7 @@
end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.name) %>
<% row.cell(text: location.id) %>
<% row.cell(text: status_tag(location)) %>
<% row.cell(text: status_tag_from_resource(location)) %>
<% end %>
<% end %>
<% end %>

2
app/views/locations/show.html.erb

@ -15,7 +15,7 @@
<% display_location_attributes(@location).each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name] } %>
<% row.value { attr[:attribute].eql?("status") ? status_tag(@location) : details_html(attr) } %>
<% row.value { attr[:attribute].eql?("status") ? status_tag_from_resource(@location) : details_html(attr) } %>
<% if LocationPolicy.new(current_user, @location).update? %>
<% row.action(text: "Change", href: scheme_location_name_path(@scheme, @location, referrer: "details")) if attr[:attribute] == "name" %>
<% end %>

2
app/views/schemes/_scheme_list.html.erb

@ -17,7 +17,7 @@
<% row.cell(text: simple_format(scheme_cell(scheme), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: scheme.id_to_display) %>
<% row.cell(text: scheme.locations&.count) %>
<% row.cell(text: status_tag(scheme)) %>
<% row.cell(text: status_tag_from_resource(scheme)) %>
<% end %>
<% end %>
<% end %>

Loading…
Cancel
Save