Commit Graph

670 Commits

Author SHA1 Message Date
Javi Martín
b9e137619a Simplify the way we provide the title in most cases
This is consistent with the way we're providing the main class.

Note we're still setting the title using a block in more complex cases.
2024-03-23 00:35:47 +01:00
Javi Martín
45c1f93562 Add a link to skip to the main content
While people using screen readers already have keyboard shortcuts to
jump to the <main> tag, there are people who navigate the page with the
keyboard using just the tab key, and for them, this link provides a way
to save time and start reading the main content instead of having to
manually go through all the navigation links every time a new page is
loaded.

Note that we had to add an additional `width: 0` rule because
Foundation's `element-invisible` would apply `1px` and the test checking
for `visible: :hidden` would faile.
2024-03-23 00:35:47 +01:00
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
Sebastia
9e5344b5d7 Merge pull request #5276 from consuldemocracy/order-cards
Allow sorting homepage cards
2024-03-22 10:56:33 +01:00
taitus
bce1474527 Only render position field on table when cards rendered are not headers 2024-03-21 19:00:56 +01:00
coslajohn
529357c980 Merge pull request #5390 Geozone Admin maps
This makes it easier to see if Geojson has been imported correctly.
2024-03-21 18:47:37 +01:00
taitus
f795c18bec Allow sorting widget_cards on sdg section 2024-03-21 18:27:49 +01:00
taitus
e9a7731f49 Do not render "Number of colums" when create a sdg header card
Co-authored-by: Javi Martín <javim@elretirao.net>
2024-03-21 18:08:25 +01:00
Javi Martín
1a22db8b17 Fix link to debates help
This link used to open in a new window, and we accidentally changed that
behavior while refactoring it in commit c2710de5f.

Since we're adding a test for this case, and the Proposals::NewComponent
class is similar, we're adding a test for that class too. In the case of
proposals, we need to sign in a user because the proposals form contains
fields to attach image, that currently rely on a user being signed in.
2024-03-18 15:29:46 +01:00
Javi Martín
bbac39e976 Merge pull request #5426 from consuldemocracy/fix_comment_votes_html
Fix invalid HTML in comment votes
2024-03-18 15:02:25 +01:00
Javi Martín
a101608ebe Fix invalid HTML in comment votes
We forgot to change the `span` tag when we replaced links with buttons
in commit ba0d21b46.
2024-03-05 00:41:53 +01:00
Javi Martín
1d955b7a20 Simplify using helper methods in components
The `use_helpers` method was added in ViewComponent 3.8.0, and it's
included by default in all components since version 3.11.0.

Note we sometimes delegated the `can?` method to the controller instead
of the helpers, for no particularly reason. We're unifying that code as
well.
2024-03-02 17:34:25 +01:00
Pierre Mesure
e5a6a5bf1d Adding clustering 2024-01-29 17:56:54 +01:00
Senén Rodero Rodríguez
0643606dcd Add new setting to enable/disable map marker clustering 2024-01-29 17:56:54 +01:00
Senén Rodero Rodríguez
ea0cedec72 [EXP] Make AJAX settings work when javascript is disabled
Otherwise we get a AuthenticityToken exception.

I was nor able to write a test to verify this change.
2024-01-25 18:29:39 +01:00
Senén Rodero Rodríguez
047cb2b76c Extract SDG configuration tab partial to a component 2024-01-25 18:29:39 +01:00
Senén Rodero Rodríguez
f32d7edcf3 Extract proposals dashboard tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
75180de8e6 Extract images and documents tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
f56dc654f3 Extract map configuration tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
6876f080a2 Extract features tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
726019616f Extract configuration settings tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
347a9d3d5b Extract remote census configuration tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
684a830515 Extract participation processes tab partial to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
f8835debae Move logic from key definition to views
Before this change, two important things depend on the format of each key,
where to render it in the administration panel and which kind of interface
to use for each setting. Following this strategy led us to a very complex
code, very difficult to maintain or modify. So, we do not want to depend
on the setting key structure anymore to decide how or where to render each
setting.

With this commit, we get rid of the key format-based rules. Now we render
each setting explicitly passing to it the type and the tab where it belongs.
2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
91c3bde36b Fix map settings redirection 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
cb91a7421d Fix upload settings redirection 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
1fb351425f Use a plain tab param
Instead of using a setting nested param `setting[:tab]`. We only need
the tab param when rendering settings in the administration section.

