Commit Graph

18703 Commits

Author SHA1 Message Date
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
9b50173ebd Merge pull request #5284 from consuldemocracy/debian_bullseye
Use Debian Bullseye instead of Buster on Docker
2023-10-24 15:25:39 +02:00
Senén Rodero
f36248fad6 Merge pull request #5303 from consuldemocracy/fix_fnm_setup
Map node binaries whenever `rvm1:hook` is called and evaluate the `fnm_setup_command` dynamically
2023-10-24 15:24:33 +02:00
Javi Martín
834da50901 Merge pull request #5279 from jensconsul/admin_panel_branch
Add information about the project to admin index
2023-10-24 15:23:33 +02:00
Senén Rodero Rodríguez
ddc8cfdfb0 Map node binaries whenever rvm1:hook is called and evaluate the fnm_setup_command dynamically
The previous version worked fine when using Capistrano to deploy a new
release, but it did not work for other commands, like `cap npm install`
or `cap puma:start`, as they do not create a release. Therefore, the
`git:create_release` was never called, and the `map_node_bins` was not
invoked.

Since we need node binaries available to the deploy user when executing
any process that runs the application, like puma, delayed_job, and rake
tasks, among others, it makes sense to load FNM to use the correct Node
version in the same places where Capistrano loads RVM to load the correct
Ruby version.

With dynamic loading of the `fnm_setup_command`, we get the correct path
when deploying a new release and also when running any other capistrano
command that does not deploy a new release.
2023-10-24 12:59:53 +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
cdf859621e Allow links in forms to open in new tabs
We used to open these links in new tabs, but accidentally stopped doing
so in commit 75a28fafc.

While, in general, automatically opening a link in a new tab/window is a
bad idea, the exception comes when people are filling in a form and
there are links to pages that contain information which will help them
fill in a form.

There are mainly two advantages of this approach. First, it makes less
likely for people to accidentally lose the information they were filling
in. And, second, having both the form and a help page open at the same
time can make it easier to fill in the form.

However, opening these links in new tabs also has disadvantages, like
taking control away from people or making it harder to navigate through
pages when using a mobile phone.

So this is a compromise solution.
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
Javi Martín
7c6134fdee Unify the way we display document information
We were displaying documents in five places, and in five different ways.
Sometimes with the metadata in parenthesis after the title, sometimes
with the metadata below the title, sometimes without metadata, sometimes
with an icon in front of the document, and sometimes with a separate
link to download the file.

So we're now displaying the same thing everywhere. Not sure whether this
is the best solution, but at least it's consistent.

We aren't unifying the way we display a list of documents, though, since
different sections look pretty different and I'm not sure whether the
same style would look well everywhere.

Note that we're renaming the `document` HTML class in the documents
table to `document-row` so the styles for the `document` class don't
apply here.
2023-10-23 18:15:54 +02:00
Javi Martín
a2e4b056ee Move documents partials to components
This way it'll be easier to change them.

Note that there were two `.document-link` elements which aren't part of
a `.documents` element. We're renaming the HTML class of the link in
investments because it didn't contain links to download documents and
are slightly duplicating the CSS in the poll answer documents in order
to keep the `word-wrap` property.
2023-10-23 18:10:24 +02:00
Javi Martín
e0c5be10aa Extract mixins to style separators
This way they can be reused in other places.
2023-10-23 15:49:01 +02:00
Javi Martín
5f0a7f4bbc Group show document tests together
While in unit tests it's great to have different tests for different
expectations, system tests are slow, and so it's better to have just one
test for all the expectations related to the same actions.
2023-10-23 15:49:01 +02:00
Javi Martín
a8bd5eb192 Rename document/image fields HTML classes
Using the `document` or `documents` classes meant styles defined for the
public list of documents conflict with these ones.

So now we're using HTML classes that match the name of the Ruby
component classes, as we usually do.
2023-10-23 15:49:01 +02:00
Javi Martín
1e1d7996bb Simplify rendering document/image fields
We were adding <div> tags with the `images` or `documents` HTML class
prettly much every time we rendered a NestedComponent. We're now
including the HTML class inside the component, as we usually do.

