Commit Graph

96 Commits

Author SHA1 Message Date
Pierre Mesure
e5a6a5bf1d Adding clustering 2024-01-29 17:56:54 +01:00
Senén Rodero Rodríguez
0186484fac Use leaflet npm version instead of the gem 2024-01-29 17:56:54 +01:00
Javi Martín
a2e4b056ee Move documents partials to components
This way it'll be easier to change them.

Note that there were two `.document-link` elements which aren't part of
a `.documents` element. We're renaming the HTML class of the link in
investments because it didn't contain links to download documents and
are slightly duplicating the CSS in the poll answer documents in order
to keep the `word-wrap` property.
2023-10-23 18:10:24 +02:00
Javi Martín
3b6fb85c51 Use node packages to install jQuery and jQuery UI
Other packages depend on jQuery, so that's why these are the first one
we move from the Gemfile to the package.json file.

This way we can also test whether dependabot correctly opens pull
requests to update Node packages.

I've tried several configuration options for the asset pipeline in order
to be able to include images referenced in jQuery UI CSS files. So far,
adding the `node_modules/jquery-ui/themes/base` folder to the assets
paths is the only way I've found to make it work. Hopefully we can find
a better solution in the future so we don't have to study the internals
of every Node package in order to integrate it with the assets pipeline.
2023-10-17 13:12:20 +02:00
Javi Martín
9cc3c553ff Extract component to render a map
This way it'll be easier to refactor it.
2023-05-04 15:27:15 +02:00
Javi Martín
9b908d7264 Extract component to render account permissions
We were using similar code in four different places; six, if we count
the welcome pages seeds. Reducing duplication in the pages seeds is a
bit tricky because administrators are supposed to edit their content and
might remove the HTML class we use to define styles. However, we can
share the code everywhere else.

Note that there's a bug in the application since we show that level 2
users cannot vote for budget projects but we give them permission to do
so in the abilities model. We're keeping the same behavior after this
refactoring but we might change it in the future.
2022-11-29 18:48:24 +01:00
Javi Martín
91614fa2a9 Allow different main header colors per tenant
Just like we did with SCSS variables, we use the `--main-header` CSS
variable and, if it isn't defined, we use the `--brand` CSS variable
instead.

Note that we're still using the `inverted-selection` mixin based on the
default `$main-header` color, so it's possible that we get the inverted
selection in the main header when using a dark color with `$main-header`
but a light color with `--main-header`, which doesn't make much sense.
Not sure whether there's anything we can do about it.
2022-11-20 00:29:12 +01:00
taitus
2865ee286f Add comments count component
Remove all the translations that are left over after having unified them
in the component.
2022-08-19 15:40:51 +02:00
Javi Martín
fef39cad24 Move banner styles to their own stylesheet
Since we've already got a banner component, we follow the convention of
using one CSS file per component. We also reduce the number of lines in
the huge layout.scss file.

Now the sections in layout.scss from "17" to "19", just like they jump
from "08" to "10".
2022-05-02 15:00:51 +02:00
Javi Martín
5c0aa42351 Remove duplication in search results summary
We were using very similar code for proposals, debates and investments,
so we might as well share the code between them.

Note we're using the `proposals.index.search_results` key even for
debates and investments. This will still work because the translations
shared the same text, but IMHO we should rename the key to something
like `shared.search_results_summary`. We aren't doing so because we'd
lose all the existing translations.
2022-04-12 14:23:14 +02:00
Javi Martín
86ad2df46d Unify code in debates/legislation vote links
We were using the same code to render links to agree and disagree, so we
can extract a new component for this code.

We're also adding component tests to make it easier to test whether
we're breaking anything while refactoring, although the code is probably
already covered by system tests.

Since the votes mixin was only used in one place, we're removing it and
moving most of its code to a new CSS file for the shared component.
2022-02-21 18:47:13 +01:00
taitus
6d9e4a9330 Allow users to manage their notifications
The user can access this page without being logged in.
We identify the user through the "subscriptions_token" parameter and
show a list of the notifications that can be enable/disable.

We will return a 404 error in case someone accesses the page with a
non-existent token.

We also control the case that some anonymous user tries to access the
page without any token, by returning the CanCan::AccessDenied exception.
2022-01-21 18:58:38 +01:00
Javi Martín
a5c66c7281 Use buttons instead of links to hide content
We're continuing to replace links with buttons, for the reasons
explained in commit 5311daadf.

Since we're using the admin action component, we can also simplify the
logic handling the confirmation message.

In order to avoid duplicate IDs when generating buttons to block the
same author more than once in a page, we're including the record dom_id
in the ID of the button to block an author.
2021-12-30 15:50:03 +01:00
Javi Martín
84c6eeae9c Use headers and actions in users moderation table
Having proper headers makes it more accessible.

