Commit Graph

684 Commits

Author SHA1 Message Date
Javi Martín
c655edddde Extract method to render special avatars in comments 2024-04-11 18:48:33 +02:00
Javi Martín
67b1518858 Make comment avatars compatible with RTL languages 2024-04-11 18:48:33 +02:00
Javi Martín
7beb28bf89 Simplify the conditions to render comment avatars
It was hard to understand that the nested `if` could actually be
`elsif`, and the indentation was a bit broken.
2024-04-11 18:48:33 +02:00
Javi Martín
c29ad265c6 Add missing alt attribute to special avatars
The `alt` attribute is mandatory in image tags. In this case, we're
leaving it empty because we also display text showing whether comments
are made by administrators, moderators or organizations.
2024-04-11 18:48:33 +02:00
Javi Martín
2c9c5d9cd4 Extract component to render avatars in comments
This way it'll be easier to add tests for it and refactor it.
2024-04-11 18:48:33 +02:00
Javi Martín
35659d4419 Replace initialjs-rails with custom avatar code
The initialjs-rails gem hasn't been maintained for years, and it
currently requires `railties < 7.0`, meaning we can't upgrade to Rails 7
while we depend on it.

Since the code in the gem is simple, and we were already rewriting its
most complex part (generating a background color), we can implement the
same code, only we're using Ruby instead of JavaScript. This way, the
avatars will be shown on browsers without JavaScript as well. Since
we're adding a component test that checks SVG images are displayed even
without JavaScript, we no longer need the test that checked images were
displayed after AJAX requests.

Now the tests show the user experience better; people don't care about
the internal name used to select the initial (which is what we were
checking); they care about the initial actually displayed.

Note initialjs generated an <img> tag using a `src="data:image/svg+xml;`
attribute. We're generating an <svg> tag instead, because it's easier.
For this reason, we need to change the code slightly, giving the <svg>
tag the `img` role and using `aria-label` so its contents won't be read
aloud by screen readers. We could give it a `presentation` role instead
and forget about `aria-label`, but then screen readers would read the
text anyway (or, at least, some of them would).
2024-04-11 18:48:33 +02:00
Javi Martín
9beb1608c4 Remove alt attribute in avatar images
These images are always displayed next to a username, meaning people
using screen readers were hearing the same username twice in a row.

Even though we're about to replace the initialjs gem, we're making this
change in case so we've got one more test and we can check everything
keeps working after replacing the gem.
2024-04-11 18:48:33 +02:00
Javi Martín
fdfdbcbd0d Add and apply Style/ArgumentsForwarding rule
We were using generic names like `args` and `options` which don't really
add anything to `*` or `**` because Ruby required us to.

That's no longer the case in Ruby 3.2, so we can simplify the code a
bit.
2024-04-11 17:59:40 +02:00
CoslaJohn
c4d8c92ae2 Change the order in which votes are displayed to be in the order they were selected by the voter
Note that the `budget` parameter was added to the `delete_path` method
so it works in the tests; on production, it worked because this
component is only rendered on pages which already have the `budget`
parameter.

Co-authored-by: Javi Martín <javim@elretirao.net>
2024-04-04 18:47:03 +02:00
Javi Martín
05a6021938 Extract methods to get investments in a ballot 2024-04-04 18:47:03 +02:00
dependabot[bot]
f4203909db Bump rubocop from 1.56.4 to 1.61.0
This version fixes false negatives for Lint/SymbolConversion when using
string interpolation, for Style/RedundantArgument when using the safe
navigation operator, for Style/RedundantParentheses when logical
operators are involved and for Style/RedundantReturn with lambda ending
with return. We're applying the new rules.

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.4 to 1.61.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.4...v1.61.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 16:31:10 +02:00
Sebastia
d76f95459e Merge pull request #5369 from consuldemocracy/refactor_comments_specs
Make comments specs faster
2024-03-25 15:04:04 +01:00
taitus
45d82d6e6b Move comments form to component 2024-03-25 07:59:39 +01:00
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
bca3415aa6 Use comments component for investments valuation comments 2024-03-22 08:57:05 +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