Commit Graph

15545 Commits

Author SHA1 Message Date
Javi Martín
0c482ae418 Fix active class for proposals in admin menu 2020-12-07 19:28:12 +01:00
Javi Martín
1046ec5e78 Move link methods from view to component
This way the view is not as hard to read as it was.
2020-12-07 15:28:56 +01:00
Javi Martín
7680bfc94b Use aria-current to mark the current element
This way screen reader users will be notified that the element is the
current one.

I'm not entirely sure whether `aria-current="page"` is more appropriate
than `aria-current="true"`, since it's a general helper which can be
used for any collection of links.
2020-12-07 15:28:56 +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
Javi Martín
c156621a4c Add method to generate a list of links
A list of links is a very common pattern in the web, and we use it in
many places. Here we're applying it to one of the most simple ones; the
help page.

Generally speaking, I'm not a big fan of helpers, but there are methods
which IMHO qualify as helpers when:

* They do not deal with application objects but mainly strings and
  arrays
* They return text or an HTML tag
* Their logic is simple and splitting it into several methods is not
  necessary

Many Rails helpers, like `tag`, follow these principles.
2020-12-07 15:28:56 +01:00
Javi Martín
190ced4d2a Remove unused views 2020-12-07 15:28:56 +01:00
Javi Martín
f9de601841 Fix double <nav> tag in valuation menu
We were defining a <nav> tag which was already defined in the admin
layout.
2020-12-07 15:28:56 +01:00
Javi Martín
b778d6551d Merge pull request #4277 from consul/admin_search
Refactor admin search forms
2020-12-07 14:59:03 +01:00
Javi Martín
cf510043a4 Search on the same URL by default 2020-12-07 14:28:36 +01:00
Javi Martín
e33794e45e Reuse admin search component in other sections
There are some sections where we are not reusing it:

* The budget investments search is completely different, so this
  component isn't appropriate there
* Booth assignment and officers are slightly different, and I'm not
  entirely sure it's safe to refactor these cases
2020-12-04 19:57:05 +01:00
Javi Martín
a9427f5971 Allow custom options in search form component
So we keep the same API as the form_tag method.
2020-12-04 19:57:05 +01:00
Javi Martín
9b073599f0 Allow different labels in admin search component 2020-12-04 19:57:05 +01:00
Javi Martín
0a3acf3c5f Use a shared translation for search buttons
We were writing the same text over and over for the same translations.
Since they all serve the same function, it's perfectly fine for them to
have the same text, and so we can have a shared translation.
2020-12-04 19:57:05 +01:00
Javi Martín
49c22b880c Use CSS to style the search component
We simplify the view, and so make it easier to customize.
2020-12-04 19:57:05 +01:00
Javi Martín
b453ed6c14 Add ARIA role and ARIA label to admin search form
This way screen reader users will have an easier access to it.
2020-12-04 19:57:05 +01:00
Javi Martín
155da08cf0 Use a generic name for the search parameter
This way we can use it for any model.
2020-12-04 19:57:05 +01:00
Javi Martín
9a24a8efe2 Use form_tag in search form
This form does not depend on an object at all, so we can use a generic
tag which is model-independent.
2020-12-04 19:57:05 +01:00
Javi Martín
2cf49b28de Extract users search view to a component
We're going to make this search component more generic, but for now,
we're keeping the exact same behavior we had.
2020-12-04 19:57:05 +01:00
taitus
7b6294199c Include the searched term in the search input form 2020-12-04 19:57:05 +01:00
Javi Martín
427dec8cbd Merge pull request #4262 from consul/sdg_tags
Add SDG relations
2020-12-04 18:49:31 +01:00
Javi Martín
c0edd1b227 Allow SDGs to get all their related contents
Note we cannot directly get all related contents through SQL because
related contents are spread through different tables.
2020-12-04 18:27:49 +01:00
Javi Martín
42699275a1 Add relations between relatable models and SDGs
Note we cannot directly get all related SDGs through SQL because they're
spread through different tables.
2020-12-04 18:27:49 +01:00
Javi Martín
1740e0ba66 Add SDG::Relation model 2020-12-04 18:27:49 +01:00
Javi Martín
ebcd64ad1a Merge pull request #4260 from consul/sdg_targets
Add SDG targets
2020-12-04 16:40:20 +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
Senén Rodero Rodríguez
00e91c40b9 Add SDG targets to seeds
Co-authored-by: Javi Martín <javim@elretirao.net>
2020-12-04 15:15:32 +01:00
Senén Rodero Rodríguez
c39c7213c7 Add SDG target model
and its relation with the SDG goal model.

Add comparable module be able to sort collections of targets
by code attribute.

Co-Authored-By: Javi Martín <35156+javierm@users.noreply.github.com>
2020-12-04 15:15:32 +01:00
Javi Martín
550f2ed319 Merge pull request #4251 from consul/add-global-sdg-setting
Add global SDG feature setting
2020-12-03 18:49:58 +01:00
taitus
64a8ceaa9b Enable sdg feature settings by default on dev_seeds 2020-12-03 18:26:00 +01:00
taitus
cb63185837 Render SDG content sidebar when sdg feature setting is enabled 2020-12-03 18:26:00 +01:00
taitus
72e64bd543 Render 'how to enable' when the related feature setting is disabled
Add 'how to enable' information on SDG configuration tab when related
sdg feature setting is disabled.
2020-12-03 18:26:00 +01:00
taitus
676adfcb3f Add new SDG feature Setting 2020-12-03 18:26:00 +01:00
Javi Martín
1d5cbece6c Merge pull request #4247 from consul/add-sdg-settings
Add SDG settings
2020-12-03 18:25:36 +01:00
taitus
bf4c2680c4 Enable sdg settings by default on dev_seeds 2020-12-03 18:00:10 +01:00
taitus
0abc82d520 Add new sdg settings on sdg-tab 2020-12-03 18:00:10 +01:00
taitus
5e19f60ba6 Add new sdg-tab on Global Configuration Settings 2020-12-03 18:00:10 +01:00
taitus
79cb78880a Add default values for new sdg settings 2020-12-03 18:00:10 +01:00
taitus
609e51bbf3 Include new type 'sdg' on settings 2020-12-03 18:00:10 +01:00
Javi Martín
a03eed801a Merge pull request #4252 from consul/sdg_goals_yaml
Add Sustainable Development Goals section
2020-12-03 17:58:58 +01:00
Javi Martín
22f5042292 Merge pull request #4263 from consul/admin_tests
Simplify tests requiring admin login
2020-12-02 15:49:38 +01:00
Javi Martín
3da4ee00b8 Simplify tests requiring admin login
We were repeating the same code over and over (with a few variants) to
setup tests which require an administrator. We can use a tag and
simplify the code.
2020-12-02 15:33:19 +01:00
Javi Martín
a0f7bf2b1f Merge pull request #4234 from consul/remove_unused_capistrano_variables
Remove unused deployment configuration variables
2020-12-02 13:03:28 +01:00
Javi Martín
d5ee1ff89c Add method to easily access a goal by code
Similar to what we do with settings, only for settings we return the
value of the setting (which is what we're going to need most of the
time), and here we return the object.
2020-12-02 12:59:17 +01:00
Senén Rodero Rodríguez
c7c8309ad1 Add rake task to load sdg
This task should be useful for existing installations that are going
to upgrade the app and want to load SDG data into an already
existing database.
2020-12-02 12:38:03 +01:00
Senén Rodero Rodríguez
cbe84450ac Add Goals seeds and translations
Extracted from the official United Nations Sustainable Development
Goals website [1].

[1] https://www.un.org/sustainabledevelopment/sustainable-development-goals/
2020-12-02 12:38:03 +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
Javi Martín
2b6c9914dd Extract selector for admin menu icon
This way we'll be able to apply it to the SDG icon, which is not
included in font-awesome.

Note we're adding a font-icon selector so it's defined before the
admin-menu-icon selector and so in case of conflicting rules the ones in
the admin-menu-icon selector are used.
2020-12-02 12:37:28 +01:00
Javi Martín
428644cd3e Add SDG goal model
Since data for this model (title and description) is not generated in
CONSUL but by the United Nations, we aren't storing it in the database
but in our YAML translation files.

The reasoning is as follows. Suppose that, a few months after CONSUL
gets SDG support, a new language is added to CONSUL.

With YAML files, getting the texts in the new language would mean
updating CONSUL to include the new language.

But if we store these texts in the database, it means we have to update
the databases of all existing CONSUL installations, either each
installation by themselves (duplicating efforts) or running a rake task
(which we would have to write each time).

So we believe using translations works better in this case.

We're still storing records in the database with the code, so they can
be easily referenced via `has_many` or `has_many :through` associations.
2020-12-02 12:13:02 +01:00