Commit Graph

15767 Commits

Author SHA1 Message Date
taitus
1cbf9a3404 Display Goals and Targets relateds on Admin Legislation Process index 2021-01-22 16:14:50 +01:00
taitus
920631c5b3 Add SDG::RelatedListSelectorComponent to Polls
Allow to relate SDG and Targets to Polls
2021-01-22 16:14:50 +01:00
taitus
6e0158db17 Display Goals and Targets relateds on Admin Poll index 2021-01-22 16:14:49 +01:00
taitus
6d3782b4a0 Add SDG::RelatedListSelectorComponent to Budget Investments
Allow to relate SDG and Targets to Budget Investments
2021-01-22 16:14:47 +01:00
taitus
95c1f36bdd Add SDG::RelatedListSelectorComponent to Proposals
Allow to relate SDG and Targets to Proposals
2021-01-22 16:05:16 +01:00
taitus
e6bfeef58d Add SDG::RelatedListSelectorComponent to Debates 2021-01-22 16:04:40 +01:00
taitus
189c299a6e Do not render component when the feature is disabled 2021-01-22 16:03:53 +01:00
taitus
8a91493fe4 Extract repeating code to a method 2021-01-22 12:42:53 +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
Javi Martín
d8f1c462de Try to avoid PG::ProtocolViolation error in tests
While running our test suite, we were getting an exception sometimes:

```
Proposal Notifications In-app notifications from the proposal's author Followers should receive a notification
   Failure/Error: notification_for_user2 = Notification.find_by(user: user2)
      ActiveRecord::StatementInvalid:
        PG::ProtocolViolation: ERROR:  bind message supplies 0 parameters, but prepared statement "" requires 2
        : SELECT  "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 LIMIT $2
   # ./spec/system/proposal_notifications_spec.rb:268
```

Sometimes we were getting a similar exception in a different test:

```
Commenting legislation questions Merged comment threads Reply on a multiple annotation thread and display it in the single annotation thread
And sometimes we were getting a different one:
   Failure/Error: annotation.comments.roots.sort_by_most_voted.limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment|
     ActionView::Template::Error:
       PG::ProtocolViolation: ERROR:  bind message supplies 0 parameters, but prepared statement "" requires 3
```

My best (wild) guess is these exceptions might take place because the
test is accessing the database and at the same time the browser
(chromedriver) process is accessing the database, with code like:

```
 find(".icon-notification").click
 notification_for_user2 = Notification.find_by(user: user2)
```

Or:

```
first(:css, ".annotator-hl").click
(...)
comment = annotation1.comments.first
click_link "Reply"
```

This behavior happened sometimes while using transactional fixtures and
a shared database connection with feature specs (before system specs
were introduced in Rails 5.1) when some queries were triggered from the
test after the browser process was started.

So we're avoiding the situation by writing the tests from the user's
point of view. This is just an attempt at fixing the issue; I don't know
whether these changes will fix it since I've only seen this exception on
Github Actions (never on my machine). Worst case scenario, we're still
improving the tests legibililty.
2021-01-22 12:31:48 +01:00
Javi Martín
25facc112f Remove double requests
They were added in commit bb4e4dc084; although I must admit I don't
know the reason why they were needed.
2021-01-22 12:26:59 +01:00
Javi Martín
a979a2225d Merge pull request #4315 from consul/sdg_relation_tags
Add SDG goal/target selector
2021-01-20 19:33:32 +01:00
taitus
9fe032a515 Fix target title 2021-01-20 19:18:58 +01:00
taitus
5d2474466d Prevent Cross-site scripting 2021-01-20 19:18:58 +01:00
taitus
d56396acb7 Improve usability and design
Render the tags under the input. This way the input is not moved down
when a tag is added.
Render icons under the label. As you can add tags by clicking on the icons,
in this way the input is more related to the icons.
2021-01-20 19:18:58 +01:00
taitus
2481fc3243 Correctly relate the label to the input
There seems to be a small issue with suggestags, and the label is associated with the
original input
2021-01-20 19:18:57 +01:00
taitus
602b22edfd Allow tags to be removed with the keyboard
We improved accessibility by overwriting the setIcon method in the library.
Now we render a button and add the aria-label attribute.
2021-01-20 19:18:57 +01:00
taitus
fce844261a Add help section
In the help section we show the titles of the Goals and Targets that we have added
2021-01-20 19:18:55 +01:00
taitus
c18ab66cc7 Add new suggestion attribute to render custom text on tags
Add "display_text" to allow customize the text that we want render on tag.
For Goals we render "SDG1", "SDG2"..
For Targets we render the code "1.1", "1.A"...
2021-01-20 19:18:03 +01:00
taitus
f463baf14a Fix removing item twice
Add spec which is fixed with this commit.

