Commit Graph

31 Commits

Author SHA1 Message Date
Javi Martín
c2710de5fc Extract method to open links in a new window
This way we can slightly simplify the code.
2023-10-23 18:19:48 +02:00
Javi Martín
cc25dbe437 Simplify help links in debates/proposals forms 2023-10-23 18:19:48 +02:00
Javi Martín
46f43236bb Extract component to render the "I agree" checkbox
IMHO the best solution would be to completely remove this checkbox on
forms that require registration. Other than the fact that people have
already agreed with these terms when registering (although I guess these
terms might have changed since then) and that approximately 0% of the
population will read the conditions every time they agree with them,
there's the fact that these links are inside a label and people might
accidentally click on them while trying to click on the label in order
to check the checkbox.

I guess the idea is that these conditions might have changed since the
moment people registered. In a fair world, checking "I agree" would have
no legal meaning because it's unreasonable to expect that people will
read these conditions every time they fill in a form, so whatever we're
trying to do here would be pointless.

But, since I'm not sure about the legal implications of removing this
field in a world where you have to inform people that websites requiring
identification use cookies, for now the field will stay where it is.
2023-10-23 18:19:48 +02:00
Javi Martín
95958b2080 Remove title attribute in fields to accept terms
Not sure why we introduced these titles in commit 9dce52a69. The title
attributes contained the same text as the label, which IMHO made them
useless.
2023-10-23 18:19:48 +02:00
Javi Martín
0b0cbcfe5a Fix typos in HTML target attributes
In some places, we were using `blank` instead of `_blank`. Most browsers
treat `blank` like `_blank`, though, so most people didn't experience
any difference.

In another place, we were incorrectly passing the `target` option inside
an `options:` hash, resulting in invalid HTML.
2023-10-23 18:19:47 +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
d3eeffded1 Fix focus outline on links containing images
In some cases, like SDG icons and the proposals map, the image was
bigger than the link containing it, resulting in a funny-looking outline
on focus.

For reasons I don't understand, using `&:active,&:focus:active` didn't
compile to the CSS I was expecting, so I'm repeating the same code for
these two separate cases.
2023-10-10 15:03:21 +02:00
Javi Martín
1a098dfcab Add and apply MultilineMethodCallBraceLayout rule
In order for this rule to work effectively when running `--autocorrect`,
we also need to enable the `ClosingParenthesisIndentation` rule.
2023-08-18 14:56:16 +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
Senén Rodero Rodríguez
ca12388005 Do not render proposals geozones when empty 2023-06-19 14:37:01 +02:00
Senén Rodero Rodríguez
e4cd02c6a9 Extract proposals geozones to a component 2023-06-19 11:15:37 +02:00
Senén Rodero Rodríguez
1bc2a68856 Do not show the geozone selector where there are no geozones defined 2023-06-14 14:32:08 +02:00
Javi Martín
e75211125a Remove duplicate i18n text to remove marker
We had two different keys with the same text and were passing it as a
parameter. Since the text is the same in any case, we don't need a
parameter for it.

Note we are using the `proposals` i18n key instead of creating a new one
in a `shared` namespace one because creating a new key would mean that
we'd lose the already existing translations in Crowdin.
2023-05-04 15:27:15 +02:00
Javi Martín
b9518d64e1 Use Rails methods to get map location input IDs
We were manually generating the IDs in order to pass them as data
attributes in the HTML in a component where we don't have access to the
form which has the inputs.

However, these data attributes only make sense when there's a form
present, so we can pass the form as a parameter and use it to get the
IDs.

We can now define a map as editable when there's an associated form,
which makes sense IMHO.
2023-05-04 15:27:15 +02:00
Javi Martín
abec716308 Show "not allowed" message on click
Defining a behavior on hover means making it different for people using
a keyboard or a touchscreen (most of the population, nowadays).

In this case, we had an accessibility issue where the message wouldn't
disappear once it appeared. That meant that, after tabbing through all
the links and buttons in, for instance, the debates index, the page
would be filled with "participation not allowed" messages, and in order
to see the information about how many people have voted, reloading the
page was required.

