Commit Graph

16247 Commits

Author SHA1 Message Date
Javi Martín
f864156b21 Add and apply ClosingErbTagIndent ERB Lint rule
Note this rule does still allow us to add new lines after opening tags;
it just makes sure that if we do, we also add it in closing tags.
Likewise, if we don't add it in the opening tag, it forces us not to add
it in the closing tag either.

I don't have a strong preference about either style; in these cases I've
chosen the latter because it seemed more common in our code.
2021-02-05 17:39:42 +01:00
Javi Martín
9b0026061e Specify erb_lint version in Gemfile
Just like we do for the rest of the gems.
2021-02-05 16:24:55 +01:00
dependabot-preview[bot]
12fa241027 Bump erb_lint from 0.0.28 to 0.0.35
Bumps [erb_lint](https://github.com/Shopify/erb-lint) from 0.0.28 to 0.0.35.
- [Release notes](https://github.com/Shopify/erb-lint/releases)
- [Commits](https://github.com/Shopify/erb-lint/compare/v0.0.28...v0.0.35)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-05 16:24:55 +01:00
Javi Martín
fe1ef43f76 Merge pull request #4345 from consul/sdg_list_refactor
Refactor tags and SDG "tags" rendering
2021-02-04 12:46:35 +01:00
Javi Martín
92a09f74b0 Remove obsolete tag list rule
This rule was added so the tag list wouldn't have an extra bottom
margin. However, the rule is already applied by the `.tags` selector
inside `.budget-investment` and it was conflicting with other lists
(goals and tags) we've added to thi investments index.
2021-02-04 12:32:03 +01:00
Javi Martín
2712cc15e3 Merge pull request #4343 from consul/taggables_fix
Fix tags and SDG "tags" on legislation proposals
2021-02-03 19:24:00 +01:00
Javi Martín
7d4e49a090 Reorganize SDG tag list components
So now we've got a component receiving records (goals or targets) and a
related model (Debate, Proposal, ...), with optionally a link to see
more tags.

This way we simplify some logic since the `TagList` classes were dealing
with too many cases (a record is passed, a class name is passed, a limit
is passed), ... Now `TagList` only deal with the natural `TagList` case,
which is listing the tags for a record. The case where a class name is
passed is used in the `TagCloud` class.
2021-02-02 22:22:40 +01:00
Javi Martín
a78663120a Extract component to render a goal/target tag 2021-02-02 22:22:40 +01:00
Javi Martín
999d1a2cfd Rename goals FilterLinks component to TagCloud
This is more consistent with the "tag_cloud" partial name.
2021-02-02 22:22:39 +01:00
Javi Martín
ad56b01a9a Extract component to render "see more" link 2021-02-02 22:22:37 +01:00
Javi Martín
6112016773 Extract component to render a list of tags 2021-02-02 21:56:45 +01:00
Javi Martín
7c4515d6ce Simplify code to generate "See more" link
We can skip the `link_to(*options) if options` part if we accept anchor
tags in the `link_list` helper.
2021-02-02 20:05:40 +01:00
Senén Rodero Rodríguez
fb611d91ca Fix legislation proposal crash with SDG enabled
Now we check the given record or name is a relatable instance or class
to avoid trying to render goals for records which don't have a goals
association.

Note for now we are ignoring the case where we pass a controller_path
for an unsupported class (for example, `legislation/proposals` or
`budgets/headings`) because we never use it. We might need to revisit
this case in the future.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-31 14:44:53 +01:00
Javi Martín
7318112e90 Merge pull request #4341 from consul/sdg_widget_tags
Add SDG tags to most active feeds
2021-01-31 14:10:35 +01:00
Senén Rodero Rodríguez
046e2273c7 Add tests for SDG::ProcessEnabled model
We were testing it through other models, but unit tests help when
changing the code of this class.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-31 13:56:05 +01:00
Senén Rodero Rodríguez
450b157a5e Fix tag links on legislation proposals
On commit 1a902a96 we removed this helper to make use of polymorphic
routes but when it's called for Legislation::Proposal fails as the
namespace does not match the model namespace.

Now we recover the removed helper but only the parts that do not work
with polymorphic_url helper.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-31 13:56:05 +01:00
taitus
35db41827c Add tag list component to process feed
Remember that this component (widget/feeds/process) is displayed both in
the home page and in the target index.
2021-01-31 13:53:57 +01:00
taitus
ca36dd56f0 Add tag list component to proposal feed 2021-01-31 13:53:57 +01:00
taitus
edbef4fd88 Add tag list component to debate feed 2021-01-31 13:53:57 +01:00
Javi Martín
60f3cc8cf9 Merge pull request #4329 from consul/sdg_polls_processes
Display related SDG and targets on polls and processes
2021-01-31 13:44:51 +01:00
Senén Rodero Rodríguez
2f9caa502a Darken goal icons on link hover
As they not seem to be interactive elements.
2021-01-31 13:33:28 +01:00
Javi Martín
a877449936 Add related SDG and targets tags to processes
I'm not sure why we were using squares to style these lists see commit
bbacd4546b) but I don't think it's very important and it breaks
displaying the list of related SDGs.
2021-01-31 13:33:27 +01:00
Javi Martín
19bab5a9dc Add related SDG and targets tags to polls 2021-01-31 13:33:27 +01:00
Senén Rodero Rodríguez
bb1315def1 Prepare SDG tag list component to render list with or without links
Now the tag list can render tags with or without links, so we need
to adapt the styles slightly.

We want to use the same text color for tags without links.

The hover style is only needed when using tags with links.
2021-01-31 13:33:26 +01:00
Senén Rodero Rodríguez
cc2ce38d13 Create SDG target component to render plain tags 2021-01-31 13:33:25 +01:00
Senén Rodero Rodríguez
54843c1e53 Create SDG goal component to render plain tags 2021-01-31 13:33:25 +01:00
Javi Martín
0f52d22b70 Merge pull request #4342 from consul/sdg_sort_performance
Improve performance sorting SDG records
2021-01-30 17:42:27 +01:00
Javi Martín
96d5354cd8 Improve performance sorting SDG records
We noticed there was a performance issue while browsing the SDG
Management section and when one of our tests started failing sometimes
because the request to the relations#index controller took too long.

The issue proved to be `SDG::Target#<=>`. This method calls `.goal` for
each target, meaning we were generating 169 database queries when
sorting all targets.

So we're comparing codes directly to minimize the number of database
queries and improve performance. Requests to the relations index take
now less than third of the time they used to take.
2021-01-30 14:00:44 +01:00
Javi Martín
458e795ad4 Merge pull request #4336 from consul/sdg_icons_size
Adjust SDG icons size
2021-01-29 19:18:18 +01:00
Javi Martín
cdfa23fc6f Adjust icon margins on small screens
On these screens, sometimes the icons will be `$sdg-icon-min-width`
wide, but the margins were not taking this into account.

We can use CSS `max` function to set minimum margins just like we set
minimum width. However, there are two things to take into account:

* LibSass does not support these functions as it tries to use Sass own
  functionst at compile time, so we need to hack them writing `Max()`
  (which works in CSS because it is not case sensitive)
* Not all browsers support it (90% at the time of writing), so we write
  the rules twice (the first time for browsers not supporting it); we
  could use `@supports` but then we would have to overwrite some of the
  rules in the `.sdg-goals-index .sdg-goal-list` selector using
  `!important` or adding a `@supports` clause there as well
2021-01-29 19:07:32 +01:00
taitus
adc66cb28e Improve icons size on goals index
We're also using a percentage to separate the icons, since using the
viewport width causes strange result on screens where the element
max-width (which is based in rem) is much smaller than the size of the
window.
2021-01-29 18:14:50 +01:00
taitus
d61d648dda Render all icons on one line in forms
Show all icons of the RelatedListSelector component on one line in the
forms.
2021-01-29 18:14:50 +01:00
Javi Martín
0b84c0da01 Improve margin rules in SDG icons
We were using the classic approach of adding a margin-right property to
all elements except the last one. This works great when all icons are
displayed in one row.

However, when they're displayed in several rows, there could be a
scenario where the last row has more elements:

element1 <margin> element2 <margin>
element3 <margin> element4 <margin> element5

In the example above, `element3` does not fit in the first row because
it's got a margin to its right. However, `element5` fits in the second
row because the last element has now right margin.

One option to fix this issue it using CSS `gap` property. However, at
the time of writing, it's only supported by 70% of the browsers.

So we're emulating the gap by giving a negative margin to the list
equivalent to the margin of the first element.

This idea is based on:

https://coryrylan.com/blog/css-gap-space-with-flexbox

The exception is the index page. Here the list of icons is centered with
`margin: auto`, and so we cannot use negative margins. We're using the
classic approach instead, which is fine because we define there are 6
icons per row.
2021-01-29 18:14:50 +01:00
taitus
2215209ae4 Standardize icon size
These icons share page with the social media icons (eg: ssb-twitter)
in both the index and the show pages
We believe we gain consistency if all the icons that appear are the
same size.

Pull request 4101 will use this width in social media icons as well.
2021-01-29 18:14:50 +01:00
Javi Martín
d774742bf5 Move sdg-colors to the right settings section
We were adding it under the Foundation overrides section, but this
variable has nothing to do with Foundation.
2021-01-29 18:14:50 +01:00
Javi Martín
8785621a56 Merge pull request #4331 from consul/sdg_view_targets
Add targets to SDG view
2021-01-29 14:37:24 +01:00
taitus
1d151b7b6f Add empty message when there are not local targets 2021-01-29 14:15:58 +01:00
taitus
f45bbb316c Add Targets component to Show component 2021-01-29 14:15:58 +01:00
taitus
857a6aa228 Add targets component to render all targets in tabs section 2021-01-29 14:15:58 +01:00
Javi Martín
5044c424b6 Merge pull request #4334 from consul/sdg_show_section_header
New header section on SDG Goals Index
2021-01-29 14:14:44 +01:00
Javi Martín
e440cd498f Merge pull request #4337 from consul/sdg_dynamic_filter
Make target filter change when goal filter changes
2021-01-29 13:02:11 +01:00
taitus
7a02ce9c08 Add sdg section header on SDG IndexComponent
Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-28 20:02:46 +01:00
Javi Martín
e0b6b83b11 Use <main> in SDG index
Just like we do in the other sections.

We're also moving the banner inside the <main> element because we do it
the same way in other sections.
2021-01-28 19:49:31 +01:00
Javi Martín
08c410cc93 Make target filter change when goal filter changes
Note we're using both the `hidden` and `disabled` properties to
guarantee compatibility with user agents which might still display the
option even when using the `hidden` attribute or hiding it with
`display: none`. We could also use `hide()` and `show()` instead of the
`hidden` property, but since we're using the `disabled` property, I
thought the code would be easier to read if we used properties in both
cases.

Also note users will no longer be able to get, let's say, debates which
are related to goal 1 and target 2.1. We think this use case is highly
unlikely and there's no need to take it into account.
2021-01-28 18:54:04 +01:00
Javi Martín
0aa0a9c16b Add missing test to search by SDG
We had only added a test to seach by target.
2021-01-28 18:46:46 +01:00
Javi Martín
a6714be6b8 Group advanced search tests together
We were doing the same tests three times to test the advanced search
feature. I'm grouping them in one place and shuffling the sections
around to remove duplication and make the test suite faster.
2021-01-28 13:42:44 +01:00
Javi Martín
5f3279b9db Extract search form component in SDG Management
We're going to add some JavaScript which affect this component, and IMHO
it will be easier to know the JavaScript affects this form if both have
their own separate file.
2021-01-28 13:41:23 +01:00
Javi Martín
3018de2847 Merge pull request #4324 from consul/sdg_target_filter
Add SDG target tags and filter
2021-01-27 16:48:12 +01:00
Javi Martín
fbcc7f0332 Merge pull request #4330 from consul/sdg_descriptions
Add descriptions to SDG view
2021-01-27 16:23:49 +01:00
Javi Martín
fa14a267a6 Render related SDGs before tags
When a proposal had geozones, it was a bit strange to have a list of
tags, then a list of SDGs, and then another list of tags. So we're
changing the order a bit.
2021-01-27 16:21:40 +01:00