Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
e25b6f4ebe Merge pull request #4424 from consul/dependabot/bundler/pronto-rubocop-0.11.1
Bump pronto-rubocop from 0.11.0 to 0.11.1
2021-08-09 02:13:07 +02:00
Javi Martín
c2e1b8e11c Merge pull request #4425 from consul/dependabot/bundler/globalize-5.3.1
Bump globalize from 5.3.0 to 5.3.1
2021-08-09 02:10:23 +02:00
dependabot[bot]
ff27f43d45 Bump pronto-rubocop from 0.11.0 to 0.11.1
Bumps [pronto-rubocop](https://github.com/mmozuras/pronto-rubocop) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/mmozuras/pronto-rubocop/releases)
- [Commits](https://github.com/mmozuras/pronto-rubocop/compare/v0.11.0...v0.11.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-08 23:46:11 +00:00
dependabot[bot]
354cc0ae6c Bump globalize from 5.3.0 to 5.3.1
Bumps [globalize](https://github.com/globalize/globalize) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/globalize/globalize/releases)
- [Changelog](https://github.com/globalize/globalize/blob/master/CHANGELOG.md)
- [Commits](https://github.com/globalize/globalize/compare/v5.3.0...v5.3.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-08 23:41:32 +00:00
Javi Martín
3e90bb8a90 Merge pull request #4426 from consul/dependabot/bundler/bullet-6.1.4
Bump bullet from 6.1.0 to 6.1.4
2021-08-09 01:37:37 +02:00
Javi Martín
9222ea0cf6 Upgrade Ruby to version 2.6.8
So get the latest security fixes in the 2.6.x series and we can update
the parser gem without getting any warnings.
2021-08-09 01:14:08 +02:00
dependabot[bot]
e59742067c Bump bullet from 6.1.0 to 6.1.4
Bumps [bullet](https://github.com/flyerhzm/bullet) from 6.1.0 to 6.1.4.
- [Release notes](https://github.com/flyerhzm/bullet/releases)
- [Changelog](https://github.com/flyerhzm/bullet/blob/master/CHANGELOG.md)
- [Commits](https://github.com/flyerhzm/bullet/compare/6.1.0...6.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-08 23:12:02 +00:00
Javi Martín
bb8dd49172 Merge pull request #4431 from consul/dependabot/bundler/groupdate-5.2.2
Bump groupdate from 5.2.1 to 5.2.2
2021-08-09 00:46:16 +02:00
dependabot[bot]
51d6d4712d Bump groupdate from 5.2.1 to 5.2.2
Bumps [groupdate](https://github.com/ankane/groupdate) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/ankane/groupdate/releases)
- [Changelog](https://github.com/ankane/groupdate/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ankane/groupdate/compare/v5.2.1...v5.2.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-08 22:25:14 +00:00
Javi Martín
743dc27b85 Merge pull request #4596 from consul/cached_attachments_task
Use a rake task to delete cached attachments
2021-08-02 15:44:33 +02:00
Javi Martín
930bb753c5 Use a rake task to delete cached attachments
Our previous system to delete cached attachments didn't work for
documents because the `custom_hash_data` is different for files created
from a file and files created from cached attachments.

When creating a document attachment, the name of the file is taken into
account to calculate the hash. Let's say the original file name is
"logo.pdf", and the generated hash is "123456". The cached attachment
will be "123456.pdf", so the generated hash using the cached attachment
will be something different, like "28af3". So the file that will be
removed will be "28af3.pdf", and not "123456.pdf", which will still be
present.

Furthermore, there are times where users choose a file and then they
close the browser or go to a different page. In those cases, we weren't
deleting the cached attachments either.

So we're adding a rake task to delete these files once a day. This way
we can simplify the logic we were using to destroy cached attachments.

Note there's related a bug in documents: when editing a record (for
example, a proposal), if the title of the document changes, its hash
changes, and so it will be impossible to generate a link to that
document. Changing the way this hash is generated is not an option
because it would break links to existing files. We'll try to fix it when
moving to Active Storage.
2021-07-30 17:30:11 +02:00
Javi Martín
a8c4cc3edc Merge pull request #4599 from consul/invalid_image_fields_html
Fix removing existing image and adding a new one
2021-07-30 16:03:01 +02:00
Javi Martín
c0a6bf54fc Fix invisible error message in attachments
In commit cc6f9391f we made the images and documents file inputs
invisible (instead of using `display: none`) in order to make it
possible to attach images and documents using the keyboard.

However, since the error messages associated to these inputs has the
same HTML class as the inputs, we were also hiding them (the `display:
none` didn't affect the error messages because they've also got the
`is-visible` class).

Using the `[type=file]` selector we make it more explicit that we only
want to style these inputs.

I'm not adding a test for this scenario because technically the text is
there and I'm not sure how to test for the presence of invisible
elements.
2021-07-27 23:57:41 +02:00
Javi Martín
2ed7fc6ce6 Merge pull request #4590 from consul/yes_typo
Fix typo in Spanish translation for "yes"
2021-07-27 19:35:59 +02:00
Javi Martín
6c63aaee76 Fix removing existing image and adding a new one
We introduced a bug in commit acbd1b023.

When editing a record and removing an existing image, we don't remove
the HTML fields associated with that image but simply hide them, and
then we add fields to create a new image when clicking on "Add image".

This is standard cocoon behavior. However, since in the case of images
there's a `has_one` relation, cocoon doesn't add unique identifiers to
the new fields, generating duplicate IDs, which is invalid HTML.

Since there's a duplicate file input ID, clicking on the "Choose image"
label we aren't clicking on the new input but on the old one. This means
we aren't correctly attaching an image. The tests passed because
Capybara uses the equivalent of a keyboard to select the field, and in
this case everything worked properly.

So we need to delete the existing elements before inserting new ones.
We're adding a test to check there aren't duplicate IDs.
2021-07-27 19:27:29 +02:00
Javi Martín
1c55691319 Merge similar edit nested imageable tests
This way we save a couple of database insertions and browser requests.
2021-07-27 18:39:00 +02:00
Javi Martín
71f1f9a365 Fix typo in Spanish translation for "yes" 2021-07-26 14:11:13 +02:00
Javi Martín
07d331582b Merge pull request #4589 from consul/dependabot/bundler/addressable-2.8.0
Bump addressable from 2.7.0 to 2.8.0
2021-07-15 14:10:39 +02:00
dependabot[bot]
e38494ef85 Bump addressable from 2.7.0 to 2.8.0
Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.7.0 to 2.8.0.
- [Release notes](https://github.com/sporkmonger/addressable/releases)
- [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.7.0...addressable-2.8.0)

---
updated-dependencies:
- dependency-name: addressable
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-14 22:20:35 +00:00
Javi Martín
b3104fae68 Merge pull request #4586 from consul/attach_with_keyboard
Allow attaching files using the keyboard
2021-07-15 00:19:27 +02:00
Javi Martín
a3324cafbb Merge pull request #4587 from consul/max_votable_headings
Do not show confirm message if user can vote in all headings
2021-07-15 00:18:43 +02:00
decabeza
e42db48f2b Do not show confirm message if user can vote in all headings 2021-07-14 16:14:29 +02:00
Javi Martín
cc6f9391fc Fix attaching files using the keyboard
We were hiding the file input and styling the label as a button instead.
Since clicking on a label has the same effect as clicking on the input,
the input worked properly for mouse and touch screen users.

However, hiding the input makes it inaccessible for keyboard users,
since labels don't get keyboard focus, but inputs do.

So we must not hide the input but make it invisible instead. But we
still need to hide the input (alongside the label) after a file has been
attached.

We could add some extra JavaScript to hide the input when we hide the
label. Since the JavaScript is already quite complex and my first few
attempts at changing it failed, I've opted to assume that the input (and
its label) must be hidden whenever there's already a file name, and
implement that rule with CSS.

Note we're using the `:focus-within` pseudoclass to style a label when
focus is on the input. This rule (at the time of writing) is only
supported by 93.5% of the browsers. Keyboard users without a screen
reader and using the other 6.5% of the browsers will still be able to
focus on the field but might not notice the field has received focus.
Since the percentage of affected users will decrease over time and until
now 100% of keyboard users were completely unable to focus on these
fields, for now we think this is a good-enough solution.
2021-07-13 17:09:05 +02:00
Javi Martín
6da8eeac6f Simplify code to delete a cached attachment
We were already defining the links with data-remote and data-method, so
instead of manually doing an AJAX request we can rely on Rails to
perform the request and then handle the `ajax:complete` event.
2021-07-13 16:58:22 +02:00
Javi Martín
367d3f9d14 Remove condition for non-nested case
We don't use these input fields inside a non-nested context since commit
2993ef870.
2021-07-13 16:58:22 +02:00
Javi Martín
a7e2f1ae30 Move file name before the destroy attachment link
This way screen reader users will hear the name of the file before
hearing about the link to destroy it. We were already displaying it this
way visually by having the file name on the left and the destroy link on
the right.

Thanks to this change we can also simplify the code which dynamically
changed the layout.
2021-07-13 16:58:22 +02:00
Javi Martín
acbd1b0239 Simplify code to reset attachment fields
Since elements are created and destroyed, we don't have to do any kind
of "reset" before destroying or creating them. We would have to do so if
we were just hiding the elements in order to show them again later, but
that's not the case.
2021-07-13 16:58:13 +02:00
Javi Martín
8cdee167f8 Fix duplicate HTML ID in document fields
Using `dom_id` means generating `new_document` as ID for new documents.
Since there might be more than one new document in the form, that means
duplicate IDs, which is invalid HTML.

Even though this issue doesn't affect image fields (because we don't
have many images on the same form), we're removing the ID there as well
for consistency.
2021-07-13 16:58:13 +02:00
Javi Martín
394a94cbff Fix invalid HTML in document/image fields labels
These labels weren't associated with any fields, which is invalid HTML.
We're using a legend inside a fieldset instead, which is the natural way
to group form fields together.
2021-07-13 16:58:13 +02:00
Javi Martín
c9903f36cc Simplify imageable/documentable note method names 2021-07-13 16:58:13 +02:00
Javi Martín
67c29a7c5f Remove duplication in max documents allowed code 2021-07-13 16:58:13 +02:00
Javi Martín
a181052f0d Move nested images partial to a component 2021-07-13 16:58:13 +02: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
ac495e7523 Remove unnecessary code in poll images controller
We're already loading the answer with a `before_action`.
2021-07-13 16:58:13 +02:00
Javi Martín
3073fee4c8 Remove unused documentable class method
It isn't used since commit 6c1d828a6.
2021-07-13 16:58:13 +02:00
Javi Martín
21fee9cff5 Simplify method names in image/document fields
We were using long, unique names because these methods used to be helper
methods. Helper methods should have unique names because otherwise one
method would overwrite the other.

Now that we're using components, we can omit the `image_` and
`document_` prefixes.
2021-07-13 16:58:13 +02:00
Javi Martín
8116e75aee Simplify showing/hiding attached file name
Note we have to render the `<p>` tag in one line because at the time of
writing browsers don't consider elements with whitespace inside as empty
[1].

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/:empty
2021-07-13 16:58:13 +02:00
Javi Martín
afbd1fec37 Remove unused methods to attach files in tests
These methods aren't used since commits eef8ad1b7 and 2993ef87.
2021-07-13 16:58:13 +02:00
Javi Martín
5cf96ba03d Extract methods to get objects in attachment forms 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
Javi Martín
d58c2f8323 Move image fields partial to a component 2021-07-13 16:58:13 +02:00
Javi Martín
a7ed1f9a37 Remove unused errors on attachment methods
They aren't used since commit f8d78ec4a.
2021-07-13 16:58:13 +02:00
Javi Martín
7db4a91d78 Remove duplicate nested image partial
It had almost exactly the same code as the standard nested image
partial, and its variations were insignificant.
2021-07-13 16:58:13 +02:00
Javi Martín
3f9614fbe1 Merge pull request #4225 from consul/forms-design
New design of the forms for creating debates and proposals
2021-07-13 16:34:32 +02:00
Javi Martín
0dfabc8939 Use a Font Awesome icon in recommendations
We've deprecated the "icons" font since we started using Font Awesome
two years ago and using it caused some screen readers to announce an "l"
before the content of every list item.
2021-07-13 15:27:21 +02:00
Javi Martín
e7b37ae93b Increase font-size in recommendations
Now that we display them in one column, the lines were too long for a
small font size.
2021-07-13 15:27:21 +02:00
Javi Martín
932da00f8d Update new topic form layout
The same way we did with debates and proposals, we move recommendations
before the form.
2021-07-13 15:27:21 +02:00
Javi Martín
cb800d0f38 Remove recommendations editing a topic
The same way we don't show recommendations when editing a proposal or a
debate.
2021-07-13 15:27:21 +02:00
decabeza
578f3437da Update styles and layout for new proposals form 2021-07-13 15:27:20 +02:00