For touchscreen users the behavior was similar to what we get on hover,
although we've found some inconsistencies when trying to support several
elements on the same page.

We think in proposals it makes sense to hide the "support" button when
users click on it, and the same applies to the buttonsto support and
vote investment projects. However, we aren't hiding the buttons to
agree/disagree with a debate in order to keep the information about the
current number of people agreeing and disagreeing visible.

Note we're removing some support spec methods because after these
changes the duplication isn't as obvious as it was in the past.
2022-02-23 16:43:37 +01:00
Javi Martín
9c4d406a77 Unify the logic to show the "not allowed" message
We were using the same logic six times regarding when we should show a
"participation not allowed" message. Since we're going to change the
current behavior, we're unifying the logic in one place so the changes
will be easier.
2022-02-23 16:43:37 +01:00
Javi Martín
88004a5e8a Replace support proposal link with a button
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST requests to the server has a few
issues.
2022-02-21 18:47:37 +01:00
Javi Martín
4fd99e2d30 Add proposal name to vote links aria-label
This way blind screen reader users will know which proposal they're
supporting. In a list of proposals, context might not be clear when a
link saying "Support" or "Support this proposal" is announced, but a
link saying "Support Create a monthly transport ticket" is less
ambiguous.

Just like we did with investments in commit de436e33a, we're keeping the
title attribute because when visiting a proposal page, the connection
between the "Support" link and the proposal is not as clear as it is in
the proposals index page, so it might not be clear what you're
supporting.
2022-02-21 18:47:37 +01:00
Javi Martín
7912d857b4 Simplify code in link to support a proposal
The code was harder to read with the (unnecessary) block.
2022-02-21 18:47:13 +01:00
Javi Martín
4e3b3f2028 Extract methods in votes components
This way we can make the view code a bit easier to read.

We're also changing the order of the conditions a little bit so we only
check for the presence of a current user once.

To make sure we aren't breaking anything with these changes, we're
adding some tests. We're also replacing one system test checking content
with a component test, since component tests are much faster.
2022-02-21 18:47:13 +01:00
Javi Martín
70f717e564 Use current user in votes components
Just like we do in most places; we almost never use `user_signed_in?`.
2022-02-21 18:47:13 +01:00
Javi Martín
4b42a68b6a Use the vote action to vote featured proposals
The action and the views were almost identical, with the supports
progress and the HTML classes of the success message element being the
only exceptions; we can use CSS for the styles instead.
2022-02-21 18:47:13 +01:00
Javi Martín
b98244afd9 Remove votes query optimizations
Just like we did in commit 0214184b2d for investments, we're removing
some possible optimizations (we don't have any benchmarks proving they
affect performance at all) in order to simplify the code.

The investement votes component `delegate` code was accidentally left
but isn't used since commit 0214184b2, so we're removing it now that
we're removing the `voted_for?` helper method.
2022-02-21 18:47:13 +01:00
Javi Martín
78f372fd0b Move votes partials to components
We're going to change the code quite a bit, and with components we can
easily extract methods when necessary.
2022-02-21 18:47:13 +01: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
decabeza
578f3437da Update styles and layout for new proposals form 2021-07-13 15:27:20 +02:00
Javi Martín
211bcb8a65 Move new proposal view to a component 2021-07-13 15:27:14 +02:00
Javi Martín
b162ad512a Remove row and column divs in debate/proposal form
We don't need any row classes anymore because the <body> already has a
maximum width. As for columns, we only have one column in this form, so
we don't need them either. Besides, the form's parent element already
has a padding.
2021-07-13 15:27:13 +02:00
Javi Martín
ab0fd86922 Show globalize locales after the errors
Just like it's done in the investment form.
2021-07-13 15:25:31 +02:00
Javi Martín
4150d7f1be Move proposals form partial to a component
Since now categories are loaded in both the investment form component
and proposal form component, and their controllers are the only
"commentable" controllers using the `@categories` instance variable, we
can remove the `load_categories` call in `CommentableActions` affecting
the create and update actions.
2021-07-13 15:25:29 +02:00