Commit Graph

17301 Commits

Author SHA1 Message Date
Javi Martín
074934c154 Merge pull request #4764 from consul/participation_not_allowed
Make "participation not allowed" message accessible
2022-02-23 17:47:43 +01:00
Javi Martín
b9a0b343be Merge pull request #4776 from consul/vote_accessibility
Make buttons to vote more accessible
2022-02-23 17:45:29 +01:00
Javi Martín
0e1d930d91 Merge pull request #4763 from consul/refactor_votes
Refactor code showing in favor and against votes
2022-02-23 17:43:49 +01: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
168575d606 Remove "not allowed" when supporting comments
Hovering over the votes showed a "participation not allowed" message
which was annoying when scrolling with the browser or simply moving the
mouse around the page. Furthermore, it hid the information about the
number of votes, links to show/collapse replies, ...

We're planning to change the behavior of all the "participation not
allowed" messages in order to show them on click instead of showing them
on hover (just like it's done on touchscreens). In the case of comments,
supports, however, there's very limited space in the part showing the
number of supports for comments, so adding this message without breaking
the layout is challenging.

So, for now, we're simply redirecting unauthenticated users to the login
page. If find an easy way to implement a better user interface in the
future to display the "participation not allowed" message, we might
change this behaviour.
2022-02-21 18:48:09 +01:00
Javi Martín
ecd34ca6ce Make participation not allowed text size consistent
Not sure whether small or normal is better, but at least it's the same.
2022-02-21 18:48:09 +01:00
Javi Martín
a0b4e35dbd Show login to comment message in annotations
This way it's consistent with what we get when there are no comments. It
only appears once on the page so it isn't overwhelming.
2022-02-21 18:48:09 +01:00
Javi Martín
9154614577 Always show not allowed message in legislation debates
This message is only shown in the `show` action, so it's shown at most
once in the whole page, so it doesn't take up too much space and it
isn't as overwhelming as if we were showing it on the index page, once
per debate.

We're only showing it when there are closed options, though, since
there's already a message to sign in to comment when the question
accepts open answers.
2022-02-21 18:48:09 +01:00
Javi Martín
aa2c551411 Use has-fa-icon in agree/disagree comment buttons
Note we're using the in-favor HTML class instead of the in_favor class
so we're consistent with our conventions for HTML classes and because we
use the in-favor class in similar places.

Also note the styles of the legislation process annotations/comments
buttons is now similar to the styles in the other sections. Previously,
the colors didn't have enough contrast and there was a very strange
margin between the "thumbs up" icon and the number of people agreeing
(that margin wasn't present between the "thumbs down" icon and the
number of people disagreeing).
2022-02-21 18:47:38 +01:00
Javi Martín
ba0d21b469 Use buttons to agree/disagree with comments
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
7a25c61ae6 Use buttons to vote in the final voting
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST requests to the server has a few
issues.

We're also improving the keyboard access. Previously, the links were
focusable and clickable with the keyboard. Now we're disabling the
buttons when voting isn't allowed.

Since these elements can no longer be focused, we're adding an element
with `tabindex="0"` so the "participation not allowed" message is shown,
like we do in most places.

Note we're slightly changing one test because now when hovering over the
button on Chrome, the "participation not allowed" text isn't shown; it's
only shown when hovering on the parts of the `div.ballot` element
outside the button. Since we're already rewriting the behavior of the
"participation not allowed" text in a different pull request, we aren't
going to fix this behavior.
2022-02-21 18:47:37 +01:00
Javi Martín
f970ddcb86 Fix agree/disagree alignment in medium screens
Using the `flex-with-gap` mixin we avoid the left margin in the second
element when the screen space isn't wide enough to show both buttons.

Setting the margins with CSS also allows as to simplify the view and
makes it easier to customize styles.
2022-02-21 18:47:37 +01:00
Javi Martín
d347da8a33 Use has-fa-icon in agree/disagree buttons
This way we can simplify the code in the views a little bit.
2022-02-21 18:47:37 +01:00
Javi Martín
eecaf5876e Move result percentages out of the voting buttons
Having buttons (previously links) with the text "I agree 75%" is
confusing; people might believe they're saying they only partially agree
with the content. Besides, the results percentages is a different piece
of information which shouldn't be related to whether one person
agrees/disagrees with the content.

This problem might be solved for people using screen readers since we
added the aria-label attribute. However, for sighted keyboard users, the
percentage was being outlined on focus as part of the button, which
might be confusing.
2022-02-21 18:47:37 +01:00
Javi Martín
8c1b4d9ea7 Replace links to agree/disagree with buttons
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
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
413a77bd98 Add votable name to agree/disagree links aria-label 2022-02-21 18:47:37 +01:00
Javi Martín
704687dc54 Add investment name to vote links aria-label
Note we're using the `budgets.investments.investment.add_label` and
`budgets.ballots.show.remove_label` internationalization keys so they're
consistent with the `budgets.investments.investment.add` and
`budgets.ballots.show.remove` keys which were already present. We aren't
unifying these keys in order to keep existing translations.
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
86ad2df46d Unify code in debates/legislation vote links
We were using the same code to render links to agree and disagree, so we
can extract a new component for this code.

We're also adding component tests to make it easier to test whether
we're breaking anything while refactoring, although the code is probably
already covered by system tests.

Since the votes mixin was only used in one place, we're removing it and
moving most of its code to a new CSS file for the shared component.
2022-02-21 18:47:13 +01:00
Javi Martín
9a625fe59f Remove redundant "participation not allowed" code
Very similar code is present in the `votes.js` file. Since the only
elements with the `js-participation-not-allowed` class also matched the
`div.supports div.participation-not-allowed` selector, for these
elements the events were executed twice.

So we can get rid of the `js-participation` class alongside all the
JavaScript code referencing it.
2022-02-21 18:47:13 +01:00
Javi Martín
f11fd2b13e Remove duplication in comments votes component
We're also simplifying the code a bit by removing the
`participation-allowed` HTML class, which wasn't used in any other votes
component.
2022-02-21 18:47:13 +01:00
Javi Martín
053ec31df6 Fix new session links in comments votes component
When there isn't a current user, the links can't be clicked, so there's
no real point in them being links.

When there's a current user and they cannot vote (for example, an
organization), having a link/button to an action they can't perform
isn't that useful IMHO. They get a message saying they aren't allowed to
vote but the message doesn't say why. However, in this case, many people
might try to click/touch the link/button and will wonder why nothing
happens, so we'll revisit this issue when we change the way we display
the "participation not allowed" messages.

