Browse Source

Add some changes to copy and styling

pull/2690/head
Kat 2 years ago
parent
commit
607e755f65
  1. 6
      app/controllers/collection_resources_controller.rb
  2. 2
      app/helpers/collection_resources_helper.rb
  3. 8
      app/views/collection_resources/edit.html.erb
  4. 8
      app/views/collection_resources/new.html.erb
  5. 4
      config/locales/en.yml
  6. 2
      spec/features/collection_resources_spec.rb

6
app/controllers/collection_resources_controller.rb

@ -167,7 +167,11 @@ class CollectionResourcesController < ApplicationController
if @collection_resource.save
begin
CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file)
flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users."
flash[:notice] = if displayed_collection_resource_years.include?(@collection_resource.year)
"The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users."
else
"The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} has been uploaded."
end
redirect_to collection_resources_path
rescue StandardError
@collection_resource.errors.add(:file, :error_uploading)

2
app/helpers/collection_resources_helper.rb

@ -49,7 +49,7 @@ module CollectionResourcesHelper
def document_list_component_items(resources)
resources.map do |resource|
{
name: "Download the #{resource.display_name}",
name: "Download the #{resource.display_name.downcase}",
href: resource.download_path,
metadata: file_type_size_and_pages(resource.download_filename),
}

8
app/views/collection_resources/edit.html.erb

@ -27,14 +27,16 @@
<% unless @collection_resource.mandatory %>
<%= f.govuk_text_field :short_display_name,
label: nil,
label: { text: "Resource type", size: "m" },
hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.",
content_tag(:br),
"For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %>
<% end %>
<%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %>
<%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
<div class="govuk-button-group">
<%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %>
<%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
</div>
<% end %>
</div>
</div>

8
app/views/collection_resources/new.html.erb

@ -22,13 +22,15 @@
label: { text: "Upload file", size: "m" } %>
<%= f.govuk_text_field :short_display_name,
label: nil,
label: { text: "Resource type", size: "m" },
hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.",
content_tag(:br),
"For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %>
<%= f.govuk_submit "Add resource" %>
<%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
<div class="govuk-button-group">
<%= f.govuk_submit "Add resource" %>
<%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
</div>
<% end %>
</div>
</div>

4
config/locales/en.yml

@ -122,7 +122,7 @@ en:
file:
error_uploading: There was an error uploading this file.
blank: Select which file to upload.
above_100_mb: The file is above 100MB.
above_100_mb: File must be 100MB or less.
must_be_pdf: The paper form must be a PDF.
must_be_xlsx: The %{resource} must be a Microsoft Excel file.
@ -212,7 +212,7 @@ en:
file:
error_uploading: There was an error uploading this file.
blank: Select which file to upload.
above_100_mb: The file is above 100MB.
above_100_mb: File must be 100MB or less.
must_be_pdf: The paper form must be a PDF.
must_be_xlsx: The %{resource} must be a Microsoft Excel file.
short_display_name:

2
spec/features/collection_resources_spec.rb

@ -187,7 +187,7 @@ RSpec.describe "Collection resources" do
expect(CollectionResource.first.released_to_user).to be_nil
expect(CollectionResource.first.display_name).to eq("sales some file (2025 to 2026)")
expect(CollectionResource.first.short_display_name).to eq("some file")
expect(page).to have_content("The sales 2025 to 2026 some file is now available to users.")
expect(page).to have_content("The sales 2025 to 2026 some file has been uploaded.")
end
it "validates file is attached" do

Loading…
Cancel
Save