Commit Graph

92 Commits

Author SHA1 Message Date
decabeza
a851048d56 Allow users to remove their support on investments
Note we don't cast negative votes when users remove their support. That
way we provide compatibility for institutions who have implemented real
negative votes (in case there are / will be any), and we also keep the
database meaningful: it's not that users downvoted something; they
simply removed their upvote.

Co-Authored-By: Javi Martín <javim@elretirao.net>
Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
2021-06-14 14:46:54 +02:00
Javi Martín
5fab843184 Simplify managing investment votes
If I'm right, the `investment_votes` instance variable only exists to
avoid several database queries to get whether the current user has
supported each of the investments.

However, that doesn't make much sense when only one investment is shown.
In this case, the number of queries stays the same, and so we can
simplify the code by rendering the component with an optional parameter.
2021-06-14 14:41:51 +02:00
Javi Martín
d5f4313f59 Simplify getting URL to support an investment
We're also changing the method name to `vote_path` in order to be
consistent with the way Rails uses `_path` for relative URLs.
2021-06-14 14:38:34 +02:00
decabeza
b23fe300f5 Add supports info section on budgets index page 2021-06-14 13:48:44 +02:00
Javi Martín
bb958daf05 Replace support investment link with a button
Using links combined with JavaScript to generate POST requests to the
browser has a few issues.