Now the behavior is more similar to the one we get when voting
proposals/debates.
2022-02-21 18:47:13 +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
0bacd5baf3 Remove unused legislation proposals index action
The `legislation_proposals#index` action was never used because it used
the same URL as `legislation_processes#proposals`.

In commit 702bfec24 we removed the view, but we forgot to remove the
controller action, the route, and some partials which were rendered from
the index view.
2022-02-21 18:47:13 +01:00
Javi Martín
5b70c3d89c Merge pull request #4777 from consul/dependabot/bundler/puma-4.3.11
Bump puma from 4.3.10 to 4.3.11
2022-02-21 18:42:14 +01:00
dependabot[bot]
9493a7ed47 Bump puma from 4.3.10 to 4.3.11
Bumps [puma](https://github.com/puma/puma) from 4.3.10 to 4.3.11.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v4.3.10...v4.3.11)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-21 18:24:18 +01:00
Sebastia
5b3669350d Merge pull request #4773 from consul/instagram_typo
Fix typo for "instagram"
2022-01-28 14:49:17 +01:00
taitus
291b478050 Fix typo for "instagram"
This typo was accidentally introduced in commit 3b00f3c141.
2022-01-28 14:30:34 +01:00
Javi Martín
3e89a1dd53 Merge pull request #4301 from consul/unsubscribe
Include link to unsubscribe in email notifications
2022-01-21 20:43:43 +01:00
taitus
7bd1f15f37 Improve translation for the notification of comments
Currently the translation:
"Notify me by email when someone comments on my proposals or debates"
It only refers to proposals and debates, but actually it also refers to budget
investments, topics and polls.
2022-01-21 20:21:52 +01:00
taitus
8b9f478e81 Render the page in the user's preferred locale
We add new method set_user_locale to render the page
with the user's preferred locale.

Note that we add a condition 'if params[:locale].blank?'
to recover the user's preferred locale. This is necessary
because it may be the case that the user does not have an
associated locale, and when execute '@user.locale' when
this value is 'nil', by default returns the default locale.
As we do not want this to happen and we want the locale we
receive as parameter to prevail in this case.
2022-01-21 20:21:52 +01:00
taitus
13965901f8 Update "newsletter" notification email to add unsubscribe link 2022-01-21 20:21:52 +01:00
taitus
1fcbd49448 Update "reply" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.

We also adapted the existing generic text by adding a description of
the related notification.
2022-01-21 20:21:52 +01:00
taitus
3a2564a92d Remove "slashes" from specs
I think the "slashes" can be removed.
The specs work fine without the "slashes".
2022-01-21 20:21:52 +01:00
taitus
478ac3a952 Update "proposal" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.
2022-01-21 20:21:52 +01:00
taitus
a36f3feb87 Update "direct message" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.
2022-01-21 20:21:52 +01:00
taitus
0af765a3bd Update "comment" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.

We also adapted the existing generic text by adding a description of
the related notification.
2022-01-21 20:21:52 +01:00
taitus
2bfdc421ae Allow updating the status of notifications
You can update the same "notifications" section that we allow you to
update in "my account".

This "subscriptions" section differs from the "my account" section
because we do not need to be logged in to update the status of the
notifications.
2022-01-21 20:21:38 +01:00
taitus
6d9e4a9330 Allow users to manage their notifications
The user can access this page without being logged in.
We identify the user through the "subscriptions_token" parameter and
show a list of the notifications that can be enable/disable.

We will return a 404 error in case someone accesses the page with a
non-existent token.

We also control the case that some anonymous user tries to access the
page without any token, by returning the CanCan::AccessDenied exception.
2022-01-21 18:58:38 +01:00
taitus
2bef215fc6 Add method to generate subscriptions_token
Note that we only update a user with a new token if the user has not
yet been assigned one.
2022-01-21 18:58:38 +01:00
Javi Martín
a53813fafe Merge pull request #4767 from consul/poster_asset_path
Fix generating dashboard poster on production
2022-01-18 13:52:20 +01:00
taitus
630ea22ece Add new 'subscriptions_token' column to the users' table
Giving any user a direct link to edit another user's account settings doesn't seem like a
great idea. Instead we'll generate a random secure hash string to help keep things
more secure. We'll store these hashes on each user so that we have a way to find
them during this public query. To do this we need to add a column to the user table.
2022-01-17 13:55:31 +01:00
Javi Martín
c5103d3025 Fix generating dashboard poster on production
In commit 905ac48bb we mentioned:

> Since we don't use `asset_path` to reference assets in the public
> folder, we can safely disable the `unknown_asset_fallback` option.

However, `asset_path` is used by the wicked_pdf gem when calling the
`wicked_pdf_stylesheet_link_tag` method. This method also checks the CSS
files, searching for `url()` calls and converting any relative URLs
referenced there to absolute URLs.

However, when compiling assets on production, our `application.css` file
contains the following line imported from Leaflet which says:

```
behavior: url(#default#VML);
```

When passing this URL to `asset_path` (which is something the wicked_pdf
gem does automatically), it doesn't find the URL, and so this call
crashes unless we enable then `unknown_asset_fallback` option.

Since the dashboard poster is a feature we might remove in the future,
we're avoiding changing a Rails global configuration just for this
feature. So, instead of enabling the `unknown_asset_fallback` option,
we're changing the `poster.pdf` view so it doesn't load all the CSS of
the application but only the CSS it needs.

Note we aren't adding a test case because this bug is only present on
production environments when assets have been precompiled.
2022-01-12 13:45:59 +01:00