In the `sTagsArea` zone there are two elements with the same `data-val`:
the `<span class="amsify-select-tag>` containing the selected tag and
the `<li class="amsify-list-item" data-val="1">` containing the
suggested tag.

This means every time we call `removeTag`, the `removeTagByItem`
function is called twice, and might remove extra items.

Suggested PR:
c8765a6915
2021-01-20 19:18:03 +01:00
taitus
23f72d939a Add list of goals icons to component
- When we click on an icon we add a new tag with the Goal related to the input or
we remove the tag when that label already exists.

- Manage goals icons status when add or remove related targets:
Whenever there is a tag related to Goal, either the Goal itself or a Target, the icon
will be "checked".
When there is no related Goal or Target it will no longer be marked as checked.
2021-01-20 19:18:03 +01:00
taitus
e4e4e28ce6 Add custom background and color text for tags 2021-01-20 19:18:02 +01:00
taitus
1eb06dfb99 Add AmsifySuggestags settings
With 'whiteList' to true, only can add tags related with suggestions.
Update 'keepLastOnHoverTag' and 'checkSimilar' to improve usability.
2021-01-20 19:18:02 +01:00
taitus
25501c74bb Add suggestions list with goals and targets
This will allow autocomplete for the loaded values in suggestions settings.
We remove commas on tag to allow to jquery.amsify.suggestag.js use comma
as delimiter.
2021-01-20 19:18:02 +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
Javi Martín
605dfefa09 Merge pull request #4320 from consul/sdg_banners
Make it possible to add banners to the SDG section
2021-01-20 18:49:22 +01:00
Javi Martín
5a42d65d5f Make it possible to add banners to the SDG section 2021-01-20 17:22:08 +01:00
Javi Martín
a7bbdb1bd0 Simplify rendering a banner
Now the banner component accepts either a banner or a section and loads
the banner if it's a section, so we don't have to add the `@banners`
variable in several controllers.
2021-01-20 17:22:05 +01:00
taitus
beda6cb8c8 Add JQuery library for input tags
Source: https://github.com/amsify42/jquery.amsify.suggestags
2021-01-20 10:41:08 +01:00
Javi Martín
c3147a1bb6 Simplify conditions to render a banner 2021-01-19 15:35:18 +01:00
Javi Martín
957a73f837 Extract banner to a component 2021-01-19 15:35:18 +01:00
Javi Martín
885a9ad765 Simplify creating web sections in seeds 2021-01-19 15:35:18 +01:00
Javi Martín
68b32f2a84 Remove duplication creating web sections in seeds 2021-01-19 15:35:18 +01:00
Javi Martín
f64db91616 Merge pull request #4294 from consul/sdg_revisions
Extend SDG managment section to allow content reviews
2021-01-19 15:26:06 +01:00
Javi Martín
21021f5054 Remove instance variables in has_filters spec
This was a false positive in Rubocop, but we can avoid it by using the
attribute reader method we've just added.
2021-01-19 15:05:37 +01:00
Senén Rodero Rodríguez
739d23fe73 Mark relatable as reviewed when updating its relations
Show a notice only once when the user updates the relatable.
2021-01-19 14:56:30 +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
94a4b67675 Use local variables at shared/filter_subnav partial
So we can use it from components too.
2021-01-19 13:51:06 +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
Senén Rodero Rodríguez
a0c9eba41d Add scope to filter SDG relations by review status 2021-01-18 13:17:37 +01:00
Senén Rodero Rodríguez
0368aa459f Add SDG::Review model
and its relation with relatables

Note about sdg_review factory: Cannot use the constantize method on
the relatable_type as long as the relatable classes will be loaded and
this will throw an exception because the database is not available at
factiry definition time.
2021-01-18 13:17:37 +01:00
Javi Martín
60c3c6b6e2 Merge pull request #4314 from consul/sdg_homepage
Add icons and cards to SDG homepage
2021-01-18 12:08:14 +01:00
Javi Martín
af599b81cd Merge pull request #4311 from consul/sdg_cards
Add SDG cards management section
2021-01-18 11:58:02 +01:00
Javi Martín
5927e4dfaa Add title to SDG homepage 2021-01-14 18:04:21 +01:00
Javi Martín
c3e60ff514 Add cards to SDG homepage 2021-01-14 17:47:21 +01:00
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