Commit Graph

15545 Commits

Author SHA1 Message Date
Javi Martín
e19bc594d8 Merge pull request #4274 from consul/admin_menu
Simplify code in the admin menu
2020-12-02 11:20:08 +01:00
Javi Martín
bdf30aa14e Use CSS to display icons in the admin menu
This way we simplify the HTML and generating similar menus will be
easier. We also improve the experience for screen reader users, who
might have been hearing the icons as text because we weren't using the
`aria-hidden` attribute.

We're still keeping the "icon-" classes for compatibility with CONSUL
installations which might have changed this code.
2020-11-27 12:33:42 +01:00
Javi Martín
d99ca9bd34 Use CSS to make items bold in the admin menu
From a semantic point of view, there's no reason to add a strong
emphasis to the menu items.

Besides, using CSS simplifies the code and is less error-prone. For
instance, the "stats" section didn't have a <strong> tag, and so it was
the only one which wasn't bold.
2020-11-26 20:04:08 +01:00
Javi Martín
615bb050e8 Remove unnecessary section-title class
It isn't used anywhere, and we could achieve the same result using the
CSS child selector `> li`.
2020-11-26 20:04:08 +01:00
Javi Martín
e3bca85321 Extract methods in admin menu component
Now that there's no naming confict with the helper method used in the
ProposalsDashboardHelper, we can easily simplify the view, moving the
logic to the Ruby class.
2020-11-26 20:04:08 +01:00
Javi Martín
60b3ca000a Fix typos in admin menu classes
The HTML `class` attribute was declared twice and so the second one was
being ignored.

In the case of messages, it was "working" properly because the
`class=is-active` part is not used on `<li>` tags when they've got a
`<ul>` inside them.
2020-11-26 20:04:08 +01:00
Javi Martín
f9e110aa9b Simplify method names in admin menu component
We no longer need to use the `menu_` prefix, since now these methods
aren't helper methods anymore, and so their names won't collide with
other helpers.
2020-11-26 12:15:07 +01:00
Javi Martín
d501915954 Extract admin menu to a component
This way adding new methods will be easier.
2020-11-26 12:15:07 +01:00
Javi Martín
1fc74e7cfa Merge pull request #4239 from consul/layout
Simplify main layout styles
2020-11-23 18:23:33 +01:00
Javi Martín
bb2e2fa0a3 Move main <h1> tag inside main header
A <header> tag is the natural place to have headings.

Since we already had the logo there, IMHO it makes sense to merge both
the <h1> tag and the logo together. We were already doing so in the
devise layout.

From the sceen reader users' point of view, having a link with the text
"CONSUL logo" is a bit confusing, since it seems to imply the link will
get us to the CONSUL logo. Using the organization name as the text of
the link makes more sense.

One thing changes, though. Before this commit, the first thing on the
page a screen reader user would hear about would be the organization
name. Now the language selector and the top links are announced before
the organization name is read. That's fine, since the actual first thing
these users will hear is the content of the <title> tag, which contains
the organization name as well.
2020-11-23 18:05:43 +01:00
Javi Martín
18813c8f2a Specify styles are meant for the main header
The <header> tag is a standard HTML tag which can be used in any section
of the page. We were adding the main header styles to all <header> tags
because in the past it was in only <header> tag we used.

That's not the case anymore, so instead of overwriting these styles on
every other <header> tag, modifying the rule so it only selects the main
header makes the code easier to maintain.
2020-11-23 18:05:43 +01:00
Javi Martín
d4a360c7fb Simplify main layout styles
We were using a "push" div in order to force the footer to the bottom,
and were using a wrapper with a minimum height and negative margins.

The same thing can be accomplished using flex and making the wrapper
fill the empty space, which in my humble opinion simplifies the code and
makes it easier to follow.

We could further simplify the code by removing the wrapper div or the
footer wrapper, although I'm not sure the benefits overcome potential
inconveniences caused to other institutions who might have custom styles
based on the existence of these wrappers.
2020-11-23 18:04:55 +01:00
Javi Martín
682f374598 Merge pull request #4268 from consul/fix_badge
Fix build status badge
2020-11-23 15:23:48 +01:00
Javi Martín
cb596a8163 Fix build status badge
As mentioned in the GitHub Actions documentation [1]

> Note: Referencing the workflow file using the file path does not work
  if the workflow has a name.

[1] https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/adding-a-workflow-status-badge
2020-11-23 15:06:20 +01:00
Javi Martín
ccb8e0970f Merge pull request #4265 from consul/actions
Run the test suite using GitHub Actions
2020-11-23 14:19:06 +01:00
Javi Martín
af1943284b Downgrade sassc to version 2.1.0
Version 2.2.x seems to cause some issues with Ruby 2.6, as mentioned in
the comments of issue 146 in the sassc-ruby repository.

Due to these issues, our test suite was failing sometimes when running
on GitHub Actions.
2020-11-23 14:00:36 +01:00
Javi Martín
9c4d24d767 Use Knapscack Pro to run tests in parallel
Just like we used to do with Travis.

The configuration was taken from the Knapsack Pro documentation [1].

[1] https://docs.knapsackpro.com/2019/github-actions-ci-config-for-ruby-on-rails-project-with-mysql-redis-elasticsearch-how-to-run-parallel-tests
2020-11-23 14:00:36 +01:00
Javi Martín
375134ea04 Run the test suite using GitHub Actions
Using GitHub Actions has a few advantages over using Travis CI:

* More jobs can be run in parallel
* All CONSUL repositories on GitHub will be configured automatically

Besides, Travis have recently changed their policy twice. First, they
announced their site for free software projects would be shut down but
free software projects could still use their site for private projects.
And then, they limited the usage of their services for free software
projects.

Just like we used to do with Travis, we're enabling builds for pull
requests but not for pushed branches.

We're also building the master branch. Even if we never push to the
master branch directly, we're aware other CONSUL repositories do, so
we're running the tests for this case.
2020-11-23 14:00:33 +01:00
Javi Martín
64205ab15f Merge pull request #4238 from consul/footer_links
Use CSS to style footer links
2020-11-19 17:19:04 +01:00
Javi Martín
8c38bceff6 Merge pull request #4237 from consul/fix_blank_space_after_footer
Remove blank space after footer
2020-11-19 15:39:20 +01:00
Javi Martín
d7a9be3108 Merge pull request #4261 from consul/tooltip_width
Fix table icon tooltips with long texts
2020-11-17 20:46:03 +01:00
Javi Martín
a05e9da99a Fix table icon tooltips with long texts
Combining the max-width and the white-space property resulted in the
text exceeding its bounds if the text was longer than what the max-width
property allowed.

The `width: max-content` property, on the other hand, is compatible with
the max-width property.
2020-11-17 17:57:38 +01:00
Javi Martín
b5eed8c3ab Merge pull request #4255 from consul/legislation_toc
Fix legislation draft version TOC width
2020-11-17 15:31:26 +01:00
Javi Martín
0961cf464c Use CSS to make Table of Contents sticky
Originally we were using Foundation's sticky, which wasn't entirely
compatible with our way to open/close the Table of Contents because its
width would not automatically be updated when the TOC was opened/closed
but when users scrolled the page.

Using CSS, which is now supported in most browsers, simplifies the
matter. On browsers like Internet Explorer, where it's not supported,
the content will not stick but other than that it'll work fine.

We're also adding `scroll: auto` so when the TOC's height will be large
than the page, it'll be possible to scroll it, which users couldn't do
in the original version.
2020-11-17 14:48:48 +01:00
Javi Martín
48daf22f31 Make draft version content use the empty space
Now that comments and TOC can be closed at the same time, we use a flex
layout so the main content uses the available width.

We're also making the comments work better on medium-sized screens,
since previously they had a fixed width and now the width is adapted to
the size of the screen.

Since now the comment box element has a relative position instead of an
absolute one, we need to consider the draft panel height when
calculating the comment box position.
2020-11-17 14:48:48 +01:00
Javi Martín
41e5ddbcdf Use details tag to show/hide a draft version TOC
We were using JavaScript to show/hide the Table of Contents.

