Commit Graph

75 Commits

Author SHA1 Message Date
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
b4b33926cf Fix HTML closing tags
In some places, we accidentally opened the same tag twice instead of
closing it, while in some other places we closed a tag without opening
it in the first place.

We've detected these issues thanks to the HTML Beautifier gem, which
we're about to start using for indentation purposes.
2025-03-07 16:02:07 +01:00
taitus
7c48ba0116 Do not display the cookie banner when JS is disabled 2025-01-23 17:16:57 +01:00
taitus
018b00cd6e Allow managing versions of cookies consent
This can be useful when adding a new cookie or making
modifications that require asking the user again.
2025-01-23 17:16:57 +01:00
taitus
5ffaf7a80e Add scripts component in order to enable/disable vendor scripts 2025-01-23 17:16:57 +01:00
taitus
7407c386a6 Render third party cookies in the management component
Set cookie duration to 365 days based on the AEPD's cookie usage guidelines.

Note from the document: "Cookies with a duration of up to 24 months are
considered acceptable as long as they are periodically updated."
Reference: https://www.aepd.es/guias/guia-cookies.pdf
2025-01-23 17:16:55 +01:00
taitus
dc54fda71b Allow accepting all cookies in consent banner and management component
Create cookie consent "all" when accept all cookies

Set cookie duration to 365 days based on the AEPD's cookie usage guidelines.

Note from the document: "Cookies with a duration of up to 24 months are
considered acceptable as long as they are periodically updated."
Reference: https://www.aepd.es/guias/guia-cookies.pdf
2025-01-23 17:03:30 +01:00
taitus
390c749d24 Add switch to management component for essentials cookies 2025-01-23 16:48:55 +01:00
taitus
c95c80dc32 Create a new component to render checkboxes as switches
https://get.foundation/sites/docs/switch.html
2025-01-23 16:48:55 +01:00
taitus
0121e57fd0 Render more info link in management component 2025-01-23 16:48:55 +01:00
taitus
d35455624f Allow accept essential cookies from management modal 2025-01-23 16:48:55 +01:00
taitus
df34853792 Add link to management modal in footer 2025-01-23 16:48:55 +01:00
taitus
119c4202fe Allow accessing to management modal from cookies consent banner 2025-01-23 16:48:55 +01:00
taitus
5d590a0aee Add modal management for show essential cookies information
Note that in order to avoid display duplicated vertical scroll when
render a modal, we are add an `overflow: unset` rule. This rule
overwrite a vendor rule both in the modal we are adding and in the
modal we already have when creating a budget in admin section.
2025-01-23 16:48:55 +01:00
taitus
d7f701cc9a Add an optional setting with the link to the cookies policy page 2025-01-23 16:48:54 +01:00
taitus
1958a77842 Allow accept essential cookies from consent banner
Set cookie duration to 365 days based on the AEPD's cookie usage guidelines.

Note from the document: "Cookies with a duration of up to 24 months are
considered acceptable as long as they are periodically updated."
Reference: https://www.aepd.es/guias/guia-cookies.pdf
2025-01-23 16:48:53 +01:00
taitus
4c0b6455f6 Add cookies consent banner
Allow enabling from settings admin section.

Note that we set the z-index to 20 in order to will be greater than
the others z-index elements in the application like <header> on
mobile devices.
2025-01-23 16:05:40 +01:00
taitus
a5911f5c6a Modify admin layout to only manage tenants and admins
We only want to render the account link and login items in the header.
And we want only render the Multitenancy and Administrators sections in
the admin sidebar.

We include the administrators management so it's possible to give
permissions to other users to manage tenants.

In order to restrict access to other sections by typing the URL or
following a link, we're only enabling the rest of the routes when we
aren't in the multitenancy management mode.
2024-11-06 11:17:53 +01:00
taitus
1e6901ec34 Add render method to notification item component 2024-11-06 11:07:00 +01:00
Javi Martín
f8f6844ec3 Simplify common HTML attributes using tag.attributes
The `tag.attributes` method was introduced in Rails 7.0.
2024-07-22 18:35:35 +02:00
Javi Martín
647121d13e Allow different locales per tenant
Note that, currently, we take these settings from the database but we
don't provide a way to edit them through the admin interface, so the
locales must be manually introduced through a Rails console.

While we did consider using a comma-separated list, we're using spaces
in order to be consistent with the way we store the allowed content
types settings.

The `enabled_locales` nomenclature, which contrasts with
`available_locales`, is probably subconsciously based on similar
patterns like the one Nginx uses to enable sites.

Note that we aren't using `Setting.enabled_locales` in the globalize
initializer when setting the fallbacks. This means the following test
(which we could add to the shared globalizable examples) would fail:

```
it "Falls back to an enabled locale if the fallback is not enabled" do
  Setting["locales.default"] = "en"
  Setting["locales.enabled"] = "fr en"
  allow(I18n.fallbacks).to receive(:[]).and_return([:fr, :es])
  Globalize.set_fallbacks_to_all_available_locales

  I18n.with_locale(:fr) do
    expect(record.send(attribute)).to eq "In English"
  end
end
```

The reason is that the code making this test pass could be:

```
def Globalize.set_fallbacks_to_all_available_locales
  Globalize.fallbacks = I18n.available_locales.index_with do |locale|
    ((I18n.fallbacks[locale] & Setting.enabled_locales) + Setting.enabled_locales).uniq
  end
end
```

However, this would make it impossible to run `rake db:migrate` on new
applications because the initializer would try to load the `Setting`
model but the `settings` table wouldn't exist at that point.

Besides, this is a really rare case that IMHO we don't need to support.
For this scenario, an installation would have to enable a locale, create
records with contents in that locale, then disable that locale and have
that locale as a fallback for a language where content for that record
wasn't created. If that happened, it would be solved by creating content
for that record in every enabled language.
2024-06-05 16:10:56 +02:00
Javi Martín
1a0f4ec65f Follow Zeitwerk conventions in names with acronyms
We were getting a few errors when trying out Zeitwerk:

```
expected file lib/sms_api.rb to define constant SmsApi

expected file app/components/layout/common_html_attributes_component.rb
to define constant Layout::CommonHtmlAttributesComponent
```

In these cases, we aren't using an inflection because we also define the
`Verification::SmsController` and a few migrations containing `Html` in
their class name, and none of them would work if we defined the
inflection.

We were also getting an error regarding classes containing WYSIWYG in
its name:

```
NameError: uninitialized constant WYSIWYGSanitizer
Did you mean?  WysiwygSanitizer
```

In this case, adding the acronym is easier, since we never use "Wysiwyg"
in the code but we use "WYSIWYG" in many places.
2024-04-11 19:08:01 +02: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
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
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
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
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
taitus
c2f03f869a Add new footer content block
Include a new content block called 'footer_legal' for additional legal footer items.
2023-09-26 17:43:20 +02:00
taitus
75c9b66375 Refactor footer legal links for cleaner code
Removed inline '&nbsp;|' used as a separator between footer legal links.
2023-09-14 09:51:51 +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
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
decabeza
1ff2144830 Show always poll officer menu to officers
Since the change on commit cbbe188d6 we added a Poll.current.any?
condition to show the officing link on admin menu to officers.

That condition doesn't have much sense since Poll results only can be
added after a poll has ended, and there may be only one active poll.
2023-02-17 14:07:02 +01:00
Javi Martín
fe3c9d47fa Make the translation button condition more readable
I was finding this part hard to follow, but after changing the name of
the condition suddenly I understood what was going on.
2023-02-16 17:52:17 +01:00
Javi Martín
2f0327acf8 Use remote translations objects instead of hashes
This way we can simplify the code dealing with the translatable
association.
2023-02-16 17:52:17 +01:00
Javi Martín
fb2b88b10a Simplify styles for the remote translations message
Instead of adding all the styles of a callout and then overwriting half
of them, we can simply add the half we need.
2023-02-16 17:24:34 +01:00
Javi Martín
1778a7563b Use CSS to define alignment in translations message
That way it's possible to override the style without changing the HTML,
which is the hardest code to customize and maintain.
2023-02-16 17:24:34 +01:00
Javi Martín
efc69e8663 Extract component for remote translations button
So we're consistent with the rest of the code in the header, which
renders components and not partials.
2023-02-16 17:24:34 +01:00
Javi Martín
bbd4d3e62d Render components instead of partials in headers
We were using partials to render components in order to ease the
transition of custom code from earlier versions of Consul. However,
that was back in Consul 1.4, and now these views looked a bit messy
since they sometimes rendered components and sometimes they
rendered partials.
2023-02-16 17:24:34 +01:00
Javi Martín
2ac338f51a Remove redundant admin-top-bar element
We weren't using the `admin-top-bar` class since commit e6c1cf774, and
we can always use the `.admin .top-bar` selector if we need to. And the
`row expanded` classes basically give an element a width of 100%, which
is already the default width for block elements.
2023-02-16 17:24:34 +01:00
Javi Martín
49cb6e010b Extract component to render the responsive menu
We were using the same code for the button in both the public and admin
headers, so we're removing the duplication.

Since the menu and the button must go together, and the contents of the
menu are different for different layouts, we're passing these contents
using a block.

Note the ID of the menu was `responsive-menu` in the public section but
`responsive_menu` in the admin section. Since we usually use underscores
for IDs and dashes for classes, we're keeping the one with the
underscore.
2023-02-16 17:24:34 +01:00
Javi Martín
b489923f66 Move menu button to the left in the admin section
So now it uses the same interface and styles as the main layout. On
small screens, it's easier to play with the menu when the button is on
the left because the menu it opens is aligned to the left.

Note that now we can get rid of the title-bar class; we didn't use the
styles in the public area since commit dcec003d0, and we were overriding
all the Foundation styles in the admin area with the exception of the
padding, which we no longer need.
2023-02-16 17:24:34 +01:00
Javi Martín
c553e15a90 Remove usage of top-bar-left class
We don't need it since it's only used for flexbox styles, and we
already have a `flex-grow` rule for the `h1` element which does the
same thing.
2023-02-16 17:07:20 +01:00
Javi Martín
70161720a0 Remove usages of the top-bar-right class
This is one of Foundation's classes that only applies when its
parent element is a flex container, which isn't the case here since
commit dcec003d0.
2023-02-16 17:07:20 +01:00
Javi Martín
d0fcc9022f Move menu and navigation styles to their own files
This way we follow the convention of one stylesheet per component.
Note that we depend on Foundation's `menu` class for some of the
styles and JavaScript behavior, so we're keeping both the `menu` and
`account-menu` classes.
2023-02-16 17:07:20 +01:00
Javi Martín
967bb4d097 Use link_list to render admin login items
This way it's easier to customize this menu.
2023-01-16 14:44:05 +01:00
Javi Martín
c40c6e04e7 Move login links to components
We're trying to be consistent; in the past, we had the partials
"shared/admin_login_items", "layouts/notification_item" and
"devise/menu/login_items". Now we're moving all these partials to
components in the `Layout` namespace.
2023-01-16 14:44:05 +01:00
Javi Martín
e000bd9a61 Hide menu button to managers on small screens
This menu isn't rendered in this case, so the "menu" button to toggle it
did nothing.
2023-01-16 14:44:01 +01:00