Commit Graph

20144 Commits

Author SHA1 Message Date
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
2ae419f3d1 Merge pull request #122 from consul/markdown-lint
Apply markdown lint rules
2023-04-21 17:17:27 +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
taitus
376f9ab568 Change "&" to "and"
Maybe using "&" is too informal for documentation.
2023-04-21 11:04:50 +02:00
taitus
08c78688db MD038 Spaces inside code span elements 2023-04-21 11:00:02 +02:00
taitus
32f825b6a6 MD034 Bare URL used 2023-04-21 11:00:02 +02:00
taitus
0d6a88abca MD033 Inline HTML
This rule is broken in the Spanish files in which we have had to create the
headers with html in order to make the links work correctly.

These changes were made in commit: 3126fe769
2023-04-21 11:00:02 +02:00
taitus
ab4fcf7e0c MD032 Lists should be surrounded by blank lines 2023-04-21 11:00:02 +02:00
taitus
31efa97076 MD031 Fenced code blocks should be surrounded by blank lines 2023-04-21 11:00:02 +02:00
taitus
e5a8f06049 MD026 Trailing punctuation in header
This rule is broken when we have ".,;::!?" in the headers.
We have removed the ones with ":" but kept the ones
with "?", so this rule will always warn in these cases.
2023-04-21 11:00:02 +02:00
taitus
d8786fd66a MD025 Multiple top level headers in the same document 2023-04-21 11:00:02 +02:00
taitus
1b0246e505 MD022 Headers should be surrounded by blank lines 2023-04-21 11:00:02 +02:00
taitus
3ed836f6af MD019 Multiple spaces after hash on atx style header 2023-04-21 11:00:02 +02:00
taitus
6ab85d4f19 MD012 Multiple consecutive blank lines 2023-04-21 11:00:02 +02:00
taitus
16a3189e0d MD009 Trailing spaces 2023-04-21 11:00:02 +02:00
taitus
1006940de5 MD006 Consider starting bulleted lists at the beginning of the line 2023-04-21 11:00:02 +02:00
taitus
78dfe298cb MD005 Inconsistent indentation for list items at the same level 2023-04-21 11:00:02 +02:00
taitus
65837049a2 MD002 First header should be a top level header
Adapt the rest of the headers.
2023-04-21 10:40:21 +02:00
taitus
dfcd7fe9f3 MD001 Header levels should only increment by one level at a time 2023-04-21 10:40:20 +02:00
taitus
b3a718ae64 Remove rule "MD029" Ordered list item prefix 2023-04-21 10:40:20 +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