We're also rendering the nested components directly, since it's been a
while since the partials were changed to simply render the components.
2023-10-23 15:49:01 +02:00
Javi Martín
00f063b291 Remove unused documents-related CSS
We don't have any elements matching the `.documents .icon-document`
selector.
2023-10-23 15:49:01 +02:00
Javi Martín
f9bb178cb0 Remove obsolete data attribute
This attribute isn't used since commit 88a7a29d2.
2023-10-23 15:49:01 +02:00
Javi Martín
2093083d29 Remove <hr> tags in document fields
We aren't using <hr> tags on any forms containing fields to add/edit
documents, so using this in the dashboard actions form and the
legislation process form was inconsistent.
2023-10-23 15:49:01 +02:00
Javi Martín
6d8f6445bc Remove unused parameter when rendering documents
This parameter isn't used in the `documents/_documents` partial.
2023-10-23 15:49:01 +02:00
Javi Martín
6d59a847eb Unify links to download documents in admin tables
We were using a "Download file" link in one place, while in another
place we had an additional column where the name of the document was a
link to download it.
2023-10-23 15:49:01 +02:00
Javi Martín
bdb92e4161 Remove redundant link to download document
There's a link next to it that does the exact same thing and includes
the word "download", which was confusing in some cases since people
might think that links with different texts lead to different pages.
2023-10-23 15:49:01 +02:00
Javi Martín
1826e3b691 Remove legacy Paperclip columns
We haven't used these columns since commit 7212657c0, and every Consul
Democracy installation has been using Active Storage since version
1.5.0.
2023-10-23 15:49:01 +02:00
taitus
87fc3c572b Add security secret "last_sign_in"
In order to comply with the security measure for the
ENS: "[op.acc.5.r5.2] The user shall be informed of
the last access made with his identity".

