Commit Graph

44 Commits

Author SHA1 Message Date
Javi Martín
92941d3304 Keep filters in admin search
While this bug was already present in the general admin search, the
combination of both search and filters was very uncommon. I've only
found this combinations in the users section, where you've got the
"erased" filter, but in this case searching for erased users doesn't
really make sense since their username and email have been deleted and
so there's nothing to find.

So the hidden content seemed to be the only affected section. However,
we're adding the field to every section so we don't have to make sure we
add it when we need it (like we did in the SDGManagement section).
2022-08-23 14:33:55 +02:00
Javi Martín
c025fef50b Add short titles to SDG targets
Since targets didn't have a title but only a long description, every
form allowing to select targets was pretty much unusable: we either
displayed just the code or the whole description.

Now, with a concise title, it's easier to find and select the desired
target.

The titles have been copied from The Global Goals page [1].

Note we're using the `short_title` I18n key for the `title` method and
the `long_title` I18n key for the `long_title` method. We can't use
`title` as I18n key instead of `short_title` because it would affect
existing translations.

[1] https://www.globalgoals.org/
2021-10-01 16:19:10 +02:00
Javi Martín
7f9a05d052 Extract method to get SDG code with title 2021-09-30 16:05:57 +02:00
Senén Rodero Rodríguez
1d6490e22f Update sdg management homepage to render header cards 2021-02-26 16:16:51 +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
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
3ec628a63b Add SDG target filter to advanced search 2021-01-26 19:30:58 +01:00
Javi Martín
14e4c528e9 Allow filtering by local target in SDG management 2021-01-22 16:34:26 +01:00
taitus
c052e907eb Prepare related list component to add on front pages
To make it easier to add the component to the front pages forms and
avoid introducing redundant classes we add the necessary padding
(@include grid-column-gutter) to make it behave  like the  rest of the form
fields.

Note that for the sdg management section we set this value to 0.
2021-01-22 12:42:51 +01:00
taitus
334d803332 Add related list selector component
This component allows you to add Goals and Targets in a single
input to relate it to any resource.
We use the new added library to render them as tags.
2021-01-20 19:18:01 +01:00
taitus
7b1821fc9b Prepare relatable concern and relations controller
Allow send Goals and Targets from edit component input field
2021-01-20 19:17:59 +01:00
Senén Rodero Rodríguez
3ad14f4acb Send current tab reference when filtering with search form 2021-01-19 14:56:30 +01:00
Senén Rodero Rodríguez
c6407d82e3 Add filters to SDG relations controller
We have three filters: "pending", "all" and "reviewed". Where "pending"
is the default one.

Now we are rendering the `shared/_filter_subnav` partial we need to stub
helper methods defined at the controller and the helper methods that
rely on the request parameters to test the component.
2021-01-19 14:56:30 +01:00
Senén Rodero Rodríguez
2744362dc7 Extract method to get the text of the section link
So we can override it when using inheritance.
2021-01-18 13:17:37 +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
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
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
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
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
74962ef05f Add filter by target 2020-12-21 18:27:27 +01:00
Javi Martín
c9362ffeb4 Add filter by goal 2020-12-21 18:27:27 +01:00
Javi Martín
791ba73e12 Extract method to display a goal code and title
This is a pattern we're going to use in many places.
2020-12-21 18:27:27 +01:00
Javi Martín
cb183b6e15 Add search to SDG managed content 2020-12-21 18:27:27 +01:00
Javi Martín
ee06dcc05a Disable SDG sections when settings are disabled 2020-12-21 18:04:48 +01:00
Javi Martín
f76279a4dd Add form to assign targets to a record 2020-12-21 18:04:48 +01:00
Javi Martín
11c3b3db13 Add link to an (empty) edit action 2020-12-21 18:04:48 +01:00
Javi Martín
ed51c5dcd3 Add basic SDG Management content section
Note using `params[:relatable_type].classify` is recognized as a
security risk by some tools. However, it's a false positive, since we've
added constraints to the URL so that paramenter can only have the values
we trust.
2020-12-21 18:04:48 +01:00
Javi Martín
5590ecaaa6 Extract methods to generate SDG management menu 2020-12-21 18:04:48 +01:00
taitus
6d5333fc7a Add generic method for header
Unify Header to be able to use it from the admin as from the seg_management.
2020-12-16 13:16:48 +01:00
Javi Martín
599332f26e Merge pull request #4271 from consul/sdg_local_targets
Add SDG local targets
2020-12-16 11:35:12 +01:00
Senén Rodero Rodríguez
5fa7503374 Include local_targets controller 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
8f7809ddb4 Allow to destroy SDG local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
a211937744 Add SDG page to update local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
eb0f13018c Add actions column to SDG local targets index 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
5611f58909 Add SDG page to create local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
3364423698 Update SDG header component
* Add a header element as component markup wrapper
* Allow component to receive an optional block
* Add reusable styles for header links

Co-autored-by: Javi Martín <javim@elretirao.net>
2020-12-11 16:09:43 +01:00
Senén Rodero Rodríguez
88bcf527d8 Add local_targets index to the administration 2020-12-11 16:09:42 +01:00
Javi Martín
55d2cfe5b1 Use link list helper in admin menus
For now we're not including lists with nested lists.
2020-12-07 15:28:56 +01:00
Senén Rodero Rodríguez
e9d52b5e11 Add subnavigation component to targets and goals
Add a new SDG component to make easier to create subnavigation menus.

Co-Authored-By: Javi Martín <35156+javierm@users.noreply.github.com>
2020-12-04 15:15:32 +01:00
Senén Rodero Rodríguez
7fb3f1920e Add targets index to the administration
Co-authored-by: Javi Martín <javim@elretirao.net>
2020-12-04 15:15:32 +01:00
Javi Martín
cb78a254f4 Extract method to provide a title for SDG pages
This way we'll avoid the duplication that can be found in the admin
section.
2020-12-02 12:38:03 +01:00
Javi Martín
a42cb050a7 Add SDG content section 2020-12-02 12:38:03 +01:00