Commit Graph

1026 Commits

Author SHA1 Message Date
Javi Martín
48db31cd6b Remove redundant links in admin tables
There were places where we had two links pointing to the same place; one
link would be the name/title of a record, and one link would be under
the "actions" column.

This is confusing, since users would probably expect these links to
point to different places (which is what happens in other tables in the
admin section) and might try to click one of them and then the other
one and be surprised when they found out both of them go to the same
page.
2020-10-21 13:19:52 +02:00
Javi Martín
3e2d7fd707 Fix crash in management with successful proposals
The page was crashing because it was looking for the `supports` partial
under `management/proposals`, when the right path was `proposals/`.
2020-09-22 21:19:35 +02:00
Javi Martín
a398f4aa13 Merge pull request #4126 from consul/max_headings_text
Clarify the meaning of max "votable" headings
2020-09-09 18:57:39 +02:00
Javi Martín
602daced6b Clarify the meaning of max "votable" headings
The word "vote" is confusing because this option does not apply to the
voting phase, but to the selecting projects phase.
2020-09-09 17:01:13 +02:00
Javi Martín
5332ae609e Filter investments only by assigned staff
In commit 74083df1 we added the possibility to assign administrators and
valuators to budgets, so they would only manage the budgets they're
assigned to.

However, when filtering projects, we were still showing all
administrators and valuators as options to filter investments. It makes
more sense to only show the valuators and administrators assigned to the
current budget.

Note this change only affects the view, and so malicious users could
technically send any other administrator or valuator ID. In this case,
they would get empty results since those administrators/valuators
wouldn't have any investments assigned, so taking this case into account
is not necessary.
2020-09-08 19:11:38 +02:00
Javi Martín
b2b64ca8a0 Add link to download summary in XLSX format again
It was removed in commit 128a8164 alongside everything related to the
legislation process summary.

Co-Authored-By: taitus <sebastia.roig@gmail.com>
2020-09-08 13:32:08 +02:00
Javi Martín
14df74fed7 Add collaborative legislation summary again
It was removed in commit 128a8164 because we hadn't reviewed it nor
tested it properly. We're now adding it again, fixing the issues we've
found while reviewing.
2020-09-08 13:32:08 +02:00
Javi Martín
996062fa19 Reset language select after adding a language
It worked differently after upgrading to jQuery 3. According to the
jQuery upgrade guide:

> It is almost always a mistake to use .removeAttr("checked") on a DOM
> element. The only time it might be useful is if the DOM is later going
> to be serialized back to an HTML string. In all other cases,
> .prop("checked", false) should be used instead.
2020-08-28 16:09:41 +02:00
Javi Martín
fc9a87a8ab Use native HTML5 date fields in the admin section
We've had to add a couple of hacks in order to make jQuery UI datepicker
work with Turbolinks, and one of our tests is failing because the
datepicker changes its height when changing from a month with 5 weeks to
a month with 6 weeks.

We could add a workaround so the test still passes (jQuery UI doesn't
provide a configuration option to always displays 6 weeks in the
datepicker), but I think it's easier to just use the HTML5 native date
input field, which also allows us to simplify the code a bit and IMHO it
improves the user experience, particularly when using mobile phones.

Since date fields are not supported in Safari and Internet Explorer,
we're still using the jQuery UI datepicker on those browsers (and on any
other browser not supporting date fields).

Due to these changes, we're moving the tests checking datepicker's
behaviour to the dashboard. I've choosing not to change the public pages
because I'm not 100% sure everybody would like this change (some people
prefer the datepicker because we can configure the way it looks).
2020-08-28 12:55:58 +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
1e70a3db02 Disable phase date fields when a phase is disabled
The JavaScript involved wasn't working since we removed the disable-date
attribute in commit 73ff6881.

We're also improving the JavaScript in two ways:

First, we trigger the `change` event immediately, so when the page loads
date fields are disabled when phases are disabled.

And second, we don't remove the selected dates when disabling a phase,
so disabling it and enabling it again will keep the selected values.
2020-08-15 13:31:32 +02:00
Javier Martín
11204b0194 Merge pull request #4083 from consul/disable_buttons
Don't disable button to download emails
2020-08-14 18:37:07 +02:00
Javi Martín
e319b93dc6 Don't disable button to download emails
Rails automatically disables buttons when submitting a form. This works
fine most of the time: for AJAX requests, it enables them again after
the request is complete, and for non-AJAX requests, the button is
replaced by a new element when the new page loads.

However, there's an exception. When a request returns data so users can
download a fire, the request is not an AJAX one and the button is not
replaced. So users are left with a disabled button they can no longer
click.

So in this case, we aren't disabling the button after a user clicks it.
2020-08-13 18:11:02 +02:00
Javi Martín
38ebfed6ea Remove redundant code to prevent double submission
As mentioned in commit 7f30d0c6, Rails already does it automatically.
2020-08-13 18:11:02 +02:00
Javi Martín
e5f71d33d0 Fix poll answer images not being displayed
After updating foundation-rails in commit 58071fd6, the orbit slider
stopped working properly. That's because the `.orbit-slide` elements now
use a `position: absolute` rule, and so our rule for `.orbit-container`
elements making their height 100% (which we added in order to be able to
add images with different heights) makes them have a height of 0px,
since now the `.orbit-slide` elements are not part of the document flow
anymore.

Making the `.orbit-slide` elements have relative position fixes this
issue, but introduces a different one, producing a really bad-looking
animation when changing a slide.

So we're disabling the animation as well in order to avoid this jump.

This change also fixes another issue introduced in commit 58071fd6 which
caused slide controls to stop working when changing slides back and
forth.
2020-08-12 17:18:49 +02:00
Javier Martín
b8894eac70 Merge pull request #3699 from consul/upgrade_turbolinks
Bump turbolinks to 5.2.1
2020-08-12 14:34:19 +02:00
Senén Rodero Rodríguez
87339451de Reset columns_selector before caching the page
This will allow to initialize this module again without duplicating
columns checkboxes and without breaking the page.
2020-08-12 10:10:58 +02:00
Senén Rodero Rodríguez
137e0f5a64 Remove description for screen readers
It was being duplicated when restoring a page by using browser
history. With this solution we will avoid to have screen readers
descriptions more than once inside any sociual share button.
2020-08-12 10:07:35 +02:00
Senén Rodero Rodríguez
6b17452bd5 Fix "Publish comment" button when restoring a page from browser cache
We need to use page body event delegation so it will work with any
element even with the ones added through ajax, in this case the
annotation comments box form. By doing this way we do not need
this code on the server response anymore.

Furthermore JS events defined at ajax responses are not part of
application javascript and are lost when restoring a page from
browser cache, you can try to apply the same event delegation
technique to the `erb` file and it wont work just because events
added dinamically are not treated the same than `application.js`
code.

To reproduce the error:

  1. Load an annotatable draft version
  2. Move to any other page
  3. Go back

Now "Publish comment" button wont work.
2020-08-12 10:07:35 +02:00
Senén Rodero Rodríguez
fc0625df8b Destroy Annotator app before storing page into brwoser cache
If we do not destroy annotator app before storing the page at
browser cache we will unnecesarily initialize annotations twice (or
more) duplicating Annotator HTML markup and causing
unexpected  errors.

Without this commit you will find an error when restoring a page with
annotator, you can click on any annotation and you will see the annotation
comments are being loaded twice.

IMO this is an idempotency issue within Annotator JS library.
2020-08-12 10:07:35 +02:00
Senén Rodero Rodríguez
da658f3d8c Hack datepicker to make it work with Turbolinks 5.x
Patch extracted from here the comments on turbolinks issue 253 and
converted to vanilla javascript.

The hide action over datepickers ensures us that opened datepickers
will be closed before leving the page. Previously if you open any
datepicker and then move to previous page you will keep seeing the
datepicker in the restored page.
2020-08-12 10:07:35 +02:00
Javi Martín
83e4633643 Don't redirect to POST request URLs after sign out
Sometimes we define URLs for POST requests which are not defined for GET
requests, such as "/residence", so redirecting to it after signing out
results in a routing error.