We have added a new secret to display the last
access made to the user on the "My account" page.
2023-10-20 08:03:24 +02:00
Javi Martín
13e9b75d9a Merge pull request #5286 from consuldemocracy/dependabot/npm_and_yarn/jquery-3.7.1
Bump jquery from 3.6.0 to 3.7.1
2023-10-18 21:28:01 +02:00
dependabot[bot]
8e27953d78 Bump jquery from 3.6.0 to 3.7.1
Bumps [jquery](https://github.com/jquery/jquery) from 3.6.0 to 3.7.1.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/3.6.0...3.7.1)

---
updated-dependencies:
- dependency-name: jquery
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 20:35:41 +02:00
Javi Martín
e0435153ef Merge pull request #5287 from consuldemocracy/dependabot/npm_and_yarn/jquery-ui-1.13.2
Bump jquery-ui from 1.12.1 to 1.13.2
2023-10-18 18:54:15 +02:00
dependabot[bot]
874ed76e28 Bump jquery-ui from 1.12.1 to 1.13.2
Bumps [jquery-ui](https://github.com/jquery/jquery-ui) from 1.12.1 to 1.13.2.
- [Release notes](https://github.com/jquery/jquery-ui/releases)
- [Commits](https://github.com/jquery/jquery-ui/compare/1.12.1...1.13.2)

---
updated-dependencies:
- dependency-name: jquery-ui
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 16:21:38 +00:00
Javi Martín
087a8b24d3 Merge pull request #5285 from consuldemocracy/dependabot/npm_and_yarn/jquery-ujs-1.2.3
Bump jquery-ujs from 1.2.2 to 1.2.3
2023-10-18 18:20:48 +02:00
Javi Martín
7070b0915b Allow liking/unliking when JavaScript is disabled
Even if pretty much nobody uses a browser with JavaScript disabled when
navigating our sites, there might be times where JavaScript isn't loaded
for reasons like a slow internet connections not getting the JavaScript
files or a technical issue.

So we're making it possible to still use the like/unlike buttons in
these cases.
2023-10-18 18:08:59 +02:00
Javi Martín
38e81f2858 Style "like" buttons to hint they can be unpressed
We added the feature to undo a vote and made it obvious for people using
screen readers using the `aria-pressed` attribute. However, for sighted
people, the only way to know a button can be unpressed is to try to
press it again and see what happens.

The most obvious way to indicate it would be to add a text indicating
that you can undo your vote. However, that'd require changing the design
quite a bit.

So, after trying a few techniques, we're using a classic approach
browsers have used by default for years: using an inset border for
pressed buttons and an outset border for unpressed ones. It might now be
enough, though; we haven't done usability tests to confirm this point.

Since icons to like/unlike comments don't have a border, I'm not sure
what to do in this case; the icons are small and that makes it hard to
style them in a distinct way. So for now we're not changing these icons.
2023-10-18 18:08:59 +02:00
Javi Martín
3482e6e058 Change styles of pressed buttons on hover
Since we were styling pressed buttons the same way as buttons on hover,
a person hovering on the button and then clicking it wouldn't notice
that the buttons had been pressed unless they noticed that the number
and percentages of votes had changes. They wouldn't notice the changes
when unpressing the buttons either, since, after clicking the button,
the cursor would still be over it, and so the hover styles would apply.

Furthermore, it was hard for mouse users to realize that a button could
be unpressed, since the style of pressed buttons didn't change on hover.

So we're now changing the icons on hover without changing the
background. This way all four states (unpressed, unpressed on hover,
pressed, pressed on hover) are styled in a different way.
2023-10-18 18:08:59 +02:00
Javi Martín
11a33c12e3 Increase contrast in like/unlike buttons
The colors we were using (gray for unpressed buttons and green or red
for pressed buttons) didn't contrast well against a white background, so
we're now using darker colors.

However, with darker colors, using solid icons for the unpressed buttons
makes it harder to differentiate when a button is pressed and when it
isn't, particularly for color-blind people.

So we're now using regular icons for the unpressed buttons and solid
icons for the pressed ones.
2023-10-18 18:08:59 +02:00
Javi Martín
1387356c86 Refactor like/unlike buttons SCSS
We were using the same selectors three times. Since we're going to
change that part of the code, we're simplifying it so we don't have to
do the same changes three times.
2023-10-18 18:08:59 +02:00
Javi Martín
0f45dbb896 Simplify border-related rules for like/unlike icons
We were keeping the same style and width when they were pressed, so we
can simply overwrite the color.
2023-10-18 18:08:59 +02:00
Javi Martín
bdcf074392 Use Debian Bullseye instead of Buster on Docker
Debian Bullseye was released in 2021 and Debian Buster only receives
security updates.

Note that the libindicator7 package is no longer available in this
distribution. However, we were only installing it in order to install
chromedriver, which we don't do since commit 59b625a5f, so we don't need
it anymore.
2023-10-18 18:08:31 +02:00
Javi Martín
d2b0acb6b4 Merge pull request #5301 from consuldemocracy/node_js_18.18.2
Update Node.js from 18.18.0 to 18.18.2
2023-10-18 17:59:17 +02:00
Javi Martín
ac5fe3e289 Update Node.js from 18.18.0 to 18.18.2 2023-10-18 17:33:58 +02:00
dependabot[bot]
9cbad7d5a6 Bump jquery-ujs from 1.2.2 to 1.2.3
Bumps [jquery-ujs](https://github.com/rails/jquery-ujs) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/rails/jquery-ujs/releases)
- [Changelog](https://github.com/rails/jquery-ujs/blob/master/RELEASE.md)
- [Commits](https://github.com/rails/jquery-ujs/compare/v1.2.2...v1.2.3)

---
updated-dependencies:
- dependency-name: jquery-ujs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 12:54:13 +00:00
Javi Martín
ed705525cf Merge pull request #5159 from consuldemocracy/npm_packages
Allow adding Node packages as dependencies
2023-10-18 14:53:48 +02:00
Javi Martín
55efcbc198 Merge pull request #5158 from consuldemocracy/node_version
Depend on a specific version of Node.js
2023-10-18 14:52:39 +02:00
Javi Martín
3b6fb85c51 Use node packages to install jQuery and jQuery UI
Other packages depend on jQuery, so that's why these are the first one
we move from the Gemfile to the package.json file.

This way we can also test whether dependabot correctly opens pull
requests to update Node packages.

I've tried several configuration options for the asset pipeline in order
to be able to include images referenced in jQuery UI CSS files. So far,
adding the `node_modules/jquery-ui/themes/base` folder to the assets
paths is the only way I've found to make it work. Hopefully we can find
a better solution in the future so we don't have to study the internals
of every Node package in order to integrate it with the assets pipeline.
2023-10-17 13:12:20 +02:00
Javi Martín
421cbe5441 Use dependabot to update NPM packages
Just like we do with gems.
2023-10-17 13:12:20 +02:00
Javi Martín
daf960add4 Run npm:install when deploying with Capistrano 2023-10-17 13:12:20 +02:00
Javi Martín
ad166fba4c Setup NPM with an empty package.json file
Note that, even if we're excluding the `node_modules/` folder from
version control, we aren't adding it to Capistrano's shared folders
because, when `node_modules` is a symbolic link, NPM removes it when
running `npm install`.
2023-10-17 13:12:20 +02:00
Javi Martín
ed4f8ad6d9 Simplify development environment setup
Rails provides a script that already did most of the steps.
2023-10-17 13:12:20 +02:00