Browse Source

lint

pull/744/head
Kat 3 years ago
parent
commit
ad14fbf774
  1. 2
      app/models/form/setup/questions/location_id.rb
  2. 2
      app/models/form/setup/questions/scheme_id.rb
  3. 2
      app/models/scheme.rb
  4. 4
      app/views/locations/edit.html.erb
  5. 4
      app/views/locations/new.html.erb

2
app/models/form/setup/questions/location_id.rb

@ -13,7 +13,7 @@ class Form::Setup::Questions::LocationId < ::Form::Question
answer_opts = {} answer_opts = {}
return answer_opts unless ActiveRecord::Base.connected? return answer_opts unless ActiveRecord::Base.connected?
Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", Date.today).each_with_object(answer_opts) do |location, hsh| Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", Time.zone.today).each_with_object(answer_opts) do |location, hsh|
hsh[location.id.to_s] = { "value" => location.postcode, "hint" => location.name } hsh[location.id.to_s] = { "value" => location.postcode, "hint" => location.name }
hsh hsh
end end

2
app/models/form/setup/questions/scheme_id.rb

@ -22,7 +22,7 @@ class Form::Setup::Questions::SchemeId < ::Form::Question
def displayed_answer_options(case_log) def displayed_answer_options(case_log)
return {} unless case_log.created_by return {} unless case_log.created_by
user_org_scheme_ids = Scheme.select(:id).where(owning_organisation_id: case_log.created_by.organisation_id).joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Date.today)).map(&:id) user_org_scheme_ids = Scheme.select(:id).where(owning_organisation_id: case_log.created_by.organisation_id).joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Time.zone.today)).map(&:id)
answer_options.select do |k, _v| answer_options.select do |k, _v|
user_org_scheme_ids.include?(k.to_i) user_org_scheme_ids.include?(k.to_i)
end end

2
app/models/scheme.rb

@ -148,7 +148,7 @@ class Scheme < ApplicationRecord
end end
def appended_text def appended_text
"(#{locations.count { |location| location.startdate.blank? || location.startdate <= Date.today }} locations)" "(#{locations.count { |location| location.startdate.blank? || location.startdate <= Time.zone.today }} locations)"
end end
def hint def hint

4
app/views/locations/edit.html.erb

@ -21,7 +21,7 @@
<%= f.govuk_text_field :name, <%= f.govuk_text_field :name,
label: { text: I18n.t("questions.location.name"), size: "m" }, label: { text: I18n.t("questions.location.name"), size: "m" },
hint: { text: I18n.t("hints.location.name")} %> hint: { text: I18n.t("hints.location.name") } %>
<%= f.govuk_number_field :units, <%= f.govuk_number_field :units,
label: { text: I18n.t("questions.location.units"), size: "m" }, label: { text: I18n.t("questions.location.units"), size: "m" },
@ -45,7 +45,7 @@
legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %> legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %>
<%= f.govuk_date_field :startdate, <%= f.govuk_date_field :startdate,
legend: { text:I18n.t("questions.location.startdate"), size: "m" }, legend: { text: I18n.t("questions.location.startdate"), size: "m" },
width: 20 %> width: 20 %>
<%= govuk_section_break(visible: true, size: "m") %> <%= govuk_section_break(visible: true, size: "m") %>

4
app/views/locations/new.html.erb

@ -43,9 +43,9 @@
wheelchair_user_selection, wheelchair_user_selection,
:id, :id,
:name, :name,
hint: { text:I18n.t("hints.location.wheelchair_adaptation")}, hint: { text: I18n.t("hints.location.wheelchair_adaptation") },
legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %> legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %>
<%= f.govuk_date_field :startdate, <%= f.govuk_date_field :startdate,
legend: { text: I18n.t("questions.location.startdate"), size: "m" }, legend: { text: I18n.t("questions.location.startdate"), size: "m" },
width: 20 %> width: 20 %>

Loading…
Cancel
Save