In my humble opinion, the <details> tag has a few shortcomings [1][2],
which means we should be careful about when to use it.

IMHO a Table of Contents is a good candidate for this tag because it's a
very common pattern to add a show/hide behavior for it, even if using it
means the "navigation" role (which we are *not* using anyway) wouldn't
be identified correctly.

I'm adding a <details> tag to the comments section as well for
consistency and in order to simplify the code. I'm not sure this is as
good an application of the <details> tag, though, but then again I'm not
sure about the interface we use to show/hide the comments (and this
feeling is increased by the fact that we use a different interface on
small screens). If we decide to change the interface in the future, we
might consider using the <details> tag for the Table of Contents but not
for the comments.

Since the <details> tag is not supported on Internet Explorer, I'm
only adding styles to this tag using the `:not([open])` option. On
Internet Explorer <details> will always be opened and so these styles
will be ignored.

[1] https://adrianroselli.com/2019/04/details-summary-are-not-insert-control-here.html
[2] https://daverupert.com/2019/12/why-details-is-not-an-accordion/
2020-11-17 14:48:48 +01:00
Javi Martín
220b1de01e Remove duplicate text in table of contents
We were using different divs to show the same text in different
positions, but we can use the same one and rotate it when appropriate.
2020-11-16 19:43:45 +01:00
Javi Martín
d0cb26c086 Use CSS to style footer links
This way additional elements added through the "footer" content block
will also have the same styles.
2020-11-08 14:02:12 +01:00
Javi Martín
09a7724307 Remove blank space after footer
In commit a8537f7e1 we added a `height: 100%` rule on links inside
cards, which is great for cards in the "Featured" section of the
homepage. However, the card in the "Open processes" section of the
homepage has as many links inside as open processes, causing its height
to be 300% if there are three processes and so expanding below the
footer.
2020-11-07 12:02:45 +01:00
Javi Martín
28b282df12 Remove unused deployment configuration variables
The server_name variable isn't used since we removed the Apache task in
commit 012d5297e, db_server and config_files aren't used since we
removed the capistrano templates in that same commit, and full_app_name
isn't used since commit 94a7e13dc.
2020-11-04 16:52:43 +01:00
Javi Martín
724a3f802b Merge pull request #4218 from consul/table_icons
Use icons in admin table actions
2020-11-04 13:22:25 +01:00
Javi Martín
a1cae895ba Use the actions component to render phase actions
We forgot to include this table when refactoring in commit 738646a56.
2020-11-03 14:58:02 +01:00
Javi Martín
9794ffbbf8 Use icons in admin table actions
The planned budget investments redesign includes using icons in some
tables, so we might as well use them everywhere.

The original design used Foundation to show the tooltips. We're using
CSS in order to keep the ERB/HTML code simple. One advantage of using
CSS is we can show the tooltip on focus as well, just like accessibility
guidelines recommend [1]. On the other hand, Foundation tooltips appear
on the sides when the link is at the bottom of the page, making sure
they're visible in this case, while CSS tooltips do not. Neither CSS
tooltips nor Foundation tooltips are dismissable, which might be an
accessibility issue.

Note we aren't changing any ERB files in order to replace links with
icons; we're only changing CSS and one line of Ruby code.

[1] https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus
2020-11-03 14:58:02 +01:00
Javi Martín
8c1140a1bf Use semantic HTML classes in table actions
Note the CSS could probably be improved to avoid duplication with other
button style definitions. However, that's fine because we're going to
change the style of the links soon.

For the same reason, I haven't bothered to style every single link the
way it was until now.
2020-11-03 14:58:02 +01:00
Javi Martín
ccb7695056 Use a custom link_to method for table actions
This way we'll be able to change the behavior of these links without
changing the view nor affecting the rest of the application.
2020-11-03 14:58:02 +01:00
Javi Martín
99dad7a7b6 Don't mix links and actions in an admin table
In some tables, we had "actions", and some columns were also links
pointing to some places. Having both of them at the same time is
confusing, particularly since traditionally the links in the columns
pointed to the same place as some of the actions (although that's not
the case since commit 48db31cd).

