Commit Graph

15920 Commits

Author SHA1 Message Date
Javi Martín
5907ddf884 Use local variable in cards partial
This way it's going to be easier to reuse.
2021-01-14 17:45:14 +01:00
Javi Martín
3e74f4ab67 Remove unused card styles
There are no links inside a figure-card, so these styles didn't affect
any elements.

There are also no elements with `.title`, and the h3 inherits the white
color automatically form the figcaption.

On the other hand, the .see-all link is not inside an element with a
`card` class since commit fae52274a.
2021-01-14 17:45:14 +01:00
Javi Martín
9913b6a0c6 Simplify hovering color styles for headings
The default behavior for headings is to inherit the color, even in the
`:hover` style, and IMHO we can keep it this way, particularly in the
cards, which is the main place where we use headings inside links.
2021-01-14 17:45:14 +01:00
Javi Martín
99fe792e11 Group figure-card styles together
This way rules are a bit easier to follow.
2021-01-14 17:45:14 +01:00
Javi Martín
4072735187 Add icons to SDG index 2021-01-14 17:45:14 +01:00
Javi Martín
7aee4f6241 Add SDG phases cards management
These cards will be displayed in the SDG homepage.

Note there seems to be a strange behavior in cancancan. If we define
these rules:

can :manage, Widget::Card, page_type: "SDG::Phase"
can :manage, Widget::Card

The expected behavior is the first rule will always be ignored because
the second one overwrites it. However, when creating a new card with
`load_and_authorize_resource` will automatically add `page_type:
"SDG::Phase"`.

Similarly, if we do something like:

can :manage, Widget::Card, id: 3
can :manage, Widget::Card

Then the new card will have `3` as an ID.

Maybe upgrading cancancan solves the issue; we haven't tried it. For now
we're defining a different rule when creating widget cards.
2021-01-14 17:40:02 +01:00
Javi Martín
739236d585 Extract placeholder selector for button styles
So we can reuse it.
2021-01-14 17:38:01 +01:00
Javi Martín
1e7517d1f6 Extract components to edit and add cards
This way we'll be able to reuse it in the SDG Management section while
reusing the `title` method to set the page title.
2021-01-14 17:38:01 +01:00
Javi Martín
13f95e9419 Add SDG phase model
The purpose of this model will be to have different sections in the SDG
index.
2021-01-14 17:38:01 +01:00
Javi Martín
ee29ca43a5 Make widget cards polymorphic
So now we'll be able to add them to other sections.

We're also adding a `dependent: :destroy` relation to models having
cards since it doesn't make sense to have cards around when their page
has been destroyed.
2021-01-14 17:37:58 +01:00
Javi Martín
c66a5a30ef Allow using table actions in different namespaces
This way we can reuse it in sections like SDGManagement and URLs will be
automatically generated as expected.
2021-01-14 17:35:38 +01:00
Javi Martín
2968275a1c Add empty SDG homepage configuration page
Here we'll eventually display links to edit the homepage and the cards
in it.
2021-01-14 17:35:38 +01:00
Javi Martín
6db128f7ee Merge pull request #4310 from consul/refactor_cards_controllers
Refactor cards controllers
2021-01-14 17:34:01 +01:00
Senén Rodero Rodríguez
3aaf5ce151 Add back link to cards form
As we normally do in other places.
2021-01-12 15:34:55 +01:00
Javi Martín
1f6ca4980f Extract method in cards table component 2021-01-12 14:50:37 +01:00
Javi Martín
5148919c17 Remove duplication in cards tables
We were using the same code in two places, so we're extracting the code
into a component in order to share it.
2021-01-12 14:50:37 +01:00
Javi Martín
b6f133b6c8 Use human attribute name on cards table
We were defining the same texts in three places: admin.homepage.cards,
admin.site_customization.pages.cards and activerecord attributes.
2021-01-12 14:50:37 +01:00
Javi Martín
4c0bb894eb Use polymorphic routes to manage cards
We use a different logic to load the card depending on the controller
we're using, and then share the rest of the code. This way we simplify
the code a bit, since we don't have to check for the page_id parameter.
2021-01-12 14:50:37 +01:00
Javi Martín
04e817e696 Simplify widget table prefix
The same way it's done in other modules.
2021-01-12 14:50:37 +01:00
Javi Martín
e8e920ee50 Rename Widgets components to Widget
So naming is consistent with the way Admin::Widget controllers are
named.
2021-01-12 14:50:37 +01:00
Javi Martín
52d71b8432 Remove unneeded namespace methods
These methods are not necessary since we changed the `namespace` helper
method in commit 13b3d9ceb.
2021-01-12 14:50:36 +01:00
Javi Martín
c06f14fa65 Remove unused method in cards controller
This method isn't necessary since commit 71601bd3f.
2021-01-12 14:50:36 +01:00
Javi Martín
0762c66855 Don't skip authorization check managing cards
I'm not sure why we were skipping this check.
2021-01-12 14:50:36 +01:00
Javi Martín
ded5a8d468 Use cancancan to load pages and cards
Like we do in most places in the application.
2021-01-12 14:50:33 +01:00
Javi Martín
c1c84507b8 Make card title mandatory
We didn't add any validation rules to the card model. At the very least,
the title should be mandatory.

