Commit Graph

79 Commits

Author SHA1 Message Date
cyrillefr
f0e696b972 Replace link with button in letter verification 2025-07-09 13:48:58 +02:00
Javi Martín
b51aa31e6a Use HTML beautifier to indent ERB files
We had inconsistent indentation in many places. Now we're fixing them
and adding a linter to our CI so we don't accidentally introduce
inconsistent indentations again.
2025-03-07 16:31:08 +01:00
Javi Martín
6af8ddd324 Extract component to render the date of birth
We reduce code duplication thanks to that, and make it easier
to change this field.

Note that there was one place where the "16.years" value was
hardcoded. We're moving the test for this case to the
component and changing it so the test doesn't use the default
age.

We're also removing the redundant helper method that had the
same code as a method in the User class which is called
everywhere else.
2024-11-12 15:15:34 +01:00
Javi Martín
431ebeda87 Fix missing "for" attribute in document number label
Since this attribute was missing, the label wasn't correctly associated
with its field.
2024-11-08 15:03:55 +01: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
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
1a098dfcab Add and apply MultilineMethodCallBraceLayout rule
In order for this rule to work effectively when running `--autocorrect`,
we also need to enable the `ClosingParenthesisIndentation` rule.
2023-08-18 14:56:16 +02:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
9b908d7264 Extract component to render account permissions
We were using similar code in four different places; six, if we count
the welcome pages seeds. Reducing duplication in the pages seeds is a
bit tricky because administrators are supposed to edit their content and
might remove the HTML class we use to define styles. However, we can
share the code everywhere else.

Note that there's a bug in the application since we show that level 2
users cannot vote for budget projects but we give them permission to do
so in the abilities model. We're keeping the same behavior after this
refactoring but we might change it in the future.
2022-11-29 18:48:24 +01:00
Javi Martín
6382028142 Use page_path to generate the census_terms URL
We had a link to `/census_terms`, and by looking at the code, it wasn't
so clear where this URL came from.

Using `page_path`, it's easier to understand that it comes from a page
with the `census_term` slug. It also means we'll find this line when
searching for usages of `page_path` in the code.
2022-05-04 16:22:46 +02:00
Javi Martín
231a7aa8ee Remove unused code to track events
We forgot to remove it in commit f28a5cc49.

The generated HTML was invalid, with the error:

> Element meta is missing one or more of the following attributes:
> content, property.
2021-12-30 17:05:07 +01:00
Javi Martín
ae91361edb Use telephone fields in phone number form controls
Using a field with `type="tel"` causes most mobile phone browsers to
show a numeric keyboard which makes it easy to enter phone numbers.

We aren't using a number field because some browsers show "spinners" to
increment/decrement numbers (which doesn't make much sense in a phone
number) and because they don't allow characters like spaces. Phone
numbers can have characters like spaces, dashes, parenthesis, asterisks,
the plus sign, ...

Since phone number formats vary depending on the region, and sometimes
even within the same region several different formats can be used, for
now we aren't offering any kind of format validation. We could offer a
format validation that rejects just letters (although there are cases
where letters are actually allowed). However, this causes issues at both
the server side and the client side.

We could use a client-side validation adding a `pattern` attribute to
the field, but that would be something unlike anything else we use in
the application, and we would need to to write some JavaScript in order
to use a proper error message.

On the other hand, if we add a server-side validation, we might find out
existing users are invalid, and it would be impossible to update them in
the many places where we update users assuming they were valid in the
first place. We'd have to add a rake task to update existing user
records and make sure they contain a valid phone number or create a
setting so this validation only applies to new CONSUL installations.
Another option would be to add a per-form validation, so the phone
number is only validated in pages where it is introduced.

All the mentioned scenarios offer certain complexities. So, for now,
we're keeping things simple.

Co-Authored-By: decabeza <alberto@decabeza.es>
2021-12-16 13:24:26 +01:00
Javi Martín
1632540984 Remove redundant placeholders in forms
Using placeholders having similar (or identical) text as already present
as a label has a few issues.

First, it's a distraction. Reading the same information twice is
useless, requires an extra effort, and might even frustrate users.

Second, if users start typing before reading the placeholder and see it
disappear, they might think they're missing relevant information,
delete what they typed, and read the placeholder. That will get them
nowhere.

Finally, we display placeholders using a text offering very low contrast
against the background, so users don't think the placeholder is an
actual value entered in the field. Using such low contrast makes the
text hard to read, particularly for users with visual impairments.

So we're removing these placeholders.

This commit only deals with placeholder texts with similar (or
identical) texts as the label text. There might be other places where we
should replace placeholder texts with labels, but that's a different
topic.
2021-06-23 19:52:45 +02:00
Javi Martín
6ea9383743 Allow toggling elements with the keyboard
Using `<a>` tags with no `href` means these elements cannot be activated
by keyboard users, so we're replacing them with buttons.

In the future we probably want to add more consistency so all toggle
buttons use the same code. We might also add styles depending on the
`aria-expanded` property.
2021-03-31 13:38:38 +02:00
Senén Rodero Rodríguez
588fac6055 Rename method and placeholder
As `residence_in_madrid` is too specific.

We should port this commit to main repo.
2021-03-02 13:15:15 +01: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
75a28fafcb Sanitize label texts automatically
This way we can remove all those `html_safe` calls and we avoid
potential XSS attacks in label texts.
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
Javi Martín
9ddbd01f91 Use active model translations for labels
The same way we did for Active Record, but this time we do it for models
not inheriting fom Active Record.
2019-10-07 01:56:24 +02:00
Javi Martín
8d9cb4d8e3 Simplify generating checkboxes in forms
Using the block syntax to generate the label with a <span> tag inside
isn't necessary after upgrading foundation_rails_helpers. Before the
upgrade, we couldn't do so because the <span> tag was escaped.
2019-10-06 19:32:04 +02:00
Javi Martín
4f5de5be3b Add aria-describedby attribute automatically
We were manually adding the attribute in many places, but not
everywhere. I'm assuming adding it where we didn't have it is doing no
harm.
2019-10-06 19:32:03 +02:00
Javi Martín
3ea9f3cecf Simplify generating form fields with labels
Instead of generating the label and then a field without a label, we can
directly generate a field with a label.
2019-10-05 16:01:58 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
c62da726b8 Apply SpaceAroundErbTag ERB Lint rule 2019-09-10 20:02:15 +02:00
decabeza
21c6da3767 Use min age to participate setting on verification residence form 2019-03-22 16:15:48 +01:00
Julian Herrero
f6489bc604 Use double quotes in app/views 2019-03-19 12:33:07 +01:00
decabeza
0e1bf2188c Remove unused verification offices url setting 2019-03-06 13:08:35 +01:00
Javi Martín
e34a827c48 Add translations for rails date order
Not doing so caused crashes on applications which don't fall back to
English when a translation is missing.

We're adding them in a separate file so we can exclude it from crowdin
and so translators don't translate symbols as if they were words which
need translation.
2018-12-21 19:31:15 +01:00
decabeza
0bf31bde6c Updates all active to is-active classes 2018-06-06 12:02:13 +02:00
decabeza
0b235d69d4 adds consistency for back links 2017-07-26 18:18:30 +02:00
decabeza
af7807ce9f Updates custom note class to foundation help-text 2017-06-27 10:29:36 +02:00
decabeza
3bcfaeb61a replaces sr-only class to show-for-sr 2017-06-13 17:51:57 +02:00
Fernando Blat
76bc1a7934 Use settings helper 2017-01-03 08:55:17 +01:00
Fernando Blat
ca2370eb7c Manage offices url as a setting 2016-12-29 10:31:38 +01:00
Alberto Garcia Cabeza
42722080fc Changes references to Madrid 2016-07-05 13:47:14 +02:00
palomahnhp
bf5d253e12 Merge branch 'master' into tracking_user_verifications_and_others
Conflicts:
	app/controllers/admin/stats_controller.rb
	db/dev_seeds.rb
2016-04-20 11:44:33 +02:00
palomahnhp
b4ec077f16 Merge remote-tracking branch 'origin/master' into tracking_user_verifications_and_others
Conflicts:
	app/assets/javascripts/application.js
2016-04-20 11:28:06 +02:00
Alberto Garcia Cabeza
7d32f2a4b0 Adds label and placeholder for international numbers verification 2016-04-15 13:09:54 +02:00
Alberto Garcia Cabeza
7648baa240 Adds help for document number on verification 2016-03-15 17:06:14 +01:00
Alberto Garcia Cabeza
f6571662a2 Adds title on links with target blank 2016-03-14 19:32:49 +01:00
Alberto Garcia Cabeza
9dce52a69a Adds title on input checkboxes 2016-03-14 19:32:49 +01:00
Alberto Garcia Cabeza
3ec0971b37 Replaces icons i tags for span 2016-03-14 19:32:48 +01:00
palomahnhp
7d4936b577 track user verification and add statistics of verified users who did not vote proposals 2016-03-13 21:38:05 +01:00
Alberto Garcia Cabeza
3752f3a53b Adds foundation 6 🎉 2016-02-26 19:33:33 +01:00
Alberto Garcia Cabeza
66acbdbb66 Removes unused classes 2015-12-16 11:58:36 +01:00
Alberto Garcia Cabeza
2cbfde8f66 Changes texts on error verification and faqs page 2015-10-23 12:47:04 +02:00
kikito
58728102a6 merges and fixes conflicts 2015-10-20 16:23:51 +02:00
kikito
0d0806c9ae improvements in the letter verification error messages 2015-10-20 16:19:17 +02:00
Alberto Garcia Cabeza
b33553cc1d Adds new styles to verifica page 2015-10-20 15:45:08 +02:00
rgarcia
5fe1bb3eee verifies the letter's code 2015-10-19 22:58:44 +02:00