We're still keeping links in tables which don't have an action column.
For instance, the proposals table has a "select" button which would be
harder to use if we had action buttons next to it.
2020-11-03 14:58:02 +01:00
Javi Martín
beaff17bec Merge pull request #4202 from consul/dependabot/bundler/pg_search-2.3.4
Bump pg_search from 2.3.0 to 2.3.4
2020-11-03 12:39:06 +01:00
Javi Martín
1ac8085aa9 Merge pull request #4206 from consul/svg_icons
Allow loading icons from SVG files
2020-11-03 12:26:55 +01:00
dependabot-preview[bot]
c9245ccdc5 Bump pg_search from 2.3.0 to 2.3.4
Bumps [pg_search](https://github.com/Casecommons/pg_search) from 2.3.0 to 2.3.4.
- [Release notes](https://github.com/Casecommons/pg_search/releases)
- [Changelog](https://github.com/Casecommons/pg_search/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Casecommons/pg_search/compare/v2.3.0...v2.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 18:06:05 +00:00
Javi Martín
df6b3ff3b1 Merge pull request #4199 from consul/dependabot/bundler/rollbar-3.0.1
Bump rollbar from 3.0.0 to 3.0.1
2020-11-02 18:36:50 +01:00
dependabot-preview[bot]
6ca9c7136e Bump rollbar from 3.0.0 to 3.0.1
Bumps [rollbar](https://github.com/rollbar/rollbar-gem) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/rollbar/rollbar-gem/releases)
- [Changelog](https://github.com/rollbar/rollbar-gem/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollbar/rollbar-gem/compare/v3.0.0...v3.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 16:59:49 +00:00
Javi Martín
af93f135b0 Merge pull request #4146 from consul/dependabot/bundler/savon-2.12.1
Bump savon from 2.12.0 to 2.12.1
2020-11-02 17:57:30 +01:00
dependabot-preview[bot]
136b4a51dd Bump savon from 2.12.0 to 2.12.1
Bumps [savon](https://github.com/savonrb/savon) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/savonrb/savon/releases)
- [Changelog](https://github.com/savonrb/savon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/savonrb/savon/compare/v2.12.0...v2.12.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 16:41:22 +00:00
Javi Martín
8ae725c234 Merge pull request #4188 from rockandror/remote_census_api_spec
Refactor RemoteCensusApi spec to use a XML response
2020-11-02 12:55:22 +01:00
Senén Rodero Rodríguez
265f8dbf01 Connect to the service only when remote census endpoint is defined
Also return an invalid response when the endpoint is not defined.

This will allow to test remote web services on development environments.
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
ac6260a2ef Mock remote census responses in tests using XML
By using real XML responses developers will be able to understand better
how the integration works (the data flow), and the correspondency between
`remote_census` settings and their place at a real XML response.

As `stubbed_responses` methods were removed from the model layer now the
stubbing part should be managed from the test environment code so also
added a new helper module `RemoteCensusSetup` that can be used anywhere
where we need to call the web service.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-11-02 11:42:39 +01:00
Javi Martín
8257a82f2f Use date objects when building office residences
Since the interface to select this date uses the classic multi-field
interface for day, month and year, we're transforming it into a date in
the Office::Residence initializer.

However, the factory to build an office residence does not assign the
paremeters in the initializer but using the `date_of_birth=` method, so
when doing so we need to use a date instead of a string.
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
dd0f56f85f Use shorter responses and configuration for specs
By simplyfing the responses the configuration for specs can be simpler too.

We're also using more generic terms instead of the ones used in Madrid's
Census API.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
3ed4bdaff8 Return no variants when document_number is blank
Otherwise the variants returned for document_type="1" and
document_number="" will be

`["0", "00", "000", "0000", "00000", "000000", "0000000", "00000000"]`

which seems to be useless.
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
93e458d46e Return invalid response when document_type or document_number are empty
Probably this case is not real for production environments where those
arguments will always be fullfilled but seems to be interesting for
testing environment where this method is being called when those
paremeters where empty.
2020-11-02 11:42:39 +01:00