Browse Source
* feat: wip update scheme summary page * feat: wip deactivate scheme schemes page * feat: wip toggle active page * feat: wip set deactivation_date to a datetime (to be more specific times later_ * Change conditional question controller to accommodate all models * feat: add specific datetimes for deactivation * feat: correct date and add notice * feat: wip error behaviour * feat: wip errors * feat: wip errors refactoring * feat: wip errors more refactoring * refactor: linting * feat: add second error in correct position and wip date range error * feat: remove unneccessary db field * feat: change type values to strings * refactor: tidy up controller logic * refactor: use same structure as locations deactivation * feat: add general partially missing date input error * feat: add tests ("updates existing scheme with valid deactivation date and renders scheme page" still wip) and add new partially nil date behaviour to locations controller * feat: fix tests, add status tag behaviour and remove unnecessary nils * refactor: linting * refactor: erblinting * refactor: remove redundant line * refactor: respond to PR comments 1 * refactor: respond to PR comments 2 * refactor: respond to PR comments 3 * refactor: respond to PR comments 3 (locations side) * fix: remove @locations in location model * fix: remove @locations in location model * fix: update status names * feat: wip validation update * feat: add validation to model layer * feat: further separate scheme deactivation behaviour * test: update tests to new flow * feat: respond to pr comments and add dynamic success text * feat: duplicate behaviour schemes -> locations (+ tests) * refactor: linting * refactor: typo and remove unnecessary line for this PR * refactor: feature toggle simplification * Refactor locations and schemes controller actions - Rename confirmation partials to `deactivate_confirm.html.erb` so that they match the actions in which they belong to - Make all deactivation date comparision UTC time * feat: update deactivation_date validation and add tests * refactor: linting Co-authored-by: Kat <katrina@kosiak.co.uk> Co-authored-by: James Rose <james@jbpr.net>pull/1000/head
natdeanlewissoftwire
2 years ago
committed by
GitHub
30 changed files with 611 additions and 120 deletions
@ -0,0 +1,26 @@
|
||||
module SchemesHelper |
||||
def display_scheme_attributes(scheme) |
||||
base_attributes = [ |
||||
{ name: "Scheme code", value: scheme.id_to_display }, |
||||
{ name: "Name", value: scheme.service_name, edit: true }, |
||||
{ name: "Confidential information", value: scheme.sensitive, edit: true }, |
||||
{ name: "Type of scheme", value: scheme.scheme_type }, |
||||
{ name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act }, |
||||
{ name: "Housing stock owned by", value: scheme.owning_organisation.name, edit: true }, |
||||
{ name: "Support services provided by", value: scheme.arrangement_type }, |
||||
{ name: "Organisation providing support", value: scheme.managing_organisation&.name }, |
||||
{ name: "Primary client group", value: scheme.primary_client_group }, |
||||
{ name: "Has another client group", value: scheme.has_other_client_group }, |
||||
{ name: "Secondary client group", value: scheme.secondary_client_group }, |
||||
{ name: "Level of support given", value: scheme.support_type }, |
||||
{ name: "Intended length of stay", value: scheme.intended_stay }, |
||||
{ name: "Availability", value: "Available from #{scheme.available_from.to_formatted_s(:govuk_date)}" }, |
||||
{ name: "Status", value: scheme.status }, |
||||
] |
||||
|
||||
if scheme.arrangement_type_same? |
||||
base_attributes.delete({ name: "Organisation providing support", value: scheme.managing_organisation&.name }) |
||||
end |
||||
base_attributes |
||||
end |
||||
end |
@ -0,0 +1,19 @@
|
||||
<% title = "Deactivate #{@scheme.service_name}" %> |
||||
<% content_for :title, title %> |
||||
<%= form_with model: @scheme, url: scheme_deactivate_path(@scheme), method: "patch", local: true do |f| %> |
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link(href: :back) %> |
||||
<% end %> |
||||
<h1 class="govuk-heading-l"> |
||||
<span class="govuk-caption-l"><%= @scheme.service_name %></span> |
||||
This change will affect <%= @scheme.lettings_logs.count %> logs |
||||
</h1> |
||||
<%= govuk_warning_text text: I18n.t("warnings.scheme.deactivation.review_logs") %> |
||||
<%= f.hidden_field :confirm, value: true %> |
||||
<%= f.hidden_field :deactivation_date, value: @deactivation_date %> |
||||
<%= f.hidden_field :deactivation_date_type, value: @deactivation_date_type %> |
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Deactivate this scheme" %> |
||||
<%= govuk_button_link_to "Cancel", scheme_details_path(@scheme), html: { method: :get }, secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,35 @@
|
||||
<% title = "#{action.humanize} #{@scheme.service_name}" %> |
||||
<% content_for :title, title %> |
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: scheme_details_path(@scheme), |
||||
) %> |
||||
<% end %> |
||||
<%= form_with model: @scheme, url: scheme_new_deactivation_path(@scheme), method: "patch", local: true do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<% collection_start_date = FormHandler.instance.current_collection_start_date %> |
||||
<%= f.govuk_error_summary %> |
||||
<%= f.govuk_radio_buttons_fieldset :deactivation_date_type, |
||||
legend: { text: I18n.t("questions.scheme.deactivation.apply_from") }, |
||||
caption: { text: title }, |
||||
hint: { text: I18n.t("hints.scheme.deactivation", date: collection_start_date.to_formatted_s(:govuk_date)) } do %> |
||||
<%= govuk_warning_text text: I18n.t("warnings.scheme.deactivation.existing_logs") %> |
||||
<%= f.govuk_radio_button :deactivation_date_type, |
||||
"default", |
||||
label: { text: "From the start of the current collection period (#{collection_start_date.to_formatted_s(:govuk_date)})" } %> |
||||
<%= f.govuk_radio_button :deactivation_date_type, |
||||
"other", |
||||
label: { text: "For tenancies starting after a certain date" }, |
||||
**basic_conditional_html_attributes({ "deactivation_date" => %w[other] }, "scheme") do %> |
||||
<%= f.govuk_date_field :deactivation_date, |
||||
legend: { text: "Date", size: "m" }, |
||||
hint: { text: "For example, 27 3 2022" }, |
||||
width: 20 %> |
||||
<% end %> |
||||
<% end %> |
||||
<%= f.govuk_submit "Continue" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,5 @@
|
||||
class AddDeactivationDateToSchemes < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :schemes, :deactivation_date, :datetime |
||||
end |
||||
end |
@ -0,0 +1,27 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe SchemesHelper do |
||||
describe "display_scheme_attributes" do |
||||
let!(:scheme) { FactoryBot.create(:scheme, created_at: Time.zone.local(2022, 8, 8)) } |
||||
|
||||
it "returns correct display attributes" do |
||||
attributes = [ |
||||
{ name: "Scheme code", value: scheme.id_to_display }, |
||||
{ name: "Name", value: scheme.service_name, edit: true }, |
||||
{ name: "Confidential information", value: scheme.sensitive, edit: true }, |
||||
{ name: "Type of scheme", value: scheme.scheme_type }, |
||||
{ name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act }, |
||||
{ name: "Housing stock owned by", value: scheme.owning_organisation.name, edit: true }, |
||||
{ name: "Support services provided by", value: scheme.arrangement_type }, |
||||
{ name: "Primary client group", value: scheme.primary_client_group }, |
||||
{ name: "Has another client group", value: scheme.has_other_client_group }, |
||||
{ name: "Secondary client group", value: scheme.secondary_client_group }, |
||||
{ name: "Level of support given", value: scheme.support_type }, |
||||
{ name: "Intended length of stay", value: scheme.intended_stay }, |
||||
{ name: "Availability", value: "Available from 8 August 2022" }, |
||||
{ name: "Status", value: :active }, |
||||
] |
||||
expect(display_scheme_attributes(scheme)).to eq(attributes) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue