Browse Source

Change function to read more clearly

pull/2510/head
Manny Dinssa 2 years ago
parent
commit
f6c938df2a
  1. 4
      app/models/scheme.rb
  2. 2
      app/views/schemes/_scheme_list.html.erb
  3. 2
      app/views/schemes/show.html.erb

4
app/models/scheme.rb

@ -295,8 +295,8 @@ class Scheme < ApplicationRecord
status == :active status == :active
end end
def all_locations_inactive? def has_active_locations?
active? && locations.all? { |location| !location.active? } active? && locations.active.exists?
end end
def any_location_active_on_date?(date) def any_location_active_on_date?(date)

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

@ -28,7 +28,7 @@
<% row.with_cell(text: scheme.locations.visible&.count) %> <% row.with_cell(text: scheme.locations.visible&.count) %>
<% row.with_cell do %> <% row.with_cell do %>
<%= status_tag_from_resource(scheme) %> <%= status_tag_from_resource(scheme) %>
<% if scheme.all_locations_inactive? %> <% unless scheme.has_active_locations? %>
<%= content_tag(:div, "No currently active locations", class: "app-!-colour-muted", style: "margin-top: 10px") %> <%= content_tag(:div, "No currently active locations", class: "app-!-colour-muted", style: "margin-top: 10px") %>
<% end %> <% end %>
<% end %> <% end %>

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

@ -26,7 +26,7 @@
<dt class="govuk-summary-list__key">Status</dt> <dt class="govuk-summary-list__key">Status</dt>
<dd class="govuk-summary-list__value"> <dd class="govuk-summary-list__value">
<%= details_html({ name: "Status", value: status_tag_from_resource(@scheme), id: "status" }) %> <%= details_html({ name: "Status", value: status_tag_from_resource(@scheme), id: "status" }) %>
<% if @scheme.confirmed? && @scheme.all_locations_inactive? %> <% if @scheme.confirmed? && !@scheme.has_active_locations? %>
<span class="app-!-colour-muted">No currently active locations</span> <span class="app-!-colour-muted">No currently active locations</span>
<% end %> <% end %>
<% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %> <% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %>

Loading…
Cancel
Save