So instead of using the request referer, we're using the stored location
devise uses, and we're not storing locations in POST requests.
2020-08-11 18:19:48 +02:00
Javi Martín
2fa8792a35 Redirect users in homepage to homepage after login
For reasons I'm not sure about, the homepage (and the welcome pages)
were an exception in our "redirect users to the same page they were"
policy.

I'm not sure about the welcome pages (no test was present indicating
they should behave in a special way), but in the case of the home page,
it was a bit annoying to be redirected to a different place after
signing in.
2020-08-11 18:19:27 +02:00
Andriy Iun
1ee750e042 Keep GET params in return URL
When signing in from a page containing GET params, like
`/budgets/1/investments?heading_id=4`, we were redirected to a URL
without those GET params; in this case, `/budgets/1/investments`.

Using the request fullpath, as recommended in the devise documentation,
keeps these parameters when redirecting.
2020-08-11 18:19:25 +02:00
Julian Herrero
d720826e59 Add feature flag exception for the module polls 2020-08-11 11:10:10 +07:00
Julian Herrero
151aa6009d Allow links and images on legislation drafts
Note we're using a new sanitizer. Ideally we'd reuse the
`AdminWYSIWYGSanitizer`, but then code that would be correctly shown by
markdown-it (like the <h1> tag) wouldn't be shown on the web, which is
confusing. Ideally we would configure markdown-it to only allow the tags
present in the `AdminWYSIWYGSanitizer` and provide some kind of help
showing which tags are allowed.
2020-08-10 12:20:59 +02:00
Javier Martín
50372f4370 Merge pull request #4066 from consul/oauth_buttons
Show Wordpress login button if it's the only one enabled
2020-08-06 13:53:57 +02:00
Javier Martín
5fb951eeac Merge pull request #4063 from consul/approval_voting
Add approval voting to budgets
2020-08-06 13:52:19 +02:00
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00
Javi Martín
0270c4c962 Hide unsaved changes warning after undoing them
This way showing the warning is consistent with warning users when
they're leaving the page.
2020-08-05 14:10:22 +02:00
Javi Martín
cfc60b5de4 Warn for changes just in markdown editor
This is the reason why this feature was implemented in the first
place: it's easy to open the editor, make some changes, close it, and
continue without realizing the changes have not been saved.

In the rest of the forms, this functionality is quite lacking. For
starters, some forms warn if there are unsaved changes, while some forms
don't, which is highly inconsistent and disorients users.

Furthermore, we were having problems with this feature after upgrading
Turbolinks, particularly in forms using CKEditor. In these cases, a lot
of hacking needs to be done in order to make this feature work properly,
since CKEditor adds some formatting automatically, and if this is done
after the form is serialized, we'll get some unexpected behavior. On the
other hand, comparing the value of a textarea against its `defaultValue`
property will work on every edge case, including using the browser's
back button or reloading the page.

Finally, users are used to the way web forms work, and aren't used to be
asked for confirmation when they change their mind and decide to leave
the page without saving the changes. Asking them for confirmation will
be annoying in most cases. Besides that, if they accidentally leave the
page, they can use the browser's back button and they'll recover the
unsaved changes.

It's true this won't happen it they accidentally close the browser's
window, but our WatchFormChanges functionality didn't work in this case
either. Using the "beforeunload" event adds more problems than it
solves, since it doesn't support custom messages (or, to be more
precise, modern browsers ignore custom messages), and it doesn't get
along with turbolinks.

Co-Authored-By: Senén Rodero Rodríguez <senenrodero@gmail.com>
2020-08-05 14:10:22 +02:00
Javi Martín
f68553dc00 Extract method to fill in markdown editor in specs 2020-08-05 14:10:22 +02:00
Javi Martín
7b96180a76 Upgrade Turbolinks to version 5.2.1
We didn't upgrade Turbolinks when we upgraded to Rails 5 so we didn't
upgrade too many things at the same time, and postponed it... until now
:).

Note upgrading Turbolinks fixes an issue with foundation's sticky when
using the browser's back and forward buttons. We're adding tests for
these scenarios.

Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2020-08-05 14:10:22 +02:00
Javi Martín
983bf49b38 Simplify code related to Foundation's sticky
In the past we had huge problems trying to make it work with Turbolinks.
However, after updating foundation-rails in commit 58071fd6, these hacks
aren't necessary anymore.

We're adding a test for the scenario of visiting a page using
Turbolinks, which was missing, so we're sure we aren't breaking
anything.

Note the sticky will still not work after using the browser back button.
We haven't been able to make it work with turbolinks-classic; we'll fix
this issue when upgrading turbolinks.
2020-08-05 11:34:57 +02:00
Senén Rodero Rodríguez
fde6fb4d97 Initialize only visible maps when page is loaded
Its known that initializing a map when it is inside a hidden element
wont work when hidden element is shown, so its makes sense to
avoid initialization of hidden maps.

When a map lives within a hidden layer we need to initialize the
map after the event of showing that hidden layer, in our case when
admin settings tab is shown.
2020-08-05 11:34:57 +02:00
Julian Herrero
b7b05b55fe Show Wordpress login button if it's the only one enabled 2020-07-27 14:47:42 +02:00
Javier Martín
54095d7928 Merge pull request #4064 from consul/remove_google_plus
Remove Google plus share button
2020-07-21 13:03:59 +02:00
Javier Martín
7ee3eecae3 Merge pull request #3980 from consul/erased-users
Filter erased users and show erase reason in admin
2020-07-17 23:00:12 +02:00
decabeza
f72f255d15 Filter erased users and show erase reason in admin 2020-07-17 22:21:52 +02:00
decabeza
e3539544a8 Remove google plus share button 2020-07-17 16:24:20 +02:00
Javi Martín
d9eeb1ad15 Improve test checking order by relevance
The test wasn't working when postgres used the English dictionary
because in English the word "what" was ignored (or, at least, not given
enough relevance) while searching. When we wrote the test, it passed
because back then we always used the Spanish dictionary. However, when
we switched to a dictionary based on the default locale (in commit
d99875cd), we had to force this test to keep using the Spanish
dictionary.

Using the Spanish dictionary in a test where all texts are in English is
strange to say the least ;). So here we're making the test a bit easier
to understand.

Since now we're only using the `:spanish_search` tag in one test, I've
decided to remove it and simply add it to that test's setup.
2020-07-14 14:49:39 +02:00
Julian Herrero
89962ba61a Allow deleting polls with answers including videos
If a poll has a question with an answer containing a related video,
an error was raised because the poll ID was referenced in another
table.
2020-07-09 13:39:15 +02:00
Javi Martín
4f30720593 Fix flagging/unflagging in the admin section
We weren't adding the HTML id our JavaScript expects, and so the page
didn't update the flag element.
2020-07-07 23:39:21 +02:00
Javi Martín
014ccd8374 Use shared specs to flag comments 2020-07-07 23:39:21 +02:00
Javi Martín
3c27df592e Remove test for flagging poll comments
This feature hasn't been implemented and there are no plans to implement
it in the near future.
2020-07-07 23:39:21 +02:00
volcov
09fd3ab44a Fix legislation proposals flag actions
We were treating legislation proposals as if they were proposals,
omitting the "legislation" namespace, and so we were flagging/unflagging
proposals when we wanted to flag/unflag a legislation proposal.
2020-07-07 23:39:21 +02:00
Javi Martín
91da038b27 Extract shared tests to flag/unflag a record 2020-07-07 22:56:17 +02:00
Javi Martín
9937e94fcd Fix flagging debates and comments with AJAX
We weren't using `foundation()` in these cases, so after flagging a
debate or a comment, we had to reload the page before we could unflag
it.

We're also adding a test for the fix in commit ea85059d. This test shows
it's necessary to filter the elements with JavaSctipt using `first()` if
we want the same code to work with comments.

Co-Authored-By: taitus <sebastia.roig@gmail.com>
2020-07-07 22:56:17 +02:00
Javier Martín
328ec5e25f Merge pull request #4001 from rockandror/check-session-locale
Discard session[:locale] when is not valid
2020-06-25 22:00:37 +02:00
taitus
ee5ac25cb1 Improve set_locale
We discard session[:locale] as valid locale when it is no longer include in
the :available_locales
2020-06-25 19:45:56 +02:00