This change will make it easier rendering the correct tab after
updating settings.
2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
6a64f38d17 Use admin table settings component to render featured settings
Now, with the same template we can render all kind of settings.
2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
e7223ba865 Extract interactive map form to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
65c6189183 Extract setting text form to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
c9e3b8903d Extract setting content types form to a component 2024-01-25 18:29:38 +01:00
Senén Rodero Rodríguez
57c257e91c Extract settings table partial to a component 2024-01-25 18:29:38 +01:00
Sebastia
c1e0d58291 Merge pull request #5274 from consuldemocracy/last-sign-in
ENS: Add security secret "last_sign_in"
2023-10-24 18:57:18 +02:00
Javi Martín
5aa56c054f Mark external links using the "rel" attribute
This will help search engines know these links point to external sites
and it'll make it possible to style these links using the
`[rel~=external]` selector. AFAIK, assistive techonologies don't use
this attribute to notify people about external links, though.
2023-10-24 16:41:03 +02:00
Javi Martín
79c1aa0755 Fix "rel" attribute in footer description links
We were accidentally filtering this attribute when sanitizing the text
since commit 928312e21.
2023-10-24 16:41:03 +02:00
Javi Martín
8053cc5e1c Open footer description links in the same window
This is a funny one, because we were accidentally opening them in the
same window without intending to do so since commit 928312e21, since the
`sanitize` method removes the `target` attribute. So the test we're
adding already passed without these changes.
2023-10-24 16:41:03 +02:00
Javi Martín
05345fb43c Extract methods in footer component
This way it'll be easier to change and refactor this code.
2023-10-24 16:41:03 +02:00
Javi Martín
219d71baaf Open links to external videos in the same window
Just like we're doing with other external links.

We already mention that it's an external video, so there's no need to
explicitly indicate it in the link.
2023-10-24 16:41:03 +02:00
Javi Martín
56d834783c Open links to social networks in the same window
As mentioned in earlier commits, opening external links in a new
tab/window results in usability and accessibility issues.

Since these links are usually at the top or bottom of the page and
contain icons of well-known sites, IMHO there's no need to even notify
people that these are external links.

Since we're no longer using the `shared.target_blank` translation inside
a sentence, we can remove the space and parenthesis in the translations.
2023-10-24 16:41:03 +02:00
Javi Martín
44f4bdf772 Open links to download files in the same tab
Just like we did for documents in commit cdc5e05d4.
2023-10-24 16:40:52 +02:00
Javi Martín
5c7d87f763 Open admin links in the same window
In the admin section, when clicking on a link that leads to a page in
the public area, sometimes the page was opened in the same window and
sometimes it would open in a new window, with no clear criteria
regarding when either scenario would take place.

This was really confusing, so now we're more consistent and open
(almost) every link in the same window. The main reason behind it is
simple: if we add `target: _blank`, people who want to open those links
in the same window can no longer do so, so we're taking control away
from them. However, if we don't add this attribute, people can choose
whether to open the link on the same tab or to open it on a new one,
since all browsers implement a method to do so.

More reasons behind this decision can be found in "Opening Links in New
Browser Windows and Tabs" [1].

We're keeping some exceptions, though:

* Opening the link to edit an investment on the same tab would result in
  losing all the investment filters already applied when searching for
  investments, so until we implement a way to keep these filters, we're
  also opening the link to edit an investment in a new tab
* For now, we're also opening links to download files in a new window;
  we'll deal with this case in the future

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
2023-10-24 16:31:39 +02:00
Javi Martín
2e217a647a Merge pull request #5283 from consuldemocracy/label_links
Allow links in forms to open in new tabs
2023-10-24 16:30:59 +02:00
Javi Martín
bc1f303551 Merge pull request #5281 from consuldemocracy/pdf_links
Open PDF files in the same tab/window
2023-10-24 16:28:31 +02:00
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
e19c16d4e2 Indicate that links inside labels open in a new window
Most screen readers don't notify when a link is about to open in a new
window [1], so we're indicating it, like we were already doing in most
places with similar links.

We could also add a visual indicator, but since links inside labels
already have accessibility issues, giving more attention to these links
might make matters worse.

[1] https://www.powermapper.com/tests/screen-readers/navigation/a-target-blank/
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
cdc5e05d48 Open PDF files in the same tab/window
Quoting usability experts Jakob Nielsen and Anna Kaley [1]:

> [Opening PDF files in new tabs] is problematic, because it assumes
> users will always do the exact same things with certain file formats,
> which isn’t always the case.

There are many examples of this situation. For example, some people
(myself included) configure their browser so it downloads PDF files
instead of opening them in the browser. In this situation, a new tab is
opened, a blank page is displayed, the file is downloaded, and then
either the tab is closed or the blank page needs to be manually closed.
The end result is really annoying.

Other situations include people who use a mobile phone browser, where
navigating through tabs is generally much harder than doing so on a
desktop browser.

But IMHO the most important point is: every browser already provides a
way to open "regular" links in a new tab, so people can choose what to
do, but if we decide to open the link in a new tab, we take control away
from them, and people who'd like to open the link in the same tab might
feel frustrated.

In these cases, the links either say "download" or include the word
"PDF", so people know in advance that they're going to download/open a
PDF file, and so we're giving them information and, by removing the
`target` attribute, we're giving them control over their browser so they
can choose what's convenient for them.

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs
2023-10-23 18:16:14 +02:00