Manny Dinssa
3 weeks ago
135 changed files with 2118 additions and 1592 deletions
@ -0,0 +1,68 @@
|
||||
class TestDataController < ApplicationController |
||||
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found |
||||
|
||||
def create_test_lettings_log |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
log = FactoryBot.create(:lettings_log, :completed, assigned_to: current_user, ppostcode_full: "SW1A 1AA") |
||||
redirect_to lettings_log_path(log) |
||||
end |
||||
|
||||
def create_setup_test_lettings_log |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
log = FactoryBot.create(:lettings_log, :setup_completed, assigned_to: current_user) |
||||
redirect_to lettings_log_path(log) |
||||
end |
||||
|
||||
def create_2024_test_lettings_bulk_upload |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
file = Tempfile.new("test_lettings_log.csv") |
||||
log = FactoryBot.create(:lettings_log, :completed, assigned_to: current_user, ppostcode_full: "SW1A 1AA") |
||||
log_to_csv = BulkUpload::LettingsLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" }) |
||||
file.write(log_to_csv.default_field_numbers_row) |
||||
file.write(log_to_csv.to_csv_row) |
||||
file.rewind |
||||
send_file file.path, type: "text/csv", |
||||
filename: "test_lettings_log.csv", |
||||
disposition: "attachment", |
||||
after_send: lambda { |
||||
file.close |
||||
file.unlink |
||||
} |
||||
end |
||||
|
||||
def create_test_sales_log |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
log = FactoryBot.create(:sales_log, :completed, assigned_to: current_user) |
||||
redirect_to sales_log_path(log) |
||||
end |
||||
|
||||
def create_setup_test_sales_log |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
log = FactoryBot.create(:sales_log, :shared_ownership_setup_complete, assigned_to: current_user) |
||||
redirect_to sales_log_path(log) |
||||
end |
||||
|
||||
def create_2024_test_sales_bulk_upload |
||||
return render_not_found unless FeatureToggle.create_test_logs_enabled? |
||||
|
||||
file = Tempfile.new("test_sales_log.csv") |
||||
|
||||
log = FactoryBot.create(:sales_log, :completed, assigned_to: current_user, value: 180_000, deposit: 150_000) |
||||
log_to_csv = BulkUpload::SalesLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" }) |
||||
file.write(log_to_csv.default_field_numbers_row) |
||||
file.write(log_to_csv.to_csv_row) |
||||
file.rewind |
||||
send_file file.path, type: "text/csv", |
||||
filename: "test_sales_log.csv", |
||||
disposition: "attachment", |
||||
after_send: lambda { |
||||
file.close |
||||
file.unlink |
||||
} |
||||
end |
||||
end |
@ -0,0 +1,34 @@
|
||||
.rails-admin-sidescroll { |
||||
overflow-x: scroll; |
||||
} |
||||
|
||||
.rails-admin-description_field { |
||||
min-width: 500px; |
||||
} |
||||
|
||||
.rails-admin-case_field { |
||||
min-width: 500px; |
||||
} |
||||
|
||||
.rails-admin-error_message_field { |
||||
min-width: 500px; |
||||
} |
||||
|
||||
.rails-admin-actions { |
||||
min-width: 160px; |
||||
|
||||
ul { |
||||
float: right; |
||||
} |
||||
} |
||||
|
||||
.rails-admin-filters-box { |
||||
.filter { |
||||
// stylelint-disable-next-line declaration-no-important |
||||
display: flex !important; |
||||
} |
||||
|
||||
button { |
||||
min-width: 20%; |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
class Form::Lettings::Pages::PersonLeadPartner < ::Form::Page |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super(id, hsh, subsection) |
||||
@id = "person_#{person_index}_lead_partner" |
||||
@depends_on = [{ "details_known_#{person_index}" => 0 }] |
||||
@person_index = person_index |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::PersonPartner.new(nil, nil, self, person_index: @person_index)] |
||||
end |
||||
end |
@ -0,0 +1,30 @@
|
||||
class Form::Lettings::Questions::PersonPartner < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "relat#{person_index}" |
||||
@type = "radio" |
||||
@check_answers_card_number = person_index |
||||
@answer_options = answer_options |
||||
@person_index = person_index |
||||
@question_number = question_number |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"P" => { "value" => "Yes" }, |
||||
"X" => { "value" => "No" }, |
||||
"R" => { "value" => "Tenant prefers not to say" }, |
||||
} |
||||
end |
||||
|
||||
def question_number |
||||
base_question_number = case form.start_date.year |
||||
when 2023 |
||||
30 |
||||
else |
||||
29 |
||||
end |
||||
|
||||
base_question_number + (4 * @person_index) |
||||
end |
||||
end |
@ -1,22 +1,23 @@
|
||||
module Forms |
||||
module BulkUploadLettings |
||||
module BulkUploadForm |
||||
class CheckingFile |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :log_type |
||||
attribute :year, :integer |
||||
attribute :organisation_id, :integer |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_logs/forms/checking_file" |
||||
"bulk_upload_#{log_type}_logs/forms/checking_file" |
||||
end |
||||
|
||||
def back_path |
||||
if organisation_id.present? |
||||
lettings_logs_organisation_path(organisation_id) |
||||
send("#{log_type}_logs_organisation_path", organisation_id) |
||||
else |
||||
bulk_upload_lettings_log_path(id: "start") |
||||
send("bulk_upload_#{log_type}_log_path", id: "start") |
||||
end |
||||
end |
||||
|
@ -1,60 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettings |
||||
class PrepareYourFile |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :year, :integer |
||||
attribute :needstype, :integer |
||||
attribute :organisation_id, :integer |
||||
|
||||
def view_path |
||||
case year |
||||
when 2023 |
||||
"bulk_upload_lettings_logs/forms/prepare_your_file_2023" |
||||
when 2024 |
||||
"bulk_upload_lettings_logs/forms/prepare_your_file_2024" |
||||
end |
||||
end |
||||
|
||||
def back_path |
||||
if have_choice_of_year? |
||||
Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year:, organisation_id: }.compact) |
||||
elsif organisation_id.present? |
||||
lettings_logs_organisation_path(organisation_id) |
||||
else |
||||
Rails.application.routes.url_helpers.lettings_logs_path |
||||
end |
||||
end |
||||
|
||||
def next_path |
||||
bulk_upload_lettings_log_path(id: "upload-your-file", form: { year:, needstype:, organisation_id: }.compact) |
||||
end |
||||
|
||||
def template_path |
||||
download_mandatory_collection_resource_path(year:, log_type: "lettings", resource_type: "bulk_upload_template") |
||||
end |
||||
|
||||
def specification_path |
||||
download_mandatory_collection_resource_path(year:, log_type: "lettings", resource_type: "bulk_upload_specification") |
||||
end |
||||
|
||||
def year_combo |
||||
"#{year} to #{year + 1}" |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
private |
||||
|
||||
def have_choice_of_year? |
||||
return true if FeatureToggle.allow_future_form_use? |
||||
|
||||
FormHandler.instance.lettings_in_crossover_period? |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,55 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
class Confirm |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_resume/confirm" |
||||
end |
||||
|
||||
def back_path |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, page: "fix-choice") |
||||
end |
||||
|
||||
def next_path |
||||
resume_bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
|
||||
def error_report_path |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
summary_bulk_upload_lettings_result_path(bulk_upload) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
ApplicationRecord.transaction do |
||||
processor = BulkUpload::Processor.new(bulk_upload:) |
||||
processor.approve |
||||
|
||||
bulk_upload.update!(choice: "create-fix-inline") |
||||
end |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "create-fix-inline" && bulk_upload.choice != "bulk-confirm-soft-validations" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,28 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
class DeletionReport |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_resume/deletion_report" |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "create-fix-inline" && bulk_upload.choice != "bulk-confirm-soft-validations" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,74 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
class FixChoice |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
attribute :choice, :string |
||||
|
||||
validates :choice, presence: true, |
||||
inclusion: { in: %w[create-fix-inline upload-again] } |
||||
|
||||
def options |
||||
[ |
||||
OpenStruct.new(id: "create-fix-inline", name: "Upload these logs and fix errors on CORE site"), |
||||
OpenStruct.new(id: "upload-again", name: "Fix errors in the CSV and upload the file again"), |
||||
] |
||||
end |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_resume/fix_choice" |
||||
end |
||||
|
||||
def next_path |
||||
case choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, page: "confirm") |
||||
when "upload-again" |
||||
error_report_path |
||||
else |
||||
raise "invalid choice" |
||||
end |
||||
end |
||||
|
||||
def error_report_path |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
summary_bulk_upload_lettings_result_path(bulk_upload) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
|
||||
def recommendation |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
"We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site." |
||||
else |
||||
"We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV." |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
bulk_upload.update!(choice:) if choice == "upload-again" |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice.blank? |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsSoftValidationsCheck |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_soft_validations_check/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
lettings_logs_path |
||||
end |
||||
|
||||
def next_path |
||||
lettings_logs_path |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
true |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,22 +1,23 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
module BulkUploadResume |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :log_type |
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
bulk_upload.completed? ? "bulk_upload_lettings_resume/completed" : "bulk_upload_lettings_resume/chosen" |
||||
bulk_upload.completed? ? "bulk_upload_#{log_type}_resume/completed" : "bulk_upload_#{log_type}_resume/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
lettings_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def next_path |
||||
lettings_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def save! |
@ -1,32 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSales |
||||
class CheckingFile |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :year, :integer |
||||
attribute :organisation_id, :integer |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_logs/forms/checking_file" |
||||
end |
||||
|
||||
def back_path |
||||
if organisation_id.present? |
||||
sales_logs_organisation_path(organisation_id) |
||||
else |
||||
bulk_upload_sales_log_path(id: "start") |
||||
end |
||||
end |
||||
|
||||
def year_combo |
||||
"#{year} to #{year + 1}" |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,51 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSales |
||||
class Guidance |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
include CollectionTimeHelper |
||||
|
||||
attribute :year, :integer |
||||
attribute :referrer |
||||
attribute :organisation_id, :integer |
||||
|
||||
def initialize(params) |
||||
super(params) |
||||
|
||||
self.year = current_collection_start_year if year.nil? |
||||
end |
||||
|
||||
def view_path |
||||
"bulk_upload_shared/guidance" |
||||
end |
||||
|
||||
def back_path |
||||
case referrer |
||||
when "prepare-your-file" |
||||
bulk_upload_sales_log_path(id: "prepare-your-file", form: { year:, organisation_id: }.compact) |
||||
when "home" |
||||
root_path |
||||
else |
||||
guidance_path |
||||
end |
||||
end |
||||
|
||||
def lettings_template_path |
||||
Forms::BulkUploadLettings::PrepareYourFile.new(year:).template_path |
||||
end |
||||
|
||||
def lettings_specification_path |
||||
Forms::BulkUploadLettings::PrepareYourFile.new(year:).specification_path |
||||
end |
||||
|
||||
def sales_template_path |
||||
Forms::BulkUploadSales::PrepareYourFile.new(year:).template_path |
||||
end |
||||
|
||||
def sales_specification_path |
||||
Forms::BulkUploadSales::PrepareYourFile.new(year:).specification_path |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,83 +0,0 @@
|
||||
require "shellwords" |
||||
|
||||
module Forms |
||||
module BulkUploadSales |
||||
class UploadYourFile |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :year, :integer |
||||
attribute :file |
||||
attribute :current_user |
||||
attribute :organisation_id, :integer |
||||
|
||||
validates :file, presence: true |
||||
validate :validate_file_is_csv |
||||
validate :validate_file_size |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_logs/forms/upload_your_file" |
||||
end |
||||
|
||||
def back_path |
||||
bulk_upload_sales_log_path(id: "prepare-your-file", form: { year:, organisation_id: }.compact) |
||||
end |
||||
|
||||
def year_combo |
||||
"#{year} to #{year + 1}" |
||||
end |
||||
|
||||
def next_path |
||||
bulk_upload_sales_log_path(id: "checking-file", form: { year:, organisation_id: }.compact) |
||||
end |
||||
|
||||
def save! |
||||
bulk_upload = BulkUpload.create!( |
||||
user: current_user, |
||||
log_type: BulkUpload.log_types[:sales], |
||||
year:, |
||||
filename: file.original_filename, |
||||
organisation_id: (organisation_id if current_user.support?) || current_user.organisation_id, |
||||
) |
||||
|
||||
storage_service.write_file(bulk_upload.identifier, File.read(file.path)) |
||||
|
||||
ProcessBulkUploadJob.perform_later(bulk_upload:) |
||||
|
||||
true |
||||
end |
||||
|
||||
private |
||||
|
||||
def storage_service |
||||
@storage_service ||= if FeatureToggle.upload_enabled? |
||||
Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) |
||||
else |
||||
Storage::LocalDiskService.new |
||||
end |
||||
end |
||||
|
||||
def validate_file_is_csv |
||||
return unless file |
||||
|
||||
argv = %W[file --brief --mime-type -- #{file.path}] |
||||
output = `#{argv.shelljoin}` |
||||
|
||||
unless output.match?(/text\/csv|text\/plain/) |
||||
errors.add(:file, :not_csv) |
||||
end |
||||
end |
||||
|
||||
MAX_FILE_SIZE = 10.megabytes |
||||
|
||||
def validate_file_size |
||||
return unless file |
||||
|
||||
if file.size > MAX_FILE_SIZE |
||||
errors.add(:file, :file_too_large) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,50 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSales |
||||
class Year |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :year, :integer |
||||
attribute :organisation_id, :integer |
||||
|
||||
validates :year, presence: true |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_logs/forms/year" |
||||
end |
||||
|
||||
def options |
||||
possible_years.map do |year| |
||||
OpenStruct.new(id: year, name: "#{year} to #{year + 1}") |
||||
end |
||||
end |
||||
|
||||
def back_path |
||||
if organisation_id.present? |
||||
sales_logs_organisation_path(organisation_id) |
||||
else |
||||
sales_logs_path |
||||
end |
||||
end |
||||
|
||||
def next_path |
||||
bulk_upload_sales_log_path(id: "prepare-your-file", form: { year:, organisation_id: }.compact) |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
private |
||||
|
||||
def possible_years |
||||
[ |
||||
FormHandler.instance.current_sales_form.start_date.year, |
||||
(FormHandler.instance.previous_sales_form.start_date.year if FormHandler.instance.sales_in_crossover_period?), |
||||
(FormHandler.instance.next_sales_form.start_date.year if FeatureToggle.allow_future_form_use?), |
||||
].compact |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesSoftValidationsCheck |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_soft_validations_check/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
sales_logs_path |
||||
end |
||||
|
||||
def next_path |
||||
sales_logs_path |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
true |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,47 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesSoftValidationsCheck |
||||
class Confirm |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_soft_validations_check/confirm" |
||||
end |
||||
|
||||
def back_path |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, page: "confirm-soft-errors") |
||||
end |
||||
|
||||
def next_path |
||||
sales_logs_path |
||||
end |
||||
|
||||
def save! |
||||
ApplicationRecord.transaction do |
||||
processor = BulkUpload::Processor.new(bulk_upload:) |
||||
processor.approve_and_confirm_soft_validations |
||||
|
||||
bulk_upload.update!(choice: "bulk-confirm-soft-validations") |
||||
end |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "bulk-confirm-soft-validations" && bulk_upload.choice != "create-fix-inline" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, :chosen) |
||||
when "create-fix-inline" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,53 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesSoftValidationsCheck |
||||
class ConfirmSoftErrors |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
attribute :confirm_soft_errors, :string |
||||
|
||||
validates :confirm_soft_errors, presence: true |
||||
|
||||
def options |
||||
[ |
||||
OpenStruct.new(id: "yes", name: "Yes, these fields are correct"), |
||||
OpenStruct.new(id: "no", name: "No, there are errors"), |
||||
] |
||||
end |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_soft_validations_check/confirm_soft_errors" |
||||
end |
||||
|
||||
def next_path |
||||
case confirm_soft_errors |
||||
when "no" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, page: "fix-choice", soft_errors_only: true) |
||||
when "yes" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, page: "confirm") |
||||
else |
||||
raise "invalid choice" |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "bulk-confirm-soft-validations" && bulk_upload.choice != "create-fix-inline" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, :chosen) |
||||
when "create-fix-inline" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,22 +1,23 @@
|
||||
module Forms |
||||
module BulkUploadSalesResume |
||||
module BulkUploadSoftValidationsCheck |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :log_type |
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
bulk_upload.completed? ? "bulk_upload_sales_resume/completed" : "bulk_upload_sales_resume/chosen" |
||||
"bulk_upload_#{log_type}_soft_validations_check/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
sales_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def next_path |
||||
sales_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def save! |
@ -1,46 +0,0 @@
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link href: @form.back_path %> |
||||
<% end %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "prepare-your-file"), method: :patch do |f| %> |
||||
<%= f.hidden_field :year %> |
||||
|
||||
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span> |
||||
<h1 class="govuk-heading-l">Prepare your file</h1> |
||||
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p> |
||||
|
||||
<h2 class="govuk-heading-s">Download template</h2> |
||||
|
||||
<p class="govuk-body govuk-!-margin-bottom-2">Use one of these templates to upload logs for 2023/24:</p> |
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li> |
||||
<%= govuk_link_to "Download the new template", @form.template_path %>: In this template, the questions are in the same order as the 2023/24 paper form and web form. |
||||
</li> |
||||
</ul> |
||||
<p class="govuk-body govuk-!-margin-bottom-2">There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.</p> |
||||
|
||||
<h2 class="govuk-heading-s">Create your file</h2> |
||||
|
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li>Fill in the template with data from your housing management system. Your data should go below the headers, with one row per log. Leave column A blank - the bulk upload fields start in column B.</li> |
||||
<li>Make sure each column of your data aligns with the matching headers above. You may need to reorder your data.</li> |
||||
<li>Use the <%= govuk_link_to "Lettings #{@form.year_combo} Bulk Upload Specification", @form.specification_path %> to check your data is in the correct format.</li> |
||||
<li><strong>Username field:</strong> To assign a log to someone else, enter the email address they use to log into CORE.</li> |
||||
<li>If you are using the new template, keep the headers. If you are using the legacy template, you can either keep or remove the headers. If you remove the headers, you should also remove the blank column A.</li> |
||||
</ul> |
||||
|
||||
<%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023 to 2024 data.") %> |
||||
|
||||
<h2 class="govuk-heading-s">Save your file</h2> |
||||
|
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li>Save your file as a CSV.</li> |
||||
<li>Your file should now be ready to upload.</li> |
||||
</ul> |
||||
|
||||
<%= f.govuk_submit class: "govuk-!-margin-top-7" %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
@ -1,40 +0,0 @@
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link href: @form.back_path %> |
||||
<% end %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "prepare-your-file"), method: :patch do |f| %> |
||||
<%= f.hidden_field :year %> |
||||
|
||||
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span> |
||||
<h1 class="govuk-heading-l">Prepare your file</h1> |
||||
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p> |
||||
|
||||
<h2 class="govuk-heading-s">Download template</h2> |
||||
|
||||
<p class="govuk-body govuk-!-margin-bottom-2">Use one of these templates to upload logs for 2023/24:</p> |
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li><%= govuk_link_to "Download the new template", @form.template_path %>: In this template, the questions are in the same order as the 2023/24 paper form and web form.</li> |
||||
</ul> |
||||
<p class="govuk-body govuk-!-margin-bottom-2">There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.</p> |
||||
|
||||
<h2 class="govuk-heading-s">Create your file</h2> |
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li>Fill in the template with data from your housing management system. Your data should go below the headers, with one row per log. The bulk upload fields start at column B. Leave column A blank.</li> |
||||
<li>Make sure each column of your data aligns with the matching headers above. You may need to reorder your data.</li> |
||||
<li>Use the <%= govuk_link_to "Sales #{@form.year_combo} Bulk Upload Specification", @form.specification_path %> to check your data is in the correct format.</li> |
||||
<li><strong>Username field:</strong> To assign a log to someone else, enter the email address they use to log into CORE.</li> |
||||
<li>If you are using the new template, keep the headers. If you are using the legacy template, you can either keep or remove the headers. If you remove the headers, you should also remove the blank column A.</li> |
||||
</ul> |
||||
|
||||
<h2 class="govuk-heading-s">Save your file</h2> |
||||
<ul class="govuk-list govuk-list--bullet"> |
||||
<li>Save your file as a CSV.</li> |
||||
<li>Your file should now be ready to upload.</li> |
||||
</ul> |
||||
|
||||
<%= f.govuk_submit %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
@ -0,0 +1,9 @@
|
||||
<%= govuk_header( |
||||
classes: "app-header app-header--orange", |
||||
homepage_url: Rails.application.routes.url_helpers.root_path, |
||||
navigation_classes: "govuk-header__navigation--end", |
||||
) do |component| |
||||
component.with_product_name(name: t("service_name")) |
||||
component.with_navigation_item(text: "Your account", href: Rails.application.routes.url_helpers.account_path) |
||||
component.with_navigation_item(text: "Sign out", href: Rails.application.routes.url_helpers.destroy_user_session_path) |
||||
end %> |
@ -0,0 +1,70 @@
|
||||
</html><!DOCTYPE html> |
||||
<html lang="en" class="govuk-template"> |
||||
<head> |
||||
<title>Admin</title> |
||||
<%= csrf_meta_tags %> |
||||
<%= csp_meta_tag %> |
||||
<%= tag.meta name: "viewport", content: "width=device-width, initial-scale=1" %> |
||||
<%= tag.meta property: "og:image", content: asset_path("images/govuk-opengraph-image.png") %> |
||||
<%= tag.meta name: "theme-color", content: "#0b0c0c" %> |
||||
<%= favicon_link_tag asset_path("images/favicon.ico"), type: nil, sizes: "48x48" %> |
||||
<%= favicon_link_tag asset_path("images/favicon.svg"), type: "image/svg+xml", sizes: "any" %> |
||||
<%= favicon_link_tag asset_path("images/govuk-icon-mask.svg"), rel: "mask-icon", color: "#0b0c0c", type: nil %> |
||||
<%= favicon_link_tag asset_path("images/govuk-icon-180.png"), rel: "apple-touch-icon", type: nil %> |
||||
<%= stylesheet_link_tag "application" %> |
||||
<%= javascript_include_tag "vendor/html5shiv.min.js" %> |
||||
<script> |
||||
window.html5.elements = "output"; |
||||
html5.shivDocument(document); |
||||
</script> |
||||
<%= javascript_include_tag "vendor/polyfill-output-value.js" %> |
||||
<%= javascript_include_tag "vendor/outerHTML.js" %> |
||||
<%= javascript_include_tag "application", defer: true %> |
||||
|
||||
<% if content_for?(:head) %> |
||||
<%= yield(:head) %> |
||||
<% end %> |
||||
<%= capybara_lockstep if defined?(Capybara::Lockstep) %> |
||||
|
||||
<% if Rails.env.development? %> |
||||
<script> |
||||
console.log(<%= session.to_json.html_safe %>) |
||||
</script> |
||||
<% end %> |
||||
<%= render "layouts/rails_admin/head" %> |
||||
</head> |
||||
|
||||
<body class="govuk-template__body app-template--wide"> |
||||
<script> |
||||
document.body.className += " js-enabled" + ("noModule" in HTMLScriptElement.prototype ? " govuk-frontend-supported" : ""); |
||||
</script> |
||||
<div data-i18n-options="<%= I18n.t("admin.js").to_json %>" id="admin-js"></div> |
||||
<div class="badge bg-warning" id="loading" style="display:none; position:fixed; right:20px; bottom:20px; z-index:100000"> |
||||
<%= t("admin.loading") %> |
||||
</div> |
||||
|
||||
<%= govuk_skip_link %> |
||||
|
||||
<%= render "layouts/rails_admin/navigation" %> |
||||
|
||||
<% feedback_link = govuk_link_to "giving us your feedback (opens in a new tab)", t("feedback_form"), rel: "noreferrer noopener", target: "_blank" %> |
||||
|
||||
<%= govuk_phase_banner( |
||||
classes: "#{current_user.present? ? 'no-bottom-border ' : ''}govuk-width-container", |
||||
tag: { colour: "orange", text: "Support beta" }, |
||||
text: "This is a new service – help us improve it by #{feedback_link}".html_safe, |
||||
) %> |
||||
|
||||
<div class="govuk-width-container"> |
||||
<main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main"> |
||||
<%= render template: "layouts/rails_admin/content" %> |
||||
</main> |
||||
</div> |
||||
<%= render partial: "layouts/feedback" %> |
||||
<%= render partial: "layouts/footer", locals: { |
||||
accessibility_statement_path: Rails.application.routes.url_helpers.accessibility_statement_path, |
||||
privacy_notice_path: Rails.application.routes.url_helpers.privacy_notice_path, |
||||
cookies_path: Rails.application.routes.url_helpers.cookies_path, |
||||
} %> |
||||
</body> |
||||
</html> |
@ -0,0 +1,25 @@
|
||||
<div class="form-actions row justify-content-end my-3"> |
||||
<div class="col-sm-10"> |
||||
<input name="return_to" type="<%= :hidden %>" value="<%= (params[:return_to].presence || request.referer) %>"> |
||||
<button class="govuk-button" data-disable-with="<%= t("admin.form.save") %>" name="_save" type="submit"<%= " disabled" unless @action.enabled? %>> |
||||
<i class="fas fa-check"></i> |
||||
<%= t("admin.form.save") %> |
||||
</button> |
||||
<span class="extra_buttons"> |
||||
<% if @action.enabled? && authorized?(:new, @abstract_model) %> |
||||
<button class="govuk-button govuk-button--secondary" data-disable-with="<%= t("admin.form.save_and_add_another") %>" name="_add_another" type="submit"> |
||||
<%= t("admin.form.save_and_add_another") %> |
||||
</button> |
||||
<% end %> |
||||
<% if @action.enabled? && authorized?(:edit, @abstract_model) %> |
||||
<button class="govuk-button govuk-button--secondary" data-disable-with="<%= t("admin.form.save_and_edit") %>" name="_add_edit" type="submit"<%= " disabled" unless @action.enabled? %>> |
||||
<%= t("admin.form.save_and_edit") %> |
||||
</button> |
||||
<% end %> |
||||
<button class="govuk-button govuk-button--secondary" data-disable-with="<%= t("admin.form.cancel") %>" formnovalidate="<%= true %>" name="_continue" type="submit"> |
||||
<i class="fas fa-times"></i> |
||||
<%= t("admin.form.cancel") %> |
||||
</button> |
||||
</span> |
||||
</div> |
||||
</div> |
@ -0,0 +1,68 @@
|
||||
<% if @abstract_models %> |
||||
<table class="table table-condensed table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th class="shrink model-name"> |
||||
<%= t "admin.table_headers.model_name" %> |
||||
</th> |
||||
<th class="shrink last-created"> |
||||
<%= t "admin.table_headers.last_created" %> |
||||
</th> |
||||
<th class="records"> |
||||
<%= t "admin.table_headers.records" %> |
||||
</th> |
||||
<th class="shrink controls"></th> |
||||
</tr> |
||||
</thead> |
||||
<tbody class="table-group-divider"> |
||||
<% @abstract_models.each do |abstract_model| %> |
||||
<% if authorized? :index, abstract_model %> |
||||
<% index_path = index_path(model_name: abstract_model.to_param) %> |
||||
<% row_class = "#{cycle('odd', 'even')}#{' link' if index_path} #{abstract_model.param_key}_links" %> |
||||
<tr class="<%= row_class %>" data-link="<%= index_path %>"> |
||||
<% last_created = @most_recent_created[abstract_model.model.name] %> |
||||
<% active = last_created.try(:today?) %> |
||||
<td> |
||||
<span class="show"> |
||||
<%= link_to abstract_model.config.label_plural, index_path %> |
||||
</span> |
||||
</td> |
||||
<td> |
||||
<% if last_created %> |
||||
<%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t('admin.misc.ago')}" %> |
||||
<% end %> |
||||
</td> |
||||
<td> |
||||
<% count = @count[abstract_model.model.name] %> |
||||
<% percent = if count.positive? |
||||
@max <= 1 ? count : ((Math.log(count + 1) * 100.0) / Math.log(@max + 1)).to_i |
||||
else |
||||
-1 |
||||
end %> |
||||
<div class="<%= active ? "active progress-bar-striped " : "" %>progress" style="margin-bottom:0px"> |
||||
<div class="bg-<%= get_indicator(percent) %> progress-bar animate-width-to" data-animate-length="<%= ([1.0, percent].max.to_i * 20) %>" data-animate-width-to="<%= [2.0, percent].max.to_i %>%" style="width:2%"> |
||||
<%= @count[abstract_model.model.name] %> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
<td class="last links rails-admin-actions"> |
||||
<ul class="nav list-inline"> |
||||
<%= menu_for :collection, abstract_model, nil, true %> |
||||
</ul> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
<% end %> |
||||
<% if @history && authorized?(:history_index) %> |
||||
<div class="block" id="block-tables"> |
||||
<div class="content"> |
||||
<h2> |
||||
<%= t("admin.actions.history_index.menu") %> |
||||
</h2> |
||||
<%= render partial: "rails_admin/main/dashboard_history" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,21 @@
|
||||
<h4> |
||||
<%= t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase) %> |
||||
<q><strong><%= @model_config.with(object: @object).object_label %></strong></q> |
||||
<%= t("admin.form.all_of_the_following_related_items_will_be_deleted") %> |
||||
</h4> |
||||
<ul> |
||||
<%= render partial: "delete_notice", object: @object %> |
||||
</ul> |
||||
<%= form_for(@object, url: delete_path(model_name: @abstract_model.to_param, id: @object.id), html: { method: "delete" }) do %> |
||||
<input name="return_to" type="<%= :hidden %>" value="<%= (params[:return_to].presence || request.referer) %>"> |
||||
<div class="form-actions"> |
||||
<button class="govuk-button govuk-button--warning" data-disable-with="<%= t("admin.form.confirmation") %>" type="submit"> |
||||
<i class="fas fa-check"></i> |
||||
<%= t("admin.form.confirmation") %> |
||||
</button> |
||||
<button class="govuk-button" data-disable-with="<%= t("admin.form.cancel") %>" name="_continue" type="submit"> |
||||
<i class="fas fa-times"></i> |
||||
<%= t("admin.form.cancel") %> |
||||
</button> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,187 @@
|
||||
<% query = params[:query] %> |
||||
<% params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export) %> |
||||
<% params.delete(:query) if params[:query].blank? %> |
||||
<% params.delete(:sort_reverse) unless params[:sort_reverse] == "true" %> |
||||
<% sort_reverse = params[:sort_reverse] %> |
||||
<% sort = params[:sort] %> |
||||
<% params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s %> |
||||
<% export_action = RailsAdmin::Config::Actions.find(:export, { controller:, abstract_model: @abstract_model }) %> |
||||
<% export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) %> |
||||
<% description = RailsAdmin.config(@abstract_model.model_name).description %> |
||||
<% properties = @model_config.list.with(controller:, view: self, object: @abstract_model.model.new).fields_for_table %> |
||||
<% checkboxes = @model_config.list.checkboxes? %> |
||||
<% table_table_header_count = begin |
||||
count = checkboxes ? 1 : 0 |
||||
count += properties.count |
||||
end %> |
||||
|
||||
<% content_for :contextual_tabs do %> |
||||
<% if filterable_fields.present? %> |
||||
<li class="nav-item dropdown"> |
||||
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#"> |
||||
<%= t("admin.misc.add_filter") %> |
||||
<b class="caret"></b> |
||||
</a> |
||||
<ul class="dropdown-menu dropdown-menu-end" id="filters"> |
||||
<% filterable_fields.each do |field| %> |
||||
<li> |
||||
<a |
||||
href="#" |
||||
class="dropdown-item" |
||||
data-options="<%= field.with(view: self).filter_options.to_json %>"> |
||||
<%= field.label %> |
||||
</a> |
||||
</li> |
||||
<% end %> |
||||
</ul> |
||||
</li> |
||||
<% end %> |
||||
<% if checkboxes %> |
||||
<%= bulk_menu %> |
||||
<% end %> |
||||
<% end %> |
||||
|
||||
<style> |
||||
<% properties.select { |p| p.column_width.present? }.each do |property| %> |
||||
<%= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }" %> |
||||
<%= "#list td.#{property.css_class} { max-width: #{property.column_width}px;}" %> |
||||
<% end %> |
||||
</style> |
||||
|
||||
<div id="list"> |
||||
<%= form_tag(index_path(params.except(*%w[page f query])), method: :get) do %> |
||||
<div class="card mb-3 p-3 bg-light"> |
||||
<div class="row rails-admin-filters-box" data-options="<%= ordered_filter_options.to_json %>" id="filters_box"></div> |
||||
<hr class="filters_box" style="display:<%= ordered_filters.empty? ? "none" : "block" %>"> |
||||
<div class="row"> |
||||
<div class="col-sm-8"> |
||||
<div class="input-group"> |
||||
<input class="govuk-input govuk-input--width-20" name="query" placeholder="<%= t("admin.misc.filter") %>" type="search" value="<%= query %>" autocomplete="off"> |
||||
<div class="govuk-!-margin-left-2"> |
||||
<button class="govuk-button govuk-!-margin-bottom-0" data-disable-with="<%= "<i class=\"fas fa-sync\"></i>#{t('admin.misc.refresh')}" %>" type="submit"> |
||||
<i class="fas fa-sync"></i> |
||||
<%= t("admin.misc.refresh") %> |
||||
</button> |
||||
</div> |
||||
<div id="remove_filter" title="<%= t("admin.misc.reset_filters") %>"> |
||||
<button class="govuk-button govuk-button--secondary govuk-!-margin-bottom-0"> |
||||
<i class="fas fa-times"></i> |
||||
</button> |
||||
</div> |
||||
</div> |
||||
<% if @model_config.list.search_help.present? %> |
||||
<div class="form-text"><%= @model_config.list.search_help %></div> |
||||
<% end %> |
||||
</div> |
||||
<div class="col-sm-4 text-end"> |
||||
<% if export_action %> |
||||
<%= govuk_button_link_to wording_for(:link, export_action), export_path(params.except("page")), class: "govuk-!-margin-bottom-0" %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
<% unless @model_config.list.scopes.empty? %> |
||||
<ul class="nav nav-tabs" id="scope_selector"> |
||||
<% @model_config.list.scopes.each_with_index do |scope, index| %> |
||||
<% scope = "_all" if scope.nil? %> |
||||
<li class="nav-item"> |
||||
<a href="<%= index_path(params.merge(scope:, page: nil)) %>" class="nav-link <%= "active" if scope.to_s == params[:scope] || (params[:scope].blank? && index.zero?) %>"> |
||||
<%= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) %> |
||||
</a> |
||||
</li> |
||||
<% end %> |
||||
</ul> |
||||
<% end %> |
||||
<%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: %w[form mb-3] do %> |
||||
<%= hidden_field_tag :bulk_action %> |
||||
<% if description.present? %> |
||||
<p> |
||||
<strong> |
||||
<%= description %> |
||||
</strong> |
||||
</p> |
||||
<% end %> |
||||
<div id="sidescroll" class="rails-admin-sidescroll"> |
||||
<table class="table table-condensed table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<% if checkboxes %> |
||||
<th class="shrink sticky"> |
||||
<input class="toggle" type="checkbox"> |
||||
</th> |
||||
<% end %> |
||||
<% properties.each do |property| %> |
||||
<% selected = (sort == property.name.to_s) %> |
||||
<% if property.sortable %> |
||||
<% sort_location = index_path params.except("sort_reverse").except("page").merge(sort: property.name).merge(selected && sort_reverse != "true" ? { sort_reverse: "true" } : {}) %> |
||||
<% sort_direction = (if selected |
||||
sort_reverse == "true" ? "headerSortUp" : "headerSortDown" |
||||
end) %> |
||||
<% end %> |
||||
<th class="<%= [property.sortable && "header", property.sortable && sort_direction, property.sticky? && "sticky", property.css_class, property.type_css_class].select(&:present?).join(" ") %>" data-href="<%= property.sortable && sort_location %>" rel="tooltip" title="<%= property.hint %>"> |
||||
<%= property.label %> |
||||
</th> |
||||
<% end %> |
||||
<th class="last shrink"></th> |
||||
</tr> |
||||
</thead> |
||||
<tbody class="table-group-divider"> |
||||
<% @objects.each do |object| %> |
||||
<tr class="<%= @abstract_model.param_key %>_row <%= @model_config.list.with(object:).row_css_class %>"> |
||||
<% if checkboxes %> |
||||
<td class="sticky"> |
||||
<%= check_box_tag "bulk_ids[]", object.id.to_s, false %> |
||||
</td> |
||||
<% end %> |
||||
<% properties.map { |property| property.bind(:object, object) }.each do |property| %> |
||||
<% value = property.pretty_value %> |
||||
<%= content_tag(:td, class: [property.sticky? && "sticky", property.css_class, property.type_css_class].select(&:present?).map { |x| "rails-admin-#{x}" }, title: strip_tags(value.to_s)) do %> |
||||
<%= value %> |
||||
<% end %> |
||||
<% end %> |
||||
<td class="last links ra-sidescroll-frozen rails-admin-actions"> |
||||
<ul class="nav list-inline"> |
||||
<%= menu_for :member, @abstract_model, object, true %> |
||||
</ul> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
<% if @objects.empty? %> |
||||
<tr class="empty_row"> |
||||
<td colspan="<%= table_table_header_count %>"> |
||||
<%= I18n.t("admin.actions.index.no_records") %> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
<% if @model_config.list.limited_pagination %> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= paginate(@objects, theme: "ra-twitter-bootstrap/without_count", total_pages: Float::INFINITY) %> |
||||
</div> |
||||
</div> |
||||
<% elsif @objects.respond_to?(:total_count) %> |
||||
<% total_count = @objects.total_count.to_i %> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= paginate(@objects, theme: "ra-twitter-bootstrap") %> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "govuk-button govuk-button--secondary") unless total_count > 100 || total_count <= @objects.to_a.size %> |
||||
</div> |
||||
</div> |
||||
<div class="clearfix total-count"> |
||||
<%= "#{total_count} #{@model_config.pluralize(total_count).downcase}" %> |
||||
</div> |
||||
<% else %> |
||||
<div class="clearfix total-count"> |
||||
<%= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" %> |
||||
</div> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
@ -0,0 +1,5 @@
|
||||
class AddCollectionYear < ActiveRecord::Migration[7.2] |
||||
def change |
||||
add_column :log_validations, :collection_year, :string |
||||
end |
||||
end |
@ -0,0 +1,6 @@
|
||||
desc "Sets value for collection_year log validations depending on the from value" |
||||
task set_log_validation_collection_year: :environment do |
||||
LogValidation.all.each do |log_validation| |
||||
log_validation.update(collection_year: "#{log_validation.from.year}/#{log_validation.from.year + 1}") |
||||
end |
||||
end |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue