Commit Graph

19873 Commits

Author SHA1 Message Date
Javi Martín
ee34ead4ee Move poll shifts form partial to a component
Thanks to it, we can move a few helper methods to the component.
2024-11-12 15:17:16 +01:00
Javi Martín
9ab6c15975 Remove unused method in shifts helper
We don't use this method since commit 452723628.
2024-11-12 15:16:23 +01:00
Javi Martín
d254fcd7ca Fix missing "for" attribute in user segments label
Since the attribute was missing, the label wasn't correctly associated
with its field.
2024-11-12 15:15:34 +01:00
Javi Martín
b68047f265 Fix missing "for" attribute in officer assignment label
Since this attribute was missing, the label wasn't correctly associated
with its field.
2024-11-12 15:15:34 +01:00
Javi Martín
3b7948a139 Use a date field to select the date of birth
The default `date_select` used in fields presents an accessibility
issue, because in generates three select controls but only one label.
That means that there are two controls without a label.

So we're using a date field instead. This type is field is supported by
about 99% of the browsers, and we've already got JavaScript code
converting this field to a jQuery UI datepicker in case the browser
doesn't support date fields.

Note that, since we no longer need to parse the three date fields into
one, we can simplify the code in both the models and the tests.

Another slight improvement is that, previously, we couldn't restrict the
month and day controls in order to set the minimum date, so the maximum
selectable date was always the 31st of December of the year set by the
minimum age setting. As seen in the component test, now that we use only
one field, we can set a specific date as the maximum one.
2024-11-12 15:15:34 +01:00
Javi Martín
6af8ddd324 Extract component to render the date of birth
We reduce code duplication thanks to that, and make it easier
to change this field.

Note that there was one place where the "16.years" value was
hardcoded. We're moving the test for this case to the
component and changing it so the test doesn't use the default
age.

We're also removing the redundant helper method that had the
same code as a method in the User class which is called
everywhere else.
2024-11-12 15:15:34 +01:00
Javi Martín
6f81215425 Merge pull request #5786 from consuldemocracy/stats_turbolinks_reload
Include stat graphs JavaScript in all admin stats actions
2024-11-11 15:46:15 +01:00
Javi Martín
c34cab282a Merge pull request #5509 from consuldemocracy/labels_everywhere
Associate all form inputs with labels
2024-11-11 15:21:25 +01:00
Javi Martín
4102330abc Add labels to investments filters
Note that adding the labels broke the layout because the button was no
longer aligned with the fields, so we're now using a flex layout.

Since we're using labels, we no longer need a placeholder (which wasn't
very informative, by the way) in the text field.
2024-11-11 15:04:40 +01:00
Javi Martín
670f4515ab Remove obsolete HTML class in advanced filters button
The `clear` class isn't needed since commit c9f31b8e1, when we moved
this button above the regular search fields.

We're also moving the `float` property to the CSS file.
2024-11-11 15:04:40 +01:00
Javi Martín
29968d1d9f Use a button to toggle advanced filters
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations.
2024-11-11 15:04:40 +01:00
Javi Martín
bc4fd63950 Simplify advanced filter params initialization 2024-11-11 15:04:40 +01:00
Javi Martín
c28ff49f10 Move investments search form partial to a component
As a bonus, we now have a few less helper methods :).
2024-11-11 15:04:40 +01:00
Javi Martín
1cefc040a7 Add labels to the search form in the management area
The text for the unfeasible checkbox wasn't correctly defined as a
label, while the fields to search investments and select the heading
weren't intuitive since their purpose wasn't obvious.
2024-11-11 15:04:35 +01:00
Javi Martín
b45f928703 Fix label width in the management area search form
With a 50% width on medium and large screens, depending on the size of
the text and the size of the screen, the label could unnecessarily use
two rows, looking broken.
2024-11-11 13:58:48 +01:00
Javi Martín
39d68fd928 Use form_tag in management area investments search form
Since this form isn't associated to an object, using `form_tag` instead
of `form_for` simplifies the code.
2024-11-11 13:58:48 +01:00
Javi Martín
02825c22fe Include stat graphs JavaScript in all admin stats actions
Since the main stats index loads this JavaScript using
`"data-turbolinks-track" => "reload"`, going from the stats index to a
section that doesn't include this JavaScript did the strange effect
Turbolinks does in these situations: it first loaded the page using an
AJAX request and, after getting the contents of the page, it reloaded it
in order to apply the changes in the included JavaScript.

This behavior was a bit confusing, particularly when browsing to a
section of the admin stats, clicking the browser's back button to go
back to the stats index, the going to another section, ...

One of the admin stats tests was failing sometimes with this message:

```
  1) Stats Budget investments Supporting phase Number of users and
     supports in investment projects
     Failure/Error: raise ex, cause: cause

     Selenium::WebDriver::Error::UnknownError:
       unknown error: unhandled inspector error:
         {"code":-32000,"message":"Node with given id does not belong to the document"}
         (Session info: chrome=129.0.6668.89)
```

This was probably caused by the mentioned Turbolinks behavior that loads
the page twice. It's possible that Selenium was somehow checking the
node related to the first request when the second request had finished.

Avoiding that double request solves the issue.
2024-11-08 19:54:29 +01:00
Javi Martín
9a4aea9381 Extract method to include stat graphs JavaScript
We're going to use this method everywhere in the admin stats section.
2024-11-08 19:37:09 +01:00
Javi Martín
f8d06bcaf2 Move management investments search partial to a component
We're also moving it to the `management` subfolder, since it's only used
in the budget investments management.
2024-11-08 15:03:55 +01:00
Javi Martín
b7e9d1118e Add ARIA labels to moderation checkboxes
This way it'll be easier for people using screen readers to know which
element the checkbox is related to.

Note that we're using the `aria-label` attribute because it makes
testing with Capybara easier than using the `aria-labelledby` attribute.
The only exception are the comments, since comments don't have a title
and there isn't a proper label for them. In this case, we're using the
title of the associated commentable as the label; we might change it in
the future since there might be many comments for the same commentable.
2024-11-08 15:03:55 +01:00
Javi Martín
8213f23629 Use I18n texts for image dimensions
This way it'll be possible to customize the text in languages not using
parenthesis or not using an "x" to define dimensions.
2024-11-08 15:03:55 +01:00
Javi Martín
b82d7032ba Add a hint to the site customization image fields
This way people using screen readers will hear the required dimensions
of the images while filling in the form.
2024-11-08 15:03:55 +01:00
Javi Martín
5ca65a787f Add an ARIA label to site customization images fields
This way it'll be easier for people using screen readers to know which
field they're on.
2024-11-08 15:03:55 +01:00
Javi Martín
331228cb2a Add proper labels for site customization texts
We were rendering one label and many textarea fields for that label.
This meant that, when switching to a different language, the label
wasn't correctly associated with the textarea.

So we're now rendering one label for each textarea. We could use
`aria-label` or `aria-labelledby` instead, but using a label offers some
advantages like the fact that clicking on the label makes the textarea
take the focus.
2024-11-08 15:03:55 +01:00
Javi Martín
0f712635a4 Extract method in information text field component
This will make it easier to reuse this method.
2024-11-08 15:03:55 +01:00
Javi Martín
e1353fd865 Fix duplicate fields in information texts form
We were rendering the same hidden field, with the same HTML ID, one time
per enabled locale.
2024-11-08 15:03:55 +01:00
Javi Martín
55d81fcac7 Fix missing "for" attribute in user invitations label
Since the attribute was missing, the label wasn't correctly associated
with its field.
2024-11-08 15:03:55 +01:00
Javi Martín
431ebeda87 Fix missing "for" attribute in document number label
Since this attribute was missing, the label wasn't correctly associated
with its field.
2024-11-08 15:03:55 +01:00
Javi Martín
9f738b8d5f Fix labels in progress bar percentage selection
We were using the same label for two elements, but the label was only
assigned to one of them.
2024-11-08 15:03:55 +01:00
Javi Martín
233ba3c72f Move progress bars form partial to a component
This way we can move some of the view logic to the Ruby class. It'll
also make it easier to write tests for it.
2024-11-08 15:03:55 +01:00
Javi Martín
9c057d5695 Fix labels in color selection
We were using the same label for two elements, but the label was only
assigned to one of them.
2024-11-08 15:03:55 +01:00
Javi Martín
8aff1414c5 Move legislation process form partial to a component
This will make it easier to write tests for it.
2024-11-08 15:03:55 +01:00
Javi Martín
c1fbcb4e0f Remove obsolete resource method in controllers
This method was used by controllers using the `Translatable` concern. We
forgot to remove it in commit 71601bd3f.
2024-11-08 15:03:51 +01:00
Javi Martín
e850ae2ff9 Move banner form partial to a component
Other than simplifying the controller, this'll make it easier to write
tests for this code.
2024-11-08 14:24:57 +01:00
Javi Martín
16fc9998c4 Use labels in controls to add and select languages
The absence of labels in these controls made them hard to use,
particularly for people who use screen readers.

Note we're removing the "Choose language" prompt, since we always
automatically choose a language and not choosing a language doesn't
really make sense. The only scenario where the prompt was used took
place when all languages had been removed but, in that case, the "Choose
language" prompt was misleading because there were no languages to
choose from.
2024-11-08 14:22:44 +01:00
Javi Martín
0f10146273 Merge pull request #5740 from consuldemocracy/button_confirmations
Use buttons for actions requiring confirmation
2024-11-08 14:11:35 +01:00
Javi Martín
ef4bc6a650 Simplify accept_confirm dialog in valuation test
We were using `check "Valuation finished"` everywhere except here.

This way it's easier to realize, while reading the test, that we're
interacting with a checkbox and not a link or a button.
2024-11-08 13:35:22 +01:00
Javi Martín
87a5dd8ee5 Use a button to mark debates as featured
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.
2024-11-08 13:24:23 +01:00
Javi Martín
68744f110e Use CSS to add separators to the debates featured action
Just like we do in the moderation actions displayed next to id.
2024-11-08 13:24:23 +01:00
Javi Martín
f8faabf7d1 Extract component to mark a debate as featured
We're also moving the path argument in the `link_to` calls to a
different line, since it's what we usually do.
2024-11-08 13:24:05 +01:00
Javi Martín
d85a87a517 Use a button to delete surveys
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.
2024-11-08 13:11:02 +01:00
Javi Martín
11ef917802 Use a button to delete comments
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.
2024-11-08 13:01:01 +01:00
Javi Martín
26b24af413 Remove unused HTML class in hide recommendation button
Since the element uses `position: absolute`, the `float: right` property
set by this utility class is ignored.
2024-11-08 13:01:01 +01:00
Javi Martín
891333abed Use a button to hide recommendations
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.

Since we're adding styles for this button, we're also adding the
`font-size` property instead of using the `small` class. We'll deal with
the `float-right` property in the next commit.
2024-11-08 13:00:14 +01:00
Javi Martín
2fb8eaf6c7 Add aria-labels to user investment actions
This way it'll be easier for people using screen readers to know which
link/button they're about to click.

Note that, at least for now, we aren't reusing the code en
`Admin::ActionComponent`. We might do so in the future if we implement
similar code in more parts of the public area.
2024-11-08 12:29:37 +01:00
Javi Martín
cbdf2f7f22 Extract methods in user investment table actions 2024-11-08 12:19:39 +01:00
Javi Martín
b694ee7077 Use a button to delete an investment
Note that, since the button now generates a `form` tag, we need to
adjust the styles of this section.

As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.

Note we're simplifying the `table .button` margin rules because the
`.button` class already defines `0` for all its margins except the
bottom margin. Otherwise, the margins defined by the `flex-with-gap`
mixin would be overwritten by the margins defined in the `table .button`
class.
2024-11-08 12:19:05 +01:00
Javi Martín
0e2434c094 Extract commponent to render user investment actions
This way it'll be easier to organize code related to it.
2024-11-07 15:18:37 +01:00
Javi Martín
58cba2316a Use a button to erase an account in the management area
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commit,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.
2024-11-07 15:18:37 +01:00
Javi Martín
2fb8abe83f Use a button to delete documents
While testing for accessibility issues (in a development branch), we're
removing Turbolinks and monkey-patching the behavior of the `click_link`
method to check the page for accessibility issues after each request.
However, we were getting false positives when clicking links that act
like buttons.

So, for the reasons mentioned in commit 5311daadf, we're replacing the
link to delete a document with a button.
2024-11-07 15:18:37 +01:00