Browse Source
* Filter out empty options from selected filters * Redirect to year filter if it is not selected * Add remaining filter questions * Display lettings filters CYA * Add cancel, conditionally display send email * Refactor * Add removed tests * Update method name * Add sales logs filters * Update tests * Set label size on filter questions * Refactor * Deduplicate filter views * Rename methods * Authenticate pages * Update filtering per organisation * Update routing from CYA * lint * Refactor check_your_answers_filters_list * Redirect if year is not given for sales csv * Update formatted organisations methods * Update missing and wrong copy * Update cancel and back buttons * CLDC-3442 Download logs csv per year (#2404) * Specify year in lettings csv download service * Specify year in sales csv download service * Define non_question_fields per year * Tidy up missing fields and tests * Fix request tests * Refactor * Add missing param * CLDC-3348 Update sales CSV for support (#2407) * Update sales csv for support * CLDC-3352 Update sales CSV address order (#2410) * Update sales support csv address ordering * Refactor * CLDC-3367 Rename sales support CSV fields (#2413) * Rename sales support CSV fields * Update sales CSV user fields order (#2416) * CLDC-2586 Rename scheme sensitive (#2405) * Rename scheme sensitive in lettings csv * Rename scheme sensitive in schemes csv * CLDC-3347 Show soft validations in support CSVs only (#2406) * Show soft validations in support csvs only * CLDC-3352 Update lettings CSV address order (#2409) * Update lettings support csv address ordering * Refactor * CLDC-3415/3421/3422 Add lettings CSV updates (#2415) * Add first_time_property_let_as_social_housing to coordinators csv * Update lettings CSV user fields order * Remove new_old from lettings CSV * Remove duplicate rent value check from CSV (#2423) * Refactor CSV service (#2425) * Extract and move lettings methods * Extract and more sales methodspull/2428/head
kosiakkatrina
8 months ago
committed by
GitHub
56 changed files with 1368 additions and 570 deletions
@ -0,0 +1,64 @@
|
||||
class LettingsLogsFiltersController < ApplicationController |
||||
before_action :lettings_session_filters, if: :current_user |
||||
before_action -> { lettings_filter_manager.serialize_filters_to_session }, if: :current_user |
||||
before_action :authenticate_user! |
||||
|
||||
%w[years status needstype assigned_to owned_by managed_by].each do |filter| |
||||
define_method(filter) do |
||||
@filter_type = "lettings_logs" |
||||
@filter = filter |
||||
render "filters/#{filter}" |
||||
end |
||||
|
||||
define_method("organisation_#{filter}") do |
||||
@organisation_id = params["id"] |
||||
@filter_type = "lettings_logs" |
||||
@filter = filter |
||||
render "filters/#{filter}" |
||||
end |
||||
end |
||||
|
||||
%w[status needstype assigned_to owned_by managed_by].each do |filter| |
||||
define_method("update_#{filter}") do |
||||
@filter_type = "lettings_logs" |
||||
|
||||
redirect_to csv_download_lettings_logs_path(search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
|
||||
define_method("update_organisation_#{filter}") do |
||||
@organisation_id = params["id"] |
||||
@filter_type = "lettings_logs" |
||||
redirect_to lettings_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
|
||||
def update_years |
||||
@filter_type = "lettings_logs" |
||||
if params["years"].nil? |
||||
redirect_to filters_years_lettings_logs_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year") |
||||
else |
||||
redirect_to csv_download_lettings_logs_path(search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
|
||||
def update_organisation_years |
||||
@filter_type = "lettings_logs" |
||||
@organisation_id = params["id"] |
||||
if params["years"].nil? |
||||
redirect_to lettings_logs_filters_years_organisation_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year") |
||||
else |
||||
redirect_to lettings_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def lettings_session_filters |
||||
params["years"] = [params["years"]] if params["years"].present? |
||||
lettings_filter_manager.session_filters |
||||
end |
||||
|
||||
def lettings_filter_manager |
||||
FilterManager.new(current_user:, session:, params:, filter_type: "lettings_logs") |
||||
end |
@ -0,0 +1,65 @@
|
||||
class SalesLogsFiltersController < ApplicationController |
||||
before_action :sales_session_filters, if: :current_user |
||||
before_action -> { sales_filter_manager.serialize_filters_to_session }, if: :current_user |
||||
before_action :authenticate_user! |
||||
|
||||
%w[years status assigned_to owned_by managed_by].each do |filter| |
||||
define_method(filter) do |
||||
@filter_type = "sales_logs" |
||||
@filter = filter |
||||
render "filters/#{filter}" |
||||
end |
||||
|
||||
define_method("organisation_#{filter}") do |
||||
@filter_type = "sales_logs" |
||||
@organisation_id = params["id"] |
||||
@filter = filter |
||||
render "filters/#{filter}" |
||||
end |
||||
end |
||||
|
||||
%w[status assigned_to owned_by managed_by].each do |filter| |
||||
define_method("update_#{filter}") do |
||||
@filter_type = "sales_logs" |
||||
|
||||
redirect_to csv_download_sales_logs_path(search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
|
||||
define_method("update_organisation_#{filter}") do |
||||
@organisation_id = params["id"] |
||||
@filter_type = "sales_logs" |
||||
|
||||
redirect_to sales_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
|
||||
def update_years |
||||
@filter_type = "sales_logs" |
||||
if params["years"].nil? |
||||
redirect_to filters_years_sales_logs_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year") |
||||
else |
||||
redirect_to csv_download_sales_logs_path(search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
|
||||
def update_organisation_years |
||||
@filter_type = "sales_logs" |
||||
@organisation_id = params["id"] |
||||
if params["years"].nil? |
||||
redirect_to sales_logs_filters_years_organisation_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year") |
||||
else |
||||
redirect_to sales_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"]) |
||||
end |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def sales_session_filters |
||||
params["years"] = [params["years"]] if params["years"].present? |
||||
sales_filter_manager.session_filters |
||||
end |
||||
|
||||
def sales_filter_manager |
||||
FilterManager.new(current_user:, session:, params:, filter_type: "sales_logs") |
||||
end |
@ -0,0 +1,31 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<%= render partial: "filters/radio_filter", |
||||
locals: { |
||||
f:, |
||||
options: { |
||||
"all": { label: "Any user" }, |
||||
"you": { label: "You" }, |
||||
"specific_user": { |
||||
label: "Specific user", |
||||
conditional_filter: { |
||||
type: "select", |
||||
label: "User", |
||||
category: "user", |
||||
options: assigned_to_filter_options(current_user), |
||||
}, |
||||
}, |
||||
}, |
||||
label: "Assigned to", |
||||
category: "assigned_to", |
||||
size: "l", |
||||
} %> |
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,30 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<%= render partial: "filters/radio_filter", locals: { |
||||
f:, |
||||
options: { |
||||
"all": { label: "Any managing organisation" }, |
||||
"specific_org": { |
||||
label: "Specific managing organisation", |
||||
conditional_filter: { |
||||
type: "select", |
||||
label: "Managed by", |
||||
category: "managing_organisation", |
||||
options: managing_organisation_filter_options(current_user), |
||||
}, |
||||
}, |
||||
}, |
||||
label: "Managed by", |
||||
category: "managing_organisation_select", |
||||
size: "l", |
||||
} %> |
||||
|
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,20 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<%= render partial: "filters/checkbox_filter", |
||||
locals: { |
||||
f:, |
||||
options: needstype_filters, |
||||
label: "Needs type", |
||||
category: "needstypes", |
||||
size: "l", |
||||
} %> |
||||
|
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,30 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<%= render partial: "filters/radio_filter", locals: { |
||||
f:, |
||||
options: { |
||||
"all": { label: "Any owning organisation" }, |
||||
"specific_org": { |
||||
label: "Specific owning organisation", |
||||
conditional_filter: { |
||||
type: "select", |
||||
label: "Owning Organisation", |
||||
category: "owning_organisation", |
||||
options: owning_organisation_filter_options(current_user), |
||||
}, |
||||
}, |
||||
}, |
||||
label: "Owned by", |
||||
category: "owning_organisation_select", |
||||
size: "l", |
||||
} %> |
||||
|
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,20 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<%= render partial: "filters/checkbox_filter", |
||||
locals: { |
||||
f:, |
||||
options: status_filters, |
||||
label: "Status", |
||||
category: "status", |
||||
size: "l", |
||||
} %> |
||||
|
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,37 @@
|
||||
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %> |
||||
<% if params["error"].present? %> |
||||
<div class="govuk-error-summary" data-module="govuk-error-summary"> |
||||
<div role="alert"> |
||||
<h2 class="govuk-error-summary__title"> |
||||
There is a problem |
||||
</h2> |
||||
<div class="govuk-error-summary__body"> |
||||
<ul class="govuk-list govuk-error-summary__list"> |
||||
<li> |
||||
<a href="#"><%= params["error"] %></a> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
|
||||
<%= render partial: "filters/radio_filter", |
||||
locals: { |
||||
f:, |
||||
options: collection_year_radio_options, |
||||
label: "Which financial year do you want to download data for?", |
||||
category: "years", |
||||
size: "l", |
||||
} %> |
||||
|
||||
<% if request.params["search"].present? %> |
||||
<%= f.hidden_field :search, value: request.params["search"] %> |
||||
<% end %> |
||||
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_button_link_to "Cancel", params["referrer"] == "check_answers" ? cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id) : send("#{@filter_type}_path"), secondary: true %> |
||||
</div> |
||||
<% end %> |
@ -1,16 +1,54 @@
|
||||
<% content_for :title, "Download CSV" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link(href: :back) %> |
||||
<%= govuk_back_link(href: download_csv_back_link) %> |
||||
<% end %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-full"> |
||||
<% if @organisation.present? %> |
||||
<span class="govuk-caption-l"><%= @organisation.name %></span> |
||||
<% end %> |
||||
<h1 class="govuk-heading-l">Download CSV</h1> |
||||
|
||||
<p class="govuk-body">We'll send a secure download link to your email address <strong><%= @current_user.email %></strong>.</p> |
||||
<% if count.positive? %> |
||||
<p class="govuk-body">You've selected <%= count %> logs.</p> |
||||
<% else %> |
||||
<p class="govuk-body">You haven't selected any logs. Please check your filters</p> |
||||
<% end %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-three-quarters-from-desktop"> |
||||
<h1 class="govuk-heading-l"> |
||||
Check your filters |
||||
</h1> |
||||
|
||||
<%= govuk_inset_text(text: "Amending these answers might change the amount of logs selected") %> |
||||
|
||||
<%= govuk_summary_list do |summary_list| %> |
||||
<% check_your_answers_filters_list(session_filters, filter_type).each do |filter| %> |
||||
<% summary_list.with_row do |row| %> |
||||
<% row.with_key { filter[:label] } %> |
||||
<% row.with_value do %> |
||||
<%= simple_format( |
||||
filter[:value], |
||||
wrapper_tag: "span", |
||||
class: "govuk-!-margin-right-4", |
||||
) %> |
||||
<% end %> |
||||
|
||||
<% row.with_action( |
||||
text: "Change", |
||||
href: change_filter_for_csv_url(filter, filter_type, search_term, codes_only, params["id"]), |
||||
) %> |
||||
<% end %> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
<% if count.positive? %> |
||||
<%= govuk_button_to "Send email", post_path, method: :post, params: { search: search_term, codes_only: } %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Loading…
Reference in new issue