Commit Graph

18471 Commits

Author SHA1 Message Date
Javi Martín
b0680628ba Extract function to add investment markers 2023-05-04 15:27:15 +02:00
Javi Martín
21ce7689c2 Don't overwrite marker when creating investment markers
The `marker` variable is like a global variable inside the
`initializeMap` function, so assigning it inside the `createMarker`
function was changing its value in other places.

So we're using different variable names like `newMarker` in order to
make the code easier to follow. Now we "only" change the `marker`
variable in functions that modify the marker.
2023-05-04 15:27:15 +02:00
Javi Martín
74d165ae7a Extract function to create a map 2023-05-04 15:27:15 +02:00
Javi Martín
2e8bc11c2a Extract functions to update map form fields 2023-05-04 15:27:15 +02:00
Javi Martín
f8053c9532 Extract function to get popup in map JavaScript 2023-05-04 15:27:15 +02:00
Javi Martín
4087066c59 Extract function to add map attribution 2023-05-04 15:27:15 +02:00
Javi Martín
00cd91c6b2 Extract functions to get coordinates in map JS
We had 130 lines long function, and we're trying to reduce its size so
it's easier to follow the code.
2023-05-04 15:27:15 +02:00
Javi Martín
e75211125a Remove duplicate i18n text to remove marker
We had two different keys with the same text and were passing it as a
parameter. Since the text is the same in any case, we don't need a
parameter for it.

Note we are using the `proposals` i18n key instead of creating a new one
in a `shared` namespace one because creating a new key would mean that
we'd lose the already existing translations in Crowdin.
2023-05-04 15:27:15 +02:00
Javi Martín
c667582c98 Remove redundant value assignments in map fields
Rails forms automatically take the value from the object related to the
form.
2023-05-04 15:27:15 +02:00
Javi Martín
b9518d64e1 Use Rails methods to get map location input IDs
We were manually generating the IDs in order to pass them as data
attributes in the HTML in a component where we don't have access to the
form which has the inputs.

However, these data attributes only make sense when there's a form
present, so we can pass the form as a parameter and use it to get the
IDs.

We can now define a map as editable when there's an associated form,
which makes sense IMHO.
2023-05-04 15:27:15 +02:00
Javi Martín
84fff2e9fb Simplify code setting marker data in maps
We were probably setting them separately to avoid having blank data
attributes in the HTML. However, when a data attribute is `nil`, Rails
doesn't write it in the HTML in the first place.
2023-05-04 15:27:15 +02:00
Javi Martín
e00aa807b9 Make remove marker label parameter optional
We were passing `nil` in some calls, which was confusing.

Since now we've got two optional parameters, we're using named
parameters.
2023-05-04 15:27:15 +02:00
Javi Martín
aa5f5235de Simplify creating a map location from a heading 2023-05-04 15:27:15 +02:00
Javi Martín
deb965bcce Remove editable parameter in render_map
The calls to `render_map` are confusing since there are so many
parameters. We can assume that the map is editable if we pass the remove
marker label.
2023-05-04 15:27:15 +02:00
Javi Martín
19adae993e Simplify method names in map component
Since we aren't using helpers anymore, we don't need the `map_location`
prefix.
2023-05-04 15:27:15 +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
c7de42ab96 Simplify map location coordinates helpers
We're calling this method after setting the map location with
`map_location = MapLocation.new if map_location.nil?`, so the condition
`map_location.present?` is always going to be true.
2023-05-04 15:27:15 +02:00
Javi Martín
b0b7d0f25b Remove unused legislation proposals map action
The only view that linked to this action was never used and so it was
deleted in commit 0bacd5baf.

Since now the proposals controller is the only one place rendering the
`shared/map` partial, we're moving it to the proposals views.
2023-05-04 15:27:10 +02:00
Javi Martín
2f8717aa52 Merge pull request #5109 from consul/fix_removing_different_map_location
Avoid removing other proposals map locations
2023-04-28 17:43:03 +02:00
Javi Martín
6105de307b Rename map_location variable containing parameters
When it was named `map_location`, I constantly thought it was an object
instead of a hash.
2023-04-28 17:16:07 +02:00
Javi Martín
65ed778226 Avoid removing other proposals map locations
It was possible to remove a map location from a different proposal (even
one created by a different author) by modifying the hidden `id`
parameter in the form.