An obvious one is that it doesn't work for users without JavaScript
enabled (which lately I've noticed are more common than I thought, even
though I've been one of them for years). These users will reach a 404
page.

Since CONSUL isn't currently designed to work without JavaScript
enabled, let's ignore this one for now.

A not so obvious issue is screen reader users might expect the link to
take them somewhere instead of performing an action (in this case,
sending a form to the server).

There might be more issues I'm unaware of. Quoting DHH [1]:

"Turning ahrefs into POSTs is a bit of an anti-pattern, especially for
a11y reasons. Better to use button_to with a styling."

So we're using a button instead. This way we can also simplify the code
and make the button disabled for unidentified users, which automatically
makes it impossible to focus it using the keyboard.

A possible disadvantage of using `button_to` is it will create a form
tag which will be announced to screen readers as a form landmark. I've
tested it with my screen reader and everything worked fine for me, but
some screen reader users might interact with these forms in a different
way and find it confusing, particularly in the case where the button is
disabled.

With this change, we're only changing links for buttons in one place.
There are other places where we should do similar changes.

[1] See issue 33 in https://github.com/hotwired/turbo-rails/
2021-06-14 12:51:41 +02:00
Javi Martín
de436e33a4 Use a component test to check a link title
In regular system tests, we prefer testing against the text of the link
because it's easier to recognize which link we're talking about.

I was wondering whether we should remove the `title` attribute
completely and use just the `aria-label` attribute. Quoting The Paciello
Group blog [1]:

"If you want to hide content from mobile and tablet users as well as
assistive tech users and keyboard only users, use the title attribute."

However, there's a case where mouse users might find the title attribute
useful. When visiting an investment page, the connection between the
"Support" link and the investment is not as clear as it is in the
investments index page, so it might not be clear what you're supporting.

As mentioned, though, this information will only be relevant for mouse
users, who nowadays represent less than half of our users.

[1] https://www.tpgi.com/using-the-html-title-attribute-updated/
2021-06-14 12:51:41 +02:00
Javi Martín
42ffc62d12 Add investment name in vote link aria-label
This way blind screen reader users will know which project they're
supporting. In a list of investments, context might not be clear when a
link saying "Support" or "Support this project" is announced, but a link
saying "Support Renovate sidewalks in Main Street" is less ambiguous.
2021-06-14 12:51:41 +02:00
Javi Martín
da11c0d7ba Fix empty support link for screen readers users
When identified users accessed the investments page, we were using the
`aria-hidden` attribute to hide this link from screen readers since
unidentified users can't support investments.

However, the link was still focusable using keyboard navigation. This
resulted in screen reader users reaching the link and being able to
click it, but getting no feedback at all about where they were or what
they were clicking on.

This is why the fourth ARIA rule says: "Do not use role="presentation" or
aria-hidden="true" on a focusable element" [1].

So we're replacing the link with a non-interactive element instead, like
we do in other places like proposals.

The accessibility of this part of the page for unidentified users still
has some issues; here we're only improving it up to a certain point.

[1] https://www.w3.org/TR/using-aria/#4thrule
2021-06-14 12:51:41 +02:00
decabeza
122195e33c Show a preview list of investments in the budget landing page
Note one of the tests dealing with random results is a bit flaky; since
it's a permutation selecting 7 objects out of 12, it will fail about
once every 4 million times. We think this is acceptable.

Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
2021-06-11 19:32:21 +02:00
Julian Herrero
17b4fb58c9 Add type to budget index table
Co-Authored-By: decabeza <alberto@decabeza.es>
2021-06-11 00:51:52 +02:00
taitus
b1b2cfa8b1 Add new time format :short_datetime
Improve DurationComponent  for render time without seconds.
I believe that adding the seconds in this component is not necessary.
2021-06-10 17:14:01 +02:00
Julian Herrero
db9ac79e05 Add main link to each phase of the budget
Co-authored-by: decabeza <alberto@decabeza.es>
2021-06-09 21:51:39 +02:00
decabeza
d78f2e03ad Render link to budget header
- Allow to define a link (text and url) on budget form for render on the budget
header.
- Improve styles

Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2021-06-09 19:16:55 +02:00
decabeza
090f1bcddb Not showing the phase description in the budget header
This description of the current phase is already being displayed on the same page
in the section "Participatory budgets phases"
2021-06-09 16:03:33 +02:00
decabeza
4adb7236dc Add title to budget header 2021-06-09 16:03:33 +02:00
Senén Rodero Rodríguez
26d14cbd04 Move system specs to subheader component specs
As the are much faster.

Keep a system spec to check the component is called from the view.
2021-06-09 16:03:32 +02:00
Senén Rodero Rodríguez
822140a147 Move systems specs to budget component
As they are much faster.
2021-06-09 16:03:32 +02:00
decabeza
f8008a4a6f Add link to remove budget on budget admin index 2021-06-08 18:45:55 +02:00
Julian Herrero
f8d6ba12d7 Add headings step to budget creation
Co-Authored-By: decabeza <alberto@decabeza.es>
2021-06-08 18:45:53 +02:00
Javi Martín
82e8de094b Extract budget form to a component
This way it will be easier to change it and reuse it.
2021-06-08 14:25:43 +02:00
Javi Martín
93a7d28a82 Fix crash with budgets with no published phases
In this case, the duration of the budget cannot be determined, and the
application was crashing when trying to do so.

Now we're just returning `nil` as duration.
2021-06-02 18:00:17 +02:00
Javi Martín
69ade5b131 Fix crash with budgets with disabled current phase
There's an edge case where the current phase of the budget was disabled.
In this case, the application was crashing.

I'm not sure what we should do regarding this case. Is it OK to allow
disabling the current phase? Is it OK to allow selecting a disabled
phase as the current phase?

Since I'm not sure about it, for now I'm leaving it the same way it was.

Co-authored-by: Julian Herrero <microweb10@gmail.com>
2021-06-02 18:00:17 +02:00
Javi Martín
5f92252054 Fix exception using locales with no help images
In commit 905ac48bb we activated exceptions when assets were not found,
in order to detect places where we were trying to load non-existent
images.

We got an exception for that reason: we were loading images based on the
current locale, but for some locales there was no images.

We're now using fallbacks and loading another image when the original
one isn't available.

Note we're copying the English images to images with a generic name for
the case where there's no fallback with an image. We're copying the
files instead of using symbolic links to make sure they can be
overwritten independently in other CONSUL installations.

Also note we're updating the HTML so the section gets the ID instead of
the header. That way the system test is simple.
2021-05-29 15:05:29 +02:00
taitus
85611a5103 Adding consistency for post_started_at and post_ended_at on specs
These two fields are of type Date and in some specs they are being
filled as Time or DateTime.
2021-04-08 17:23:33 +02:00
Javi Martín
b93f38ec11 Extract banner test to a component
Checking the `style` attribute fails in JavaScript tests because the
browser converts colors to the `rgb()` format.

So we're testing the generated HTML in a component test while
simplifying the system test.
2021-04-07 14:32:49 +02:00
decabeza
04605d5d5b Add filters on budget investments index page
Now it's easier to change the investments filter. Previously we had to
go back to the budget index page, change the filter there, and then
select one heading.

Now the links to change the current filter in the budget index page
aren't needed anymore.
2021-03-17 13:44:01 +01:00
Julian Herrero
d2871d7770 Include duration in budgets table 2021-03-11 19:37:58 +01:00
taitus
d26607183e Add sdg help page
In this page we will render a list of clickable Goals icons that will show their
targets and related local targets

Co-authored-by: Senen <senenrodero@gmail.com>
2021-03-02 14:45:18 +01:00
taitus
522684cd2f Adapt targets component to render on sdg help page
This component was rendered on different pages so there were no conflicts
with static id's.
Now in the SDG help page we are going to render them all at once, so we
convert the static identifiers to dynamic.
2021-02-26 16:36:40 +01:00
taitus
4a880fc1c5 Render header on sdg index page
We no longer show the static header when we have created a
custom header.
2021-02-26 16:20:57 +01:00
Javi Martín
da7846c6d5 Merge pull request #4361 from consul/sdg_per_budget_stats
Split investment projects statistics by participatory budget
2021-02-26 14:41:13 +01:00
Senén Rodero Rodríguez
ebe8903c75 Investment projects statistics by participatory budget
The more recent budgets show first.

The current budget will only show the amount of sent investments
until the winner's phase.
2021-02-26 14:08:45 +01:00
Javi Martín
45517f659e Add SDG goals/targets to legislation proposals 2021-02-24 20:42:53 +01:00
decabeza
7eda4be219 Add link to preview budget on budgets table 2021-02-23 17:05:24 +01:00
Javi Martín
7d4e49a090 Reorganize SDG tag list components
So now we've got a component receiving records (goals or targets) and a
related model (Debate, Proposal, ...), with optionally a link to see
more tags.

This way we simplify some logic since the `TagList` classes were dealing
with too many cases (a record is passed, a class name is passed, a limit
is passed), ... Now `TagList` only deal with the natural `TagList` case,
which is listing the tags for a record. The case where a class name is
passed is used in the `TagCloud` class.
2021-02-02 22:22:40 +01:00
Javi Martín
999d1a2cfd Rename goals FilterLinks component to TagCloud
This is more consistent with the "tag_cloud" partial name.
2021-02-02 22:22:39 +01:00
taitus
35db41827c Add tag list component to process feed
Remember that this component (widget/feeds/process) is displayed both in
the home page and in the target index.
2021-01-31 13:53:57 +01:00
taitus
ca36dd56f0 Add tag list component to proposal feed 2021-01-31 13:53:57 +01:00
taitus
edbef4fd88 Add tag list component to debate feed 2021-01-31 13:53:57 +01:00
Senén Rodero Rodríguez
bb1315def1 Prepare SDG tag list component to render list with or without links
Now the tag list can render tags with or without links, so we need
to adapt the styles slightly.

We want to use the same text color for tags without links.

The hover style is only needed when using tags with links.
2021-01-31 13:33:26 +01:00
Senén Rodero Rodríguez
cc2ce38d13 Create SDG target component to render plain tags 2021-01-31 13:33:25 +01:00
Senén Rodero Rodríguez
54843c1e53 Create SDG goal component to render plain tags 2021-01-31 13:33:25 +01:00
taitus
857a6aa228 Add targets component to render all targets in tabs section 2021-01-29 14:15:58 +01:00
Javi Martín
5044c424b6 Merge pull request #4334 from consul/sdg_show_section_header
New header section on SDG Goals Index
2021-01-29 14:14:44 +01:00
taitus
7a02ce9c08 Add sdg section header on SDG IndexComponent
Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-28 20:02:46 +01:00
Javi Martín
5f3279b9db Extract search form component in SDG Management
We're going to add some JavaScript which affect this component, and IMHO
it will be easier to know the JavaScript affects this form if both have
their own separate file.
2021-01-28 13:41:23 +01:00
Javi Martín
3018de2847 Merge pull request #4324 from consul/sdg_target_filter
Add SDG target tags and filter
2021-01-27 16:48:12 +01:00
Javi Martín
1fefc910d6 Add list of targets to SDG tag list
Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2021-01-27 16:21:40 +01:00
taitus
6c7a8d31b1 Add read more and real less on long description
In the spec we added in system/sdg/goals_spec.rb we couldn't use
either click_link or find_link, because the link to show/hide the
long description doesn't have the href attribute.
2021-01-27 15:56:08 +01:00
Javi Martín
b0a6c20bc0 Add long description to goals 2021-01-27 15:49:46 +01:00