We were adding <div> tags with the `images` or `documents` HTML class
prettly much every time we rendered a NestedComponent. We're now
including the HTML class inside the component, as we usually do.
We're also rendering the nested components directly, since it's been a
while since the partials were changed to simply render the components.
This way we fix a bug we mentioned in commit 930bb753c which caused
links to documents to be broken when editing their title because the
title was used to generate the URL of the document.
Note we're still using Paperclip to render cached attachments because
this is the only case where we store files with just Paperclip and not
Active Storage.
With Active Storage, we render attachments just like any other resource,
using `polymorphic_path`. Paperclip included the `url` method in the
model; since the model doesn't have access to the request parameters
(like the host), this was inconvenient because it wasn't possible to
generate absolute URLs with Paperclip.
In order to simplify the code and make it similar to the way we used
Paperclip, we're adding a `variant` method accepting the name of a
variant and returning the variant.
The imageable/documentable object is always the object the form builder
is based on; since we're already passing the form builder, we don't have
to pass the object as well.
The only exception are the poll answers. In this case, we're passing a
new answer as the object. That's OK; the same hack that we're using to
send the data to the answer URL without displaying existing attachments
causes the form to keep working the same way.
Cambios para hacer commit:
modificado: app/views/images/_admin_image.html.erb
modificado: spec/features/admin/poll/polls_spec.rb
modificado: spec/features/polls/polls_spec.rb
Added missing text for english and new texts in english and spanish.
Cambios para hacer commit:
modificado: app/assets/stylesheets/participation.scss
modificado: app/models/concerns/imageable.rb
modificado: app/models/poll.rb
modificado: app/views/admin/poll/polls/_form.html.erb
modificado: app/views/images/_admin_image.html.erb
modificado: config/locales/en/images.yml
modificado: config/locales/es/admin.yml
modificado: config/locales/es/images.yml
modificado: spec/features/admin/poll/polls_spec.rb