We're also using the table actions component because we're going to add
another action. Since table actions use a flex layout, we have to tweak
the styles a little bit. For that, I'm adding a <main> element which
will make it possible to style just this table while also providing an
extra shortcut for people using screen readers.
2021-12-30 15:50:02 +01:00
Javi Martín
36d795f69c Move investment filters to the sidebar
As mentioned in commit bc0f04075, a <select> field which submits its
form on change causes many accessibility and usability issues. In this
case there was also an incompatibility with the advanced search filter
which caused a bug solved in commit 541a5fa89.

So the question is where to position the filters and how to display
them. One factor to take into the account is how relevant these filters
are, particularly compared to the links to select the prefered order,
since we don't usually give users the choice of both filters and orders.

Our filters don't really make sense until the valuation phase starts,
since before that phase investments aren't selected nor their
feasibility is decided.

After that phase, the only phase where citizens are really involved
is the final voting; the rest of the phases are done by valuators and
administrators. In the final voting, citizens can only vote on selected
projects, and that's the default filter during that phase.

So these filters are mainly there for information purposes, and not to
help citizens in the phases where they're actually involved (accepting
projects, selecting projects and balloting).

Orders, on the other hand, play a crucial role during the final voting
phase. Since citizens might have already voted for a few projects and
have, let's say, 100,000€ left, ordering by price allows them to find
which projects are within their remaining budget.

In conclusion, orders are more important than filters, and so they
should have a more prominent place.

For consistency with the proposals section, where we've got some links
in the sidebar (bottom part of the page on small screens) providing a
similar funcionality, like accessing selected proposals or archived or
retired proposals, we're moving the investments filters to the sidebar
(bottom part of the page on small screens) as well.
2021-10-29 14:53:33 +02:00
Machine Learning
4d27bbebad Add experimental machine learning 2021-08-16 16:31:04 +02:00
Javi Martín
c8d8fae98d Move related list partial to a component
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
2021-08-16 16:30:13 +02:00
Javi Martín
b162ad512a Remove row and column divs in debate/proposal form
We don't need any row classes anymore because the <body> already has a
maximum width. As for columns, we only have one column in this form, so
we don't need them either. Besides, the form's parent element already
has a padding.
2021-07-13 15:27:13 +02:00
Javi Martín
53d49c223e Fix font icon line-height
We forgot to include this property when replacing our use of `%fa-icon`,
and it was causing the admin menu to have a blank space at the bottom.

So we're including it again to make sure nothing else breaks because of
this omition.
2021-07-02 18:33:16 +02:00
Javi Martín
4d49ec8efe Limit Font Awesome imports to reduce CSS size
We were using Font Awesome fonts and selectors to support the browsers
which don't support mask images (at the time of writing, about 5% of the
browsers). However, we were only importing the selectors in order to
extend them. This resulted in our compiled CSS including styles for
every Font Awesome icon (currenty, more than a thousand), even if we
only use a few of them.

So we're using Font Awesome variables instead of using the selectors it
provides. Since variables are only compiled in the CSS if they're
actually used, this reduces the size of our compiled CSS considerably.
In production environments, the size is reduced from 539KB to 475KB,
meaning we reduce its size in about 12%.

The downside here is we can't easily use Font Awesome variables in our
Sass mixins because we can't use interpolation in variable names (that
is, we can't use `$fa-var-#{icon}`). So we're using a map containing all
Font Awesome variables in order to access it in the mixin.

Note installations using `.fa-*` selectors will now have to add extra
`@import` clauses.
2021-06-30 16:41:39 +02:00
Javi Martín
38436b1102 Load vendor CSS before application CSS
So we make sure the rules we add will take precedence over vendor rules.
2021-06-29 17:08:40 +02:00
Javi Martín
0aba34ad4d Extract social links to a component 2021-06-24 12:43:43 +02:00
Javi Martín
b549eb444a Allow several custom stylesheets
So other institutions customizing CONSUL can organize their custom code
as they wish to.

We're also updating the comments in the `custom.scss` file, since it was
referencing files which no longer exist.
2021-06-02 16:15:00 +02:00
Javi Martín
4d70f50a5f Fix order loading custom styles
We have to load the custom styles last so they actually override what we
do.
2021-06-02 16:14:59 +02:00
Javi Martín
0846766dd6 Load leaflet CSS before our styles
This way we don't have to use the `!important` flag to override styles.
2021-06-02 16:14:24 +02:00
Javi Martín
fb8c476fb2 Extract component for ballot investment
Using component inheritance we can remove duplication and share the same
view.
2021-03-24 15:48:24 +01:00
Javi Martín
c08aa6ade5 Split SCSS mixins in several files
One file was OK when we only had a couple of mixins, but recently we've
been adding quite a few.

We can now avoid a SCSS Lint warning by excluding just the file with the
affected mixin.
2021-03-24 15:48:24 +01:00
decabeza
04605d5d5b Add filters on budget investments index page
Now it's easier to change the investments filter. Previously we had to
go back to the budget index page, change the filter there, and then
select one heading.

Now the links to change the current filter in the budget index page
aren't needed anymore.
2021-03-17 13:44:01 +01:00
Javi Martín
46e80bf430 Extract budget phases to a component 2021-03-09 16:37:47 +01:00
Julian Herrero
b1cb981980 Add help text in budgets admin index
Co-authored-by: decabeza <alberto@decabeza.es>
2021-02-18 23:40:40 +01:00
Javi Martín
f11f2cd3dd Extract component to render notifications item 2021-02-16 00:00:49 +01:00
Javi Martín
0d3c4c8154 Simplify styling tags
This way we won't have to add the `inline-block` and `no-bullet` classes
to other elements and we can define the styles in one place.

Note we're using the `ul.tags` selector instead of just `.tags` to avoid
conflicts with a `div.tags` selector which is used to select tags in a
form. Renaming the selector to `.tag-list` would be better, but we
aren't doing so because it would break custom stylesheets using that
selector.

Also note we're keeping the %tags placeholder selector in `.tags`
selector in the participation.scss file. This is so styles are not
overwritten by selectors like `.debate-show ul li`, which has the same
specifity as `ul.tags li`.
2021-01-27 15:55:21 +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
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
2faf99c54b Extract advanced search into a component 2021-01-10 15:54:23 +01:00
Javi Martín
330efe5a41 Extract components for feeds 2020-12-27 16:44:51 +01:00
Javi Martín
a73ab57cef Add basic header to SDG goals view 2020-12-23 13:18:17 +01:00
Javi Martín
a42cb050a7 Add SDG content section 2020-12-02 12:38:03 +01:00
Javi Martín
64b0cc741b Improve table actions layout
In the past we were using some <div> tags surrounding table action
links in order to guarantee these links wouldn't be wider that their
cell's space and wouldn't expand over two lines.

However, while these links didn't expand over two lines, at certain
resolutions the width of their text exceeded the width of the links,
causing part of the text to be outside their borders.

This behavior was also inconsistent: some tables had these <div> tags,
and some tables didn't.

Since we've now introduced the table actions component, the code is more
consistent and we're getting rid of these <div> tags. So now we're again
facing the issue where links could expand over two lines.

Using a flex layout solves this issue and considerably improves the
layout at lower resolutions.
2020-10-21 13:19:52 +02:00
Senén Rodero Rodríguez
b2196561e2 Override proposal sticky top property when anchored
It's known that Foundation Sticky causes some renderization problems
when rendering sticky elements in anchored position.

The problem seems to be that Foundation Sticky is showing the
support box on medium and up devices overlapped with "Share" and
"Community" sidebar boxes when loading proposal page through
Turbolinks and when restoring the page from brwoser history.
Foundation seems to be doing some top property dynamic calculation
(javascript) and is setting top property to `206px` when it should be
`0px`. Notice that this do not happen on page first load (without
Turbolinks). Check foundation/foundation-sites issue 11098.

Another workaround could be to remove sticky feature for bigger that
small devices (medium large xlarge xxlarge).
Check foundation/foundation-sites issue 9892.
2020-08-24 19:41:14 +02:00
Javi Martín
6172dd0a56 Group phase related fields in fieldsets
We were using a <label> tag with no associated field where a <legend>
tag was more appropriate. With a fieldset, we also make it obvious these
fields are related.
2020-08-15 13:31:32 +02:00
decabeza
18975a3963 Add font-awesome-sass gem
Now can use all icons from https://fontawesome.com.
2019-10-23 15:49:15 +02:00
Javi Martín
afa8bf8dba Add basic headings and navigaton styles for stats 2019-05-21 13:50:15 +02:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
decabeza
acc7cf65e3 Replace single quotes to double quotes on scss files 2019-02-11 17:42:58 +01:00
Javi Martín
51a4ca98ad Move milestone styles to their own sheet 2019-01-18 14:26:02 +01:00
decabeza
35dca0a17a Removes dashboard poster css file 2018-10-17 01:11:11 +02:00
decabeza
775b4698be Moves all new styles to dashboard.scss 2018-10-05 18:52:04 +02:00
decabeza
71c70b8324 Removes foundation icons font 2018-10-05 17:42:14 +02:00
Juan Salvador Pérez García
6cc1ddb9af Fixes #231
Implements a poster feature for the proposals dashboard
2018-07-31 12:50:25 +02:00