Commit Graph

77 Commits

Author SHA1 Message Date
Javi Martín
7c6134fdee Unify the way we display document information
We were displaying documents in five places, and in five different ways.
Sometimes with the metadata in parenthesis after the title, sometimes
with the metadata below the title, sometimes without metadata, sometimes
with an icon in front of the document, and sometimes with a separate
link to download the file.

So we're now displaying the same thing everywhere. Not sure whether this
is the best solution, but at least it's consistent.

We aren't unifying the way we display a list of documents, though, since
different sections look pretty different and I'm not sure whether the
same style would look well everywhere.

Note that we're renaming the `document` HTML class in the documents
table to `document-row` so the styles for the `document` class don't
apply here.
2023-10-23 18:15:54 +02:00
Javi Martín
a2e4b056ee Move documents partials to components
This way it'll be easier to change them.

Note that there were two `.document-link` elements which aren't part of
a `.documents` element. We're renaming the HTML class of the link in
investments because it didn't contain links to download documents and
are slightly duplicating the CSS in the poll answer documents in order
to keep the `word-wrap` property.
2023-10-23 18:10:24 +02:00
Javi Martín
1e1d7996bb Simplify rendering document/image fields
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.
2023-10-23 15:49:01 +02:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
7212657c02 Remove Paperclip and use just Active Storage 2022-02-23 18:43:48 +01:00
Javi Martín
091abfc944 Use Active Storage to render attachments
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.
2022-02-23 18:21:38 +01:00
Javi Martín
c9113041c0 Move nested documents partial to a component 2021-07-13 16:58:13 +02:00
Javi Martín
629df5ab9b Simplify getting imageable/documentable in forms
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.
2021-07-13 16:58:13 +02:00
Javi Martín
810814486c Move document fields partial to a component 2021-07-13 16:58:13 +02:00
decabeza
72a24128a6 Improve upload image and documents buttons 2021-03-24 15:48:24 +01:00
Javi Martín
6b1864fbcd Sanitize translations instead of using _html
Using the `_html` suffix in an i18n key is the same as using `html_safe`
on it, which means that translation could potentially be used for XSS
attacks.
2019-10-09 19:46:47 +02:00
Javi Martín
c62da726b8 Apply SpaceAroundErbTag ERB Lint rule 2019-09-10 20:02:15 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
decabeza
0995480b73 Remove question and external_url fields from proposals 2019-04-30 11:35:47 +02:00
Julian Herrero
f6489bc604 Use double quotes in app/views 2019-03-19 12:33:07 +01:00
rgarcia
dacc2d529d Fix destroy document specs
We were linking to the document url itself, which does not have a route
associated and so the specs fails

With this commit we are using the correct path to the destroy action of
the DocumentsController.

We are also using the referrer instead of a params[:from] attribute, as
it avoids having to pass an extra parameter, making the code prettier
and it works the same way
2019-01-24 21:39:43 +01:00
decabeza
4cda7d1d9f Shows documents title only if there is any document 2018-12-26 12:03:46 +01:00
decabeza
61c7b9a02b Changes width of additional documents container 2018-12-04 17:30:54 +01:00
Raimond Garcia
1692abc54a Merge pull request #2374 from wairbut-m2c/upload_documents_feature
Upload documents feature
2018-04-05 19:39:12 +02:00
decabeza
acebb07ddd Adds link to image and docs on admin budget investment info 2018-03-14 15:14:47 +01:00
decabeza
5c0a10699a Refactors documents partials and reorganices css 2018-02-28 15:22:33 +01:00
Bertocq
97ec551178 Correctly check if user can destroy a document 2018-01-24 17:07:05 +01:00
Vicente Mendoza
410caced3e test added for changes at documentable's view 2018-01-24 12:48:06 +01:00
Bertocq
d7d1a85fbb Refactor documents and document view partials 2018-01-02 13:32:42 +01:00
Manuel Ortega
3531060476 Added partial in order to show documents collection. Added DocumentsHelper method in order to show documents link with humanized file type and file size 2017-10-21 16:53:41 +02:00
Manuel Ortega
2fef9c14d0 Moving humanized_content_type from DocumentablesHelper to Document model. Removing humanized_file_size in favor of direct use of number_to_human_size form ActionViewHelper. Added additional documentens to all concerned views 2017-10-18 22:21:01 +02:00
Manuel Ortega
97fb986626 Added documentable feature to legislation processes 2017-10-18 19:50:34 +02:00
decabeza
fd78eb30cc shows hr tag on forms only when expanded 2017-09-28 15:20:47 +02:00
Senén Rodero Rodríguez
6c1d828a62 Remove unneded code 2017-09-27 11:38:38 +02:00
Senén Rodero Rodríguez
2993ef8707 Remove documents single uploads 2017-09-27 11:04:56 +02:00
Senén Rodero Rodríguez
77f63a4c44 Add _destroy parameter to nested documents 2017-09-26 13:57:13 +02:00
Senén Rodero Rodríguez
f8d78ec4ab Remove new_nested action from images controller. Use cocoon gem to manage new nested fields creation on images. 2017-09-26 13:57:13 +02:00
Senén Rodero Rodríguez
88a7a29d27 Remove new_nested action from documents controller. Use cocoon gem to manage new nested fields creation on documents. 2017-09-26 13:57:13 +02:00
Alessandro Cuoghi
3745e76c07 Solve conflicts. Refactor documentable and imageable styles. 2017-09-26 13:57:13 +02:00
Senén Rodero Rodríguez
966ff4dc03 User new direct uploads controllers action on imageable. 2017-09-26 13:56:06 +02:00
Senén Rodero Rodríguez
824dd26d5a User new direct uploads controllers action on documentable. Skipped spec. 2017-09-26 13:55:51 +02:00
Senén Rodero Rodríguez
826385f659 Extract ajax upload and destroy_upload actions from images and documents controllers and place them at new controllers to manage direct uploads 2017-09-26 13:55:28 +02:00
Senén Rodero Rodríguez
c6dabedb4a Add missing image model spec. Add shared specs to check image validations at any imageable model 2017-09-26 13:55:03 +02:00
Senén Rodero Rodríguez
60e91c7a24 Remove sleep from documentable shared feature specs. Use matchers able to wait new content to appear. 2017-09-26 13:55:03 +02:00
Senén Rodero Rodríguez
6f71da07ee Duplicate documentable code and rename for imageable 2017-09-26 13:55:03 +02:00
decabeza
b43e464292 renames js class 2017-09-20 19:27:11 +02:00
Alessandro Cuoghi
b0e4c5d66c Hide progress bar for remove white space on init form. Added display block via js to show progrss bar. Added some margin. 2017-08-25 18:50:02 +02:00
Senén Rodero Rodríguez
2fdbbf15e5 Fix back link 2017-08-25 18:41:34 +02:00
Senén Rodero Rodríguez
796e6f9ce1 Code adaptation to work with nested documents and plain documents. 2017-08-25 18:34:55 +02:00
Senén Rodero Rodríguez
b2a6189cf5 Views and helpers refactor 2017-08-25 18:34:54 +02:00
Senén Rodero Rodríguez
d67ad6d6d0 Fix overlapping error on Travis with make_visible option on attach_field spec helper 2017-08-25 18:34:54 +02:00
Senén Rodero Rodríguez
2e1d98c408 Fix use of an old route 2017-08-25 18:34:54 +02:00
Alessandro Cuoghi
a32849c79b Changed style button. Add margin top progress bar. 2017-08-25 18:34:53 +02:00
Senén Rodero Rodríguez
0fbffdc73e Fix abilities definition and related specs 2017-08-25 18:34:53 +02:00