So we're making sure the map location we destroy is the one associated
to the proposal we're updating.

Since we're now using the `@proposal` instance variable in the
`destroy_map_location_association` method, we're calling that method
after loading the resource with cancancan.
2023-04-28 17:11:59 +02:00
Javi Martín
eaf28ef6fb Merge pull request #5107 from consul/fix_map_investments_after_voting
Fix wrong investments on the map after voting
2023-04-28 15:44:26 +02:00
Javi Martín
4954038076 Only re-render my ballot after voting
We were rendering the whole sidebar again, which wasn't necessary since
most of it remains unchanged. This resulted in complicated code to pass
the necessary information to render the same map that was already
rendered. Furthermore, when users had been moving the map around or
zooming out, we were resetting the map to its default settings after
voting, which was potentially annoying.

This also fixes the wrong investments being displayed in the map after
voting; only the investments on the current page were displayed in this
case while the index displayed all of them.
2023-04-27 17:39:56 +02:00
Javi Martín
d0be5c4850 Extract component to render my ballot
This is the only part of the sidebar that needs to be re-rendered after
an AJAX request adding or removing investments to a ballot, so having a
separate view just for it will make it easier to simplify the code.
2023-04-21 17:39:55 +02:00
Sebastia
17d7451816 Merge pull request #4931 from consul/dependabot/bundler/master/devise-security-0.17.0
Bump devise-security from 0.16.0 to 0.17.0
2023-04-21 12:09:59 +02:00
Javi Martín
e421484c38 Merge pull request #5102 from consul/dependabot/bundler/nokogiri-1.14.3
Bump nokogiri from 1.13.10 to 1.14.3
2023-04-20 19:52:11 +02:00
dependabot[bot]
a93b768e0d Bump nokogiri from 1.13.10 to 1.14.3
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.10 to 1.14.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.10...v1.14.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-20 19:34:06 +02:00
dependabot[bot]
0d8def373b Bump devise-security from 0.16.0 to 0.17.0
Bumps [devise-security](https://github.com/devise-security/devise-security) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/devise-security/devise-security/releases)
- [Commits](https://github.com/devise-security/devise-security/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: devise-security
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 17:20:23 +02:00
taitus
79d65305b0 Update test to test exactly what we want to test
Since this test was added in commit 78c6a30424 the
"current_password" was filled with an incorrect value.

This test did not fail because in previous versions of the
"devise-security" gem if this "current_password" was not valid
a "self.valid?" was performed which caused the error we are testing.

In version 0.17 (as can be seen in the following commit
https://github.com/devise-security/devise-security/pull/340/commits/41a99b67fe0)
if the "current_password" is not valid, related errors are still added
 but the "self.valid?" code is removed, which is what causes the
expected error "must be different than the current password"
to appear in the "new password" field.

By adding a correct "current_password" in the test, we avoid this validation
for the "current_password" (which no longer includes the expected error)
and follow the natural flow of devise that does end up intercepting the error
for the new password entered.
2023-04-18 17:20:23 +02:00
Senén Rodero
33f5f4cdb9 Merge pull request #5096 from consul/bump_leaflet
Bump Leaflet from 1.5.1 to 1.9.3
2023-04-14 17:39:51 +02:00
Senén Rodero Rodríguez
c3439ab539 Keep the same attribution as it was in previous versions 2023-04-14 14:38:53 +02:00
Senén Rodero Rodríguez
dd368ad650 Bump leaflet from 1.5.1 to 1.9.3
Newer versions have more capabilities and also fix lot of errors,
usability and accessibility issues.

Note that we're using an external gem to rails-assets.org as it's
not supports the rails-assets pipeline. This gems wraps the
original one and make the code work with the default rails assets
pipeline as usual.
2023-04-14 14:36:58 +02:00
Javi Martín
03a12ea60b Merge pull request #5074 from consul/ruby3.0
Upgrade Ruby to version 3.0.6
2023-04-13 17:32:41 +02:00
Javi Martín
f298715f78 Add Style/HashExcept Rubocop rule
We were already using it because Rails adds the `Hash#except` method for
Ruby 2.7 and earlier, but since the method wasn't part of Ruby itself,
the Rubocop rule only works with Ruby 3.0 and later.
2023-04-13 16:41:15 +02:00
Javi Martín
b911284b86 Update Style/RedundantFreeze rule for Ruby 3.0
In Ruby 3.0, Regexp and Range literals are frozen objects, and so we
don't need to freeze them.
2023-04-13 16:41:15 +02:00
Javi Martín
6c8445e3d7 Upgrade Ruby to version 3.0.6
Note the structure of the Gemfile changes slightly because Ruby 3.0
includes a new version of the Bundler gem.
2023-04-13 16:41:07 +02:00
Javi Martín
4d11d8a395 Specify translation class name in dummy test class
These tests were failing with Ruby 3.0 because we were getting an error
when loading the `translations` association of the dummy class:

```
NameError:
  uninitialized constant
  DummyBanner::#<Class:0x000055630e4dccd8>::Translation
```

Specifying the `class_name` of the `translations` association solves the
issue.
2023-04-13 16:31:28 +02:00
Senén Rodero
8e0acb8592 Merge pull request #5097 from consul/map_scroll_wheel
Disable scroll wheel for zooming in favor of map zoom buttons
2023-03-28 16:34:46 +02:00
Javi Martín
26f806b7fa Merge pull request #5095 from consul/one_server_on_preproduction
Use only one server when deploying to preproduction
2023-03-28 16:05:37 +02:00
Senén Rodero Rodríguez
3341c45e61 Disable scroll wheel for zooming in favor of map zoom buttons
It's causing annoying behaviour for desktop users when scrolling
the page to the bottom and there is more content below the
map.

The behaviour of touchable devices does not seem to be
affected by this change and keeps behaving the same.
2023-03-28 12:15:26 +02:00
Javi Martín
bbf6a31a05 Simplify deploy secrets example configuration file
So now it's similar to our database example file.
2023-03-21 19:15:25 +01:00
Javi Martín
8aa113a47c Unify deploy secret keys for the main server
We were using `server` on staging but `server1` and `server2` on
preproduction and production.

The reason behind it is we've always used one server on staging but
sometimes we've used several servers on preproduction and production.

However, this is a bit of a mess on installations which have only one
server on preproduction or production and need to use the `server` key
for the staging environments but `server1` for other environments.

So, in order to keep compatibility with existing Consul installations,
we're now allowing either `server` or `server1` on any environment.
2023-03-21 19:01:28 +01:00
Javi Martín
b115b0cc8d Use only one server when deploying to preproduction
It doesn't make much sense that by default we use one server on
production on two servers on preproduction.

Note we're keeping `server1` instead of using just `server` in order to
keep compatibility with existing installation.
2023-03-21 18:53:18 +01:00
Javi Martín
39574040e0 Merge pull request #5093 from consul/bump_erb_lint
Bump erb_lint from 0.0.37 to 0.3.1
2023-03-20 17:51:30 +01:00
Javi Martín
99b0ef07f2 Enable CommentSyntax ERB Linter
It's a default linter in erb_lint 0.3.0, and it's useful during
development since I'm always unsure about the right way to add ERB
comments.
2023-03-20 17:07:09 +01:00
Javi Martín
09a62d6f2c Bump erb_lint from 0.0.37 to 0.3.1
We also need to update pronto-erb_lint since the old version depended on
erb_lint 0.0.x.
2023-03-20 17:07:09 +01:00
Javi Martín
4ddcfde529 Explicitly enable ERB linters
I thought SelfClosingTag was enabled since it was on the list and the
`enabled: false` got lost among all the `enabled: true`. ERB Lint 0.1
and later will also add RequireInputAutocomplete as a default linter,
and we're not interested in it, at least for now.

So, just like we do for Rubocop, we're disabling all linters and
enabling the ones we use explicitly.
2023-03-20 17:06:05 +01:00
Javi Martín
448e9574b1 Merge pull request #5092 from consul/dependabot/bundler/rack-2.2.6.4
Bump rack from 2.2.6.3 to 2.2.6.4
2023-03-16 18:45:07 +01:00
dependabot[bot]
35153ad154 Bump rack from 2.2.6.3 to 2.2.6.4
Bumps [rack](https://github.com/rack/rack) from 2.2.6.3 to 2.2.6.4.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v2.2.6.3...v2.2.6.4)

---
updated-dependencies:
- dependency-name: rack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-16 16:18:14 +01:00
Sebastia
9bbde19d8d Merge pull request #5089 from consul/bing-translator
Use Bing Translator instead of TranslatorText
2023-03-15 17:50:51 +01:00