The fact that the label field is marked as optional in the form but the
other fields are not probably means description and link should be
mandatory as well. However, since there might be institutions using
cards with descriptions but no link or cards with links but no
description, so we're keeping these fields optional for compatibility
reasons. We might change our minds in the future, though.
2021-01-12 14:44:29 +01:00
Javi Martín
36037bbc55 Merge pull request #4300 from consul/sdg_filters
Add SDG filters to advanced search
2021-01-11 13:11:09 +01:00
Javi Martín
cee4613d87 Merge pull request #4305 from consul/sdg_icons_in_index
Add SDG icons to related records
2021-01-11 13:07:11 +01:00
Javi Martín
1449c63cd1 Merge pull request #4309 from consul/fix_spec_name
Fix spec name
2021-01-11 13:05:32 +01:00
Javi Martín
75fc4315ba Add goal filter to advanced search 2021-01-10 15:54:23 +01:00
Javi Martín
8024c4bb69 Fix goal order in goal select 2021-01-10 15:54:23 +01:00
Javi Martín
0595f91222 Simplify advanced search layout width rules
This way, adding a new element is going to be easier.
2021-01-10 15:54:23 +01:00
Javi Martín
a750c48c99 Removed unused CSS rule
There are no elements matching the selector; the element has only one
child (the <form> element) and it doesn't use the `column` class.
2021-01-10 15:54:23 +01:00
Javi Martín
f024a643ea Simplify accessing advanced search params 2021-01-10 15:54:23 +01:00
Javi Martín
2faf99c54b Extract advanced search into a component 2021-01-10 15:54:23 +01:00
Javi Martín
dda79a9224 Remove unnecessary advanced search path parameter
We can use the current path as URL instead of passing it every time.
Passing the `page: 1` parameter is also redundant since by default the
index goes to the first page and the search form does not send any page
parameter.
2021-01-10 15:54:23 +01:00
Javi Martín
142f9b300b Add filters by SDG to processes sidebar
It appears on every process where a tag cloud appears: debates,
proposals and budget investments.
2021-01-10 15:52:22 +01:00
Javi Martín
c5a6ee74c4 Fix component specs using "within"
These specs were passing because the `within` method does not work in
components specs. We have to use `page.find` instead.
2021-01-09 15:48:12 +01:00
Javi Martín
ceed3c18d3 Display SDG icons alongside tags
We're using the translation fallbacks for the icons, just like we do for
texts.

Note we use the `render?` method provided by view_component to make sure
the component will not be rendered when certain features are disabled.

Also note the `find_asset` method works differently in development and
production, and so we use different approaches here.
2021-01-09 14:53:54 +01:00
Javi Martín
53af5749b9 Extract class to check SDG rendering conditions
This class provides a method which shows whether a certain process is
enabled.

Even if it uses a helper, this class is inside the models folder because
the helper it uses actually only uses model methods. We might eventually
remove/simplify this helper and cache inside the model, like we did with
I18n content translations in commit 41dba842a.
2021-01-09 14:19:00 +01:00
Javi Martín
1a902a9671 Use polymorphic_path instead of taggables_path
We forgot to make this change when we started using "resolve" to
generate polymorphic nested resources.

The taggables_path method can be replaced with the polymorphic_path of a
class. It even works with nested resources, given the current page
already has the nested resources params (in this case, `budget_id` for
investments).
2021-01-09 14:17:21 +01:00
Javi Martín
afda9ab3b7 Fix string literal with single quote
It was accidentally introduced in commit de4be15a8.
2021-01-08 19:59:00 +01:00
Javi Martín
43def0517a Fix SDG manager spec filename
We forgot the `_spec` suffix.
2021-01-08 19:58:46 +01:00
Javi Martín
7144c80d0c Add SDG icons for Brazilian Portuguese
Downloaded from: https://odsbrasil.gov.br/
2021-01-08 15:18:36 +01:00
Javi Martín
432fea8a3d Add SDG icons for Western European languages
Downloaded from: https://unric.org/en/sdgs-in-your-language/

Only languages enabled by default in CONSUL have been downloaded:
Danish, German, Greek, Italian, Dutch and Swedish.

Note that, unlike the icons for the 6 official UN languages, these icons
vary in size and quality. They've also been converted from JPEG files.
2021-01-08 15:18:36 +01:00
Javi Martín
9d5f08de25 Add official UN SDG icons
Note we're adding the icons in English on both the `sdg/en/` folder and
the `sdg/default/` folder. The latter stores the default icons when the
desired language does not have a fallback with an icon folder.

Also note we need to explicitely add the images to the asset pipeline
because they've been added to the `vendor/` folder; for some reason,
everything works properly without adding them to the asset pipeline if
we use the `app/` folder instead.
2021-01-08 15:18:01 +01:00
Javi Martín
2d5549f6d8 Merge pull request #4304 from consul/sdg_typos
Fix typos in SDG titles
2021-01-05 13:01:51 +01:00
Javi Martín
159edba015 Specify the SDG title uses two lines
This way translators will find a hint indicating they must use two lines
and not three or more, since the title is optimized for being displayed
in two lines.
2021-01-04 12:45:03 +01:00
Javi Martín
401be5b8fb Fix typo in SDG title 2021-01-04 12:45:03 +01:00
Javi Martín
587dd721d7 Merge pull request #4298 from consul/sdg_header
Style SDG headers following UN guidelines
2020-12-28 21:01:30 +01:00
Javi Martín
73e605232e Merge pull request #4292 from consul/sdg_view
Add SDG view with related content
2020-12-28 21:01:14 +01:00