Commit Graph

58 Commits

Author SHA1 Message Date
Javi Martín
2b962f2789 Use a <main> tag on every page
Many pages had this tag, but many other didn't, which made navigation
inconsistent for people using screen readers.

Note that there are slight changes in two pages:

* The homepage now includes the banner and the content of the
  `shared/header` element inside the <main> tag
* The budgets index now includes the banner inside the <main> tag

I see both potential advantages and disadvantages of this approach,
since banners aren't necessarily related to the main content of a page
but on the other hand they aren't the same across pages and people using
screen readers might accidentally skip them if they jump to the <main>
tag.

So I'm choosing the option that is easier to implement.

Note we're adding a `public-content` class to the <main> element in the
application layout. This might be redundat because the element could
already be accessed through the `.public main` selector, but this is
consistent with the `admin-content` class used in the admin section, and
without it the <main> element would sometimes have an empty class
attribute and we'd have to use `if content_for?(:main_class)` or
`tag.main` which IMHO makes the code less consistent.

The Capybara::DSL monkey-patch is only done on the `visit` method
because it's the only reliable one. Other methods like `click_link`
generate AJAX requests, so `expect(page).to have_css "main", count: 1`
might be executed before the AJAX request is finished, meaning it
wouldn't properly test anything.
2024-03-23 00:35:43 +01:00
Javi Martín
4954038076 Only re-render my ballot after voting
We were rendering the whole sidebar again, which wasn't necessary since
most of it remains unchanged. This resulted in complicated code to pass
the necessary information to render the same map that was already
rendered. Furthermore, when users had been moving the map around or
zooming out, we were resetting the map to its default settings after
voting, which was potentially annoying.

This also fixes the wrong investments being displayed in the map after
voting; only the investments on the current page were displayed in this
case while the index displayed all of them.
2023-04-27 17:39:56 +02:00
Javi Martín
4243de3062 Move ballot partial to a component
This way it'll be easier to extract methods from its code and modify
them.
2021-10-29 15:23:22 +02:00
Javi Martín
3cd2529791 Fix huge header in participatory budgets
The budget header was supposed to be huge, but only in the participatory
budgets index or show actions. It was still huge, with plenty of empty
space, when there was no budget, or in the "submit my ballot" and
"select a heading" pages.
2021-08-09 20:07:51 +02:00
Alberto
048ca61207 Improve styles for budgets voting phase 2021-03-24 15:50:25 +01:00
Alberto
10eb7f47c8 Use underscores on HTML IDs 2021-03-24 15:48:24 +01:00
Javi Martín
fb8c476fb2 Extract component for ballot investment
Using component inheritance we can remove duplication and share the same
view.
2021-03-24 15:48:24 +01:00
Javi Martín
2552330fe0 Fix "go back" link in ballot page
Since the `@ballot_referer` variable was only set in the lines
controller, it didn't work when we accessed the ballot page without
adding a line.

Note it still doesn't work if we access the ballot page directly by
entering the URL in the browser's address bar.
2021-03-19 15:08:33 +01:00
decabeza
d912b80e74 Move phases header close to phases section 2021-03-11 19:37:58 +01:00
Javi Martín
27e1721348 Remove unnecessary HTML classes
There are negative margins on .expanded.budget elements, and so these
rules are redundant.
2021-03-11 19:37:58 +01:00
Javi Martín
1d42fe54f0 Simplify HTML class for budget header
There were some issues using `.budget.expanded`, like a link having that
class which would force us to a `:not(.button)` selector or similar,
making the CSS more complex.
2021-03-11 19:37:58 +01:00
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00
Javi Martín
82ef5149c5 Remove redundant progress bar
We were displaying two progress bars for the same thing, and hiding one
of them.

Displaying just one of them and readjusting the styles accordingly is a
bit more intuitive IMHO.

We're also getting the text inside the progress bar out of it; its
purpose inside an element with the `progressbar` role is to provide the
same information as the progress bar (which we aren't exactly doing,
although it could be argued that we do), and in order to be accessible
we should provide the same text in the `aria-valuetext` field, which we
aren't doing. This also simplifies our CSS, which was working because we
defined a padding which covered the height of the hidden extra progress
bar and would have needed quite a few changes if we kept just one
progress bar with text inside it. We can also remove a few CSS rules
which we added to override foundation's rules for the
`progress-meter-text` class.
2020-07-30 16:20:00 +02:00
Javi Martín
2216cb91d1 Use local variables in progress bar partial
We were even passing the `ballot` local variable in some places, which
was ignored because we were using instace variables.
2020-07-30 16:20:00 +02:00
Javi Martín
8edcbcfd3b Fix aria-valuenow attibute in ballot progress bar
We were setting it to 0, and so screen reader users might be confused by
it.

The easiest way to reuse the code and using it for both this attribute
and the width of the progress bar is to move this method to the voting
style, just like the other methods used in this view.

Note the progressbar ARIA role might not be right, since this isn't a
task which is "progressing", but an indicator of the amount spent and
amount available, which is exactly what the <meter> HTML5 tag was
designed for.

We might use a <meter> tag in the future. For now, I'm leaving it as it
is because I'm not certain about how well <meter> is supported in
accessibility tools, and because it's definitely not supported in
Internet Explorer 11, which we haven't officially dropped support for.
2020-07-30 16:20:00 +02:00
Javi Martín
ceee25fdc9 Don't re-render the ballot twice
We were rendering an individual ballot, and then rendering all ballots
(including the already rendered one). So we can skip the first part, as
pointed out by microweb10 in the comments of pull request 3036.
2020-07-30 16:20:00 +02:00
Javi Martín
5f726df8be Extract methods showing voting style information
The idea is that different voting styles will display different
information messages.
2020-07-30 16:19:58 +02:00
Javi Martín
ad6d830c1f Make translations more consistent
We're passing the amount as a paramenter to the "remaining" text, so it
makes sense to pass it to the "amount spent" text as well.

Here we're also changing the I18n key to the text saying users can
change their vote, so it's easier to note the text is about changing
their vote, and not about the projects they have voted so far.
2020-07-28 13:06:31 +02:00
Javi Martín
c22e800329 Remove code duplication
We were calling the same method three times.
2020-07-28 13:06:31 +02:00
Javi Martín
a32c0f8154 Remove unused parameter
The `refresh_ballots` partial ignores the `investment` parameter
completely; instead, it iterates over the investments in the
`@investments` instance variable.
2020-07-28 13:06:31 +02:00
Javi Martín
27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +02:00
Javi Martín
6b1864fbcd Sanitize translations instead of using _html
Using the `_html` suffix in an i18n key is the same as using `html_safe`
on it, which means that translation could potentially be used for XSS
attacks.
2019-10-09 19:46:47 +02:00
Javi Martín
61bf9a5c73 Use sanitize instead of html_safe
The difference is `html_safe` allows every HTML tag, including the
`<script>` tag, while `sanitize` only allows tags which are considered
safe. In this case, we want to allow a `<span>` tag in a translation,
and links inside flash messages.
2019-10-08 18:46:21 +02:00
Javi Martín
55a190f44a Remove unneeded _html suffix in I18n keys
This suffix does the same thing as calling `.html_safe` on them. So we
don't need to use it in texts that don't use HTML.
2019-10-08 13:20:22 +02:00
voodoorai2000
a932737881 Delete ballots 2019-05-31 15:43:06 +02:00
decabeza
d7bde5818e Update texts on check my ballot links 2019-03-28 17:16:15 +01:00
Javi Martín
3e4e65ead7 Use double quotes inside ERB
We were using single quotes inside ERB code when that code was inside
HTML double quotes.
2019-03-25 14:58:54 +01:00
Julian Herrero
c87267d34f Use double quotes in app/views/budgets 2019-03-19 12:16:50 +01:00
Julian Herrero
1c35ec99c1 Make budget groups translatable 2019-02-13 12:30:37 +01:00
Julian Herrero
25e1afea48 fix map rendering for budget headings 2018-12-14 15:37:22 +01:00
decabeza
3c8ec4169f improves messages on header 2018-01-09 19:29:36 +01:00
decabeza
3bcfaeb61a replaces sr-only class to show-for-sr 2017-06-13 17:51:57 +02:00
decabeza
cd4d37470b removes bold on links and make consistent text 2017-05-11 17:24:39 +02:00
decabeza
57d5e40fbb improves ballot list on sidebar 2017-05-11 13:12:26 +02:00
Juanjo Bazán
fce60b9d9a changes heading amount info into a link in ballot view 2017-05-09 13:14:03 +02:00
Juanjo Bazán
4ae6ec75e7 adds links in ballot view to no voted groups 2017-05-09 11:27:07 +02:00
Alberto Garcia Cabeza
c0afb94cfa improves ballot page when shows several groups 2017-05-08 14:33:07 +02:00
Raimond Garcia
aa43d43b73 Merge pull request #1525 from consul/ballot-reviewing
Display correct heading name when reviewing ballot
2017-05-08 13:50:18 +02:00
Juanjo Bazán
216b60f22e orders groups in ballot view 2017-05-08 13:27:17 +02:00
Juanjo Bazán
39ed526b89 displays correct heading name when reviewing ballot 2017-05-08 13:22:53 +02:00
rgarcia
8e7ca16c47 makes ballot's back link point to referer 2017-05-05 20:07:24 +02:00
rgarcia
b84ec0857c fixes specs 2017-01-09 11:02:15 +01:00
kikito
b7a0aa3b57 Fixes i18n errors now that they are detected by i18n-tasks 2017-01-06 19:55:23 +01:00
Alberto Garcia Cabeza
54691fe7f4 improves styles for budgets ballot 2017-01-05 20:37:34 +01:00
Alberto Garcia Cabeza
f503c492f3 improves styles for budgets investments ballot and votes 2017-01-05 17:43:57 +01:00
kikito
28e6a10382 Hides balloting controls when not in the balloting phase 2017-01-05 15:17:49 +01:00
kikito
bbb8ac830c Fixes erroneous i18n param in view 2016-12-23 18:37:02 +01:00
kikito
eb648b7269 Adds missing parameters to partials 2016-12-22 20:27:01 +01:00
kikito
7acedb30f6 fixes parenthesis 2016-12-22 20:26:39 +01:00
kikito
4434a601d3 Implements several helper methods for formatting amounts 2016-12-14 11:49:16 +01:00