Commit graph

452 commits

Author SHA1 Message Date
Paul Chavard
967699c305 fix(select): improuve no results found message 2022-01-11 12:10:20 +01:00
Paul Chavard
d6b6bb0f2a a11y(combobox): add support for describedby and labelledby and improuve external fields handling 2022-01-05 12:33:40 +01:00
Paul Chavard
6776a5e05a fix(react): remove register component cache 2022-01-03 19:41:23 +01:00
Pierre de La Morinerie
07230870d3 js: don't track external links
This fixes an issue where, by default, links to private attachments are
reported to Matomo.

This is benign: attachments URLs can be filtered out server-side, and
expire after one hour anyway. But we don't want to ship an insecure
configuration by default.
2021-12-23 09:50:21 +01:00
Paul Chavard
f8d245d2f8 refactor(js): use dynamic import 2021-12-21 17:09:49 +00:00
Paul Chavard
ed2cbdc966 fix(champ): save departement name without code prefix 2021-12-06 20:58:08 +01:00
Pierre de La Morinerie
115ca5e24a js: don't create invalid menus by default
When a new "Menu" type de champ is added, it comes pre-filled with a
menu title – and nothing else. Which is confusing, and invalid.

Instead pre-fill the type de champ with actual values (no titles).
2021-12-02 09:00:37 +01:00
Paul Chavard
7d189575af fix(commune): do not display foreign departement when selecting commune 2021-11-25 13:49:57 +03:00
mfo
91c3a8be19 fix(eslint): max columns 2021-11-25 13:43:28 +03:00
Martin
0d486981a6 fix(ComboCOmmunesSearch.typo): fix combo communes search typo 2021-11-25 13:43:28 +03:00
Paul Chavard
ae09b37e72 fix(champs): save departement info on champ commune 2021-11-17 14:52:47 +03:00
Paul Chavard
ba0211ba52 feat(champ): ask for departement before asking for commune 2021-11-04 11:55:25 +01:00
Paul Chavard
7ebc439630 refactor(drop_down_list_champ): other option 2021-10-27 12:01:15 +02:00
Paul Chavard
8154daf847 refactor(drop_down_list_champ): other option 2021-10-27 12:00:39 +02:00
kara Diaby
c2fcd3992d add other option for dropdown select 2021-10-26 16:11:15 +02:00
kara Diaby
0e65916e44 add other option for dropdown radio 2021-10-26 16:11:15 +02:00
kara Diaby
dc35d9521f add other option to liste deroulante champ 2021-10-26 16:11:15 +02:00
Paul Chavard
d308448f02 feat(type_de_champ): add secondary label and description do linked drop downs 2021-10-26 12:18:01 +02:00
simon lehericey
933d7b8c8d merge with another preexisting account 2021-10-14 14:47:50 +02:00
simon lehericey
ce40e1127d merge with another new account 2021-10-14 14:47:50 +02:00
simon lehericey
19f81b594b merge with an existing account by using the password 2021-10-14 14:47:50 +02:00
Pierre de La Morinerie
b2774ed2f6 js: fix pays API request on older Edge and Safari
The /api/pays API requires user authentication. However older versions
of Edge and Safari don't transmit cookies by default during a
`fetch` request.

Use the `credentials: 'same-origin'` option explicitely to fix the
countries list.
2021-09-30 16:21:24 +02:00
Pierre de La Morinerie
4f33a7b72e js: improve auto-save-controller documentation 2021-09-07 16:45:52 -05:00
Pierre de La Morinerie
ad8dcc7f7d js: don't report autosave failures that are timeouts
This prevents spamming Sentry with "[Autosave] Error: 0" messages.
2021-09-07 16:45:52 -05:00
Pierre de La Morinerie
8dce7d59ed js: redirect to sign-in when a ujs link_to receives a 401
Before, when a 401 was received by a ujs-enabled link (like `link_to …,
method: :delete, data: { remote: true }`, rails-ujs tried to insert the
response text as a Javascript script.

As the script was something like `Please sign-in`, which is not valid
Javascript, the browser would throw an "Unexpected token" error.

The typical use-case is:

1. The user open a form in a tab,
2. The user disconnects in another tab,
3. In the first tab, the user clicks on a remote "Delete" link_to

In that case the browser raised an error in the console (and in Sentry),
but the user would see nothing.

With this commit, all 401 ujs errors are turned into redirects to the
sign-in page.

Fix https://sentry.io/organizations/demarches-simplifiees/issues/2522512693/activity/
2021-09-07 16:45:52 -05:00
Pierre de La Morinerie
255c00c174 js: ignore a new variant of the same warning 2021-09-07 16:45:52 -05:00
Jérôme Desboeufs
7079af2fd4
Update photographies-aeriennes basemap URL 2021-09-01 21:58:12 +02:00
Pierre de La Morinerie
7380d27d78 js: fix null xhr in autosave error handling
Sentry reports many cases of the xhr object being missing in the
error handler.

Ensure the error handling code doesn't crash because of the missing xhr.
2021-08-31 14:54:02 -05:00
Paul Chavard
5d63ced246 fix(eslint): fix eslint warnings 2021-08-31 18:14:04 +02:00
Paul Chavard
a3cc072bbd feat(i18n): translate countries selector 2021-08-31 13:15:26 +02:00
Paul Chavard
b81cfea0e4 fix(combo-search): can input empty value 2021-08-18 15:48:37 +01:00
Paul Chavard
2a84f14521 Make generic 2021-08-18 12:09:20 +02:00
Pierre de La Morinerie
e1909ed29f brouillon: redirect to sign-in when disconnected
There are two cases where the draft auto-save might fail because the
user is no longer authenticated:

- The user signed-out in another tab,
- The brower quit and re-opened, so the Session cookie expired.

In both cases, the auto-save will never succeed until the user
authenticates again, so displaying a "Retry" button is cruel.

Moreover, in plus of all auto-save requests failing with a small error,
the actual hard failure only occurs after filling all the form and
trying to submit it. Then the user is redirected to the sign-in page –
but all their changes are lost.

Instead, we now redirect to the sign-in page on the first 401 error
during the auto-save, let the user sign-in, and then redirect back to
the form.
2021-07-22 11:58:02 +02:00
Pierre de La Morinerie
7808f6dd4f js: document utils.ajax() 2021-07-22 11:58:02 +02:00
Pierre de La Morinerie
c6fff58f38 js: fix typo in comment 2021-07-22 11:58:01 +02:00
Pierre de La Morinerie
071d9145ca js: don't attempt to log unexistent statusText 2021-07-22 11:58:01 +02:00
Paul Chavard
c7b0b8495b Get more results from communes API and use local matcher 2021-07-20 13:34:17 +02:00
Pierre de La Morinerie
63cde95fc9 js: ignore errors generated by a Microsoft crawler
Sentry has a lot of Javacript errors stating:

> UnhandledRejection: Non-Error promise rejection captured with value: Object Not Found Matching Id:2 

This is apparently caused by a Microsoft crawler (maybe for scanning
targets of email links), and can be safely ignored.

See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062/12
2021-07-20 09:21:59 +02:00
Paul Chavard
38fdaa7404 Trigger onStyleChange when leyers are toggled 2021-07-07 16:23:55 +02:00
Paul Chavard
1e4c943392 Fix map controls checkbox labels 2021-07-07 15:38:21 +02:00
Paul Chavard
65adce1e24 Fix cadastres layer 2021-07-07 15:38:21 +02:00
Paul Chavard
527db7631e Add a point on map from coordinates input 2021-07-07 13:33:28 +02:00
Paul Chavard
0ce708028d Prevent crashes in combo boxes 2021-07-06 15:06:38 +02:00
Paul Chavard
87fb98f5ed Make IGN layers opacity configurable 2021-07-06 10:36:12 +02:00
Paul Chavard
fc966a2761 IGN layers on maps can now be disabled by the user 2021-06-30 20:07:52 +02:00
Paul Chavard
10cdd2c77e Apply suggestions from code review
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
2021-06-16 09:38:47 +02:00
Paul Chavard
7f28c49887 expand commune searches with multiple post codes 2021-06-16 09:29:25 +02:00
Paul Chavard
7575f50d25 Fix autocomplete on blur 2021-06-15 10:13:31 +02:00
Paul Chavard
7f4e174871 Declare useCallback dependencies 2021-06-15 10:13:31 +02:00
simon lehericey
6be0bbaa9c Change bottom champs editor button from enregistrer to continuer 2021-06-15 09:54:32 +02:00
Paul Chavard
1b0cc62fc2 Add cadastres to MapReader 2021-05-24 11:57:00 +02:00
Paul Chavard
2244263b49 Add cadastres to MapEditor 2021-05-24 11:57:00 +02:00
Paul Chavard
19440afebf Improuve mapbox utilis and shared components 2021-05-24 11:57:00 +02:00
Paul Chavard
bf462380e6 MultiSelect: select values on blur 2021-05-20 17:21:13 +02:00
Paul Chavard
3313ea5885 MultiSelect: do not show empty results on free form inputs 2021-05-20 17:21:13 +02:00
Paul Chavard
e0d8d096f2 MultiSelect: improuve setters 2021-05-20 17:21:13 +02:00
Paul Chavard
868ec214ce MultiSelect: enable adding multiple emails with , or space 2021-05-20 17:21:13 +02:00
Paul Chavard
bf9f29cc71 Fix messagerie scroll to last message 2021-05-20 11:58:54 +02:00
Paul Chavard
69ab7854c2 replace fontawesome with heroicons 2021-04-29 15:20:05 +02:00
Paul Chavard
6e1b4a2067 Update and pin mapbox-gl 2021-04-28 15:34:53 +02:00
Paul Chavard
85b907807a Improuve ComboMultipleDropdownList style 2021-04-28 12:54:45 +02:00
Paul Chavard
6836191ca5 Improuve commune autocomplete results 2021-04-22 09:59:21 +01:00
Christophe Robillard
6026793c1d focus to target after toggle 2021-03-17 11:31:51 +01:00
Christophe Robillard
df3bd3a1d2 handle focus during and after upload 2021-03-17 11:31:51 +01:00
Christophe Robillard
43039d1755 add aria-value min, max and now for progressbar upload 2021-03-17 11:31:51 +01:00
Paul Chavard
6f543d3770 Handle invalid GeoJSON in the editor 2021-03-11 15:51:09 +01:00
Paul Chavard
9f8c55969d Add proper external data API errors handling 2021-03-04 10:16:06 +01:00
Paul Chavard
2c2b392d6c Fix multiselect labels
only add values to new values if it is a new value
2021-02-19 12:08:54 +01:00
Paul Chavard
24f71ccc1a Improuve multi select
In multi select with acceptNewValues option alway keep the new value as the first item in the list to make it easier to add it
2021-02-19 10:53:16 +01:00
Paul Chavard
6756db1013 Update react-query 2021-02-16 18:14:11 +01:00
Paul Chavard
bb49f6e151 replace react-use with use-debounce
this is a much lighter dependencie
2021-02-16 18:14:10 +01:00
Paul Chavard
3dae5b5c04 update react 2021-02-16 18:14:10 +01:00
Paul Chavard
df80f5681d remove react-scroll-to-component 2021-02-16 18:14:10 +01:00
Paul Chavard
1c164c4376 Use jsx extension 2021-02-16 18:14:10 +01:00
Paul Chavard
881820888a Use stable cache key for useMemo 2021-02-16 16:47:15 +01:00
Christophe Robillard
8b55f67964 accepte nouvelles valeurs pour ComboMultipleDropdownList 2021-02-16 16:47:15 +01:00
Paul Chavard
06e282b839 supprime select2
select2 n'est plus utilisé. Il est remplacé par
ComboMultipleDropdownList
2021-02-16 16:47:15 +01:00
Christophe Robillard
e048f48241 create ComboMultipleDropdownList component 2021-02-16 16:47:14 +01:00
Paul Chavard
a503417298 Remove old css and js 2021-02-02 15:26:11 +01:00
Paul Chavard
9f691dce4c Set external_id from combo search inputs 2021-01-15 11:50:02 +01:00
Paul Chavard
91be115c70 Add annuaire_education champ ui 2021-01-14 17:57:48 +01:00
Paul Chavard
6ca9daab0f Ensure a combo always autosave value on change 2021-01-14 17:31:37 +01:00
Paul Chavard
075ee9dcde Fix cadastres layer 2020-12-11 14:47:50 +01:00
Paul Chavard
1af0d30d94 Use new optional layers in maps module 2020-12-10 11:26:16 +01:00
Paul Chavard
eaa9b1c071 Expose all optional layers in TypeDeChamp editor 2020-12-10 11:26:16 +01:00
Christophe Robillard
ddd50993a5 cache pays 2020-12-08 13:09:08 +00:00
Christophe Robillard
12d1a5bece implement ComboPaysSearch 2020-12-08 13:09:08 +00:00
Paul Chavard
618c81b9a6 Mount react components on page updates 2020-10-15 18:46:12 +02:00
Paul Chavard
ca0ba4ba2d replace deprecated react-loadable with suspense 2020-10-15 17:30:49 +02:00
Paul Chavard
752ee78c49 Use fetch instead of jQuery 2020-10-13 10:55:10 +02:00
Paul Chavard
70bf9ea92f remove unused select2 code 2020-10-08 15:26:15 +02:00
Paul Chavard
8a2f079acb Implement ComboAdresseSearch 2020-10-08 15:26:14 +02:00
Paul Chavard
b6c94a3758 Implement ComboCommunesSearch 2020-10-08 15:26:14 +02:00
Paul Chavard
4217dcd94b Implement ComboDepartementsSearch 2020-10-08 15:26:14 +02:00
Paul Chavard
2c7ee82d31 Implement ComboRegionsSearch 2020-10-08 15:26:14 +02:00
Paul Chavard
1b57d94d93 Use @reach/combobox instead of select2 2020-10-08 15:26:14 +02:00
Paul Chavard
5df7a729e7 Add a wrapper to catch chart rendering before chartkick is loaded 2020-10-07 11:40:07 +02:00
Paul Chavard
d8852c7dc5 Lazily load trix 2020-10-07 11:40:07 +02:00
Paul Chavard
95eb907090 remove unused javascript 2020-10-07 11:39:57 +02:00
Christophe Robillard
6fd0134b6d convert to es6 classes 2020-09-22 16:09:15 +02:00
Christophe Robillard
8baaee8810 load expanded buttons only for contact form 2020-09-22 16:09:15 +02:00
Christophe Robillard
5bd4644c2c fix js lint errors 2020-09-22 16:09:15 +02:00
Christophe Robillard
9be015752a set input value for question type of contact page 2020-09-22 16:09:15 +02:00
Christophe Robillard
df9a15a224 expand buttons for contact page 2020-09-22 16:09:15 +02:00
Paul Chavard
512cdeb6ff normalize features on import 2020-09-22 09:12:55 +02:00
kara Diaby
5c68d75107 add titre_identite champ 2020-09-18 14:57:08 +02:00
Christophe Robillard
51c4001a1a add aria-disclosure for Mon compte button 2020-09-15 18:12:26 +02:00
Paul Chavard
bbcdff0ccf Use IGN plan v2 and add MNHN data sources 2020-09-15 14:39:02 +02:00
Pierre de La Morinerie
e033ec3404 js: ignore missing DOM element on ProgressBar
Currently ProgressBar is used to monitor upload progress of attachments.

But there's two cases where the associated DOM element may be removed:

- In the champs editor, when the list scrolls, DOM elements are removed
and added dynamically by React;
- In the user form, the user might start an upload on a repetition, and
then remove the associated row during the download.

In both those cases, we don't want the missing DOM element to trigger
an error.
2020-09-03 15:03:13 +02:00
kara Diaby
ae61c279af migrate emails text editor to new interface 2020-09-03 14:42:22 +02:00
Paul Chavard
ec72fdd164 Remove migration service 2020-09-02 11:26:26 +02:00
kara Diaby
1788471664 carto hack : traduce edition buttons in french 2020-09-01 17:41:20 +02:00
Pierre de La Morinerie
ecc4f01c20 autosave: trigger an autosave after removing a row 2020-08-25 15:45:49 +02:00
Pierre de La Morinerie
96037069ff autosave: remove the repetition row after deletion
Before, when autosaving a draft, removing a repetition row would
send `_destroy` inputs to the controller – but not remove the row
from the DOM. This led to the `_destroy` inputs being sent again
on the next autosave request, which made the controller raise
(because the row fields were already deleted before).

To fix this, we let the controller response remove the deleted
row(s) from the DOM.

Doing it using a controller response avoids the need to keep track
of operations on the Javascript side: the controller can easily
know which row was just deleted, and emit the relevant changes for
the DOM. This keeps the autosave requests robust: even if a request
is skipped (e.g. because of a network interruption), the next request
will still contain the relevant informations to succeed, and not let the
form in an unstable state.

Fix #5470
2020-08-25 14:39:34 +02:00
Pierre de La Morinerie
e157a289e1 autosave: factorize some javascript code 2020-08-25 14:39:34 +02:00
Paul Chavard
4c87e547b3 Put IGN map behind a feature flag 2020-07-30 17:22:28 +02:00
Paul Chavard
f1cbc9846e Add carte ign 2020-07-30 16:58:20 +02:00
Paul Chavard
87a1661cdc fix prop type error 2020-07-22 11:10:14 +02:00
Pierre de La Morinerie
5949266e89 javascript: silence Crisp warning in Javascript console 2020-06-26 15:57:14 +02:00
kara Diaby
3dacff19d5 [CARTO] fix the GPX and KML imports in order to manage multiples draw types in the same file 2020-06-18 16:28:46 +02:00
Paul Chavard
d9f7d10425 Refactor Map Reader|Editor to handle events from geo areas list 2020-06-09 18:45:45 +02:00
Paul Chavard
95d61c85e1 Dispatch events from geo areas list view 2020-06-09 18:45:45 +02:00
Paul Chavard
901b6e23a8 Remove legacy carto 2020-06-04 16:03:23 +02:00
kara Diaby
f104567619 Add 2 cards style for MapEditor + optim import gpx kml 2020-06-02 13:24:29 +02:00
kara Diaby
1e3a042a69 Add styles without cadastres in mapReader + tutorials pages in MapEditor 2020-05-28 17:50:14 +02:00
kara Diaby
d8ae089e93 [Carto] Improve files import UX + import KML files 2020-05-20 14:17:27 +02:00
kara Diaby
c37b32ac94 fix the search input addresses return box bug [Carto] 2020-05-19 15:34:48 +02:00
Pierre de La Morinerie
833d7a3b59 javascript: ignore most common upload errors also in standard uploads
In #5149, we ignored most common upload errors, but only for
auto-uploads.

This PR ignores those errors also for standard uploads.
2020-05-18 11:50:29 +02:00
Paul Chavard
d44df9cc2a Fix map apercu 2020-05-14 14:28:54 +02:00
Pierre de La Morinerie
bbc0aa5465 javascript: remove debug code for FileReader errors 2020-05-14 13:29:54 +02:00
Pierre de La Morinerie
86357b65f0 javascript: ignore most common upload errors 2020-05-14 13:29:54 +02:00
Pierre de La Morinerie
4b288038d3 javascript: human-readable message for reading errors during upload 2020-05-14 13:29:54 +02:00
Paul Chavard
03075afa5b Update javascript dependencies 2020-05-14 13:21:42 +02:00
Pierre de La Morinerie
b5f1d97629 app: disable Turbolinks
Fix #5039
2020-05-13 11:04:16 +02:00
Paul Chavard
43a1ead1cb fix new prettier defaults 2020-05-12 18:18:37 +02:00
kara Diaby
474521c841 Adapt style for Map reader (point, line) 2020-05-12 17:47:28 +02:00
kara Diaby
1cc04092f4 import GPX file in browser [Carto] 2020-05-11 11:36:36 +02:00
Paul Chavard
05e408225b Implement atomic operations on MapEditor 2020-05-06 16:46:14 +02:00
kara Diaby
9aea1fffee Migrate the map editor to mapbox-gl with react component 2020-04-27 11:30:32 +02:00
Pierre de La Morinerie
6f4075f38e javascript: fix FileUploadError stacktraces
When subclassing a JS error, most browsers include the constructor
stacktrace :/

This is an issue, because:
- The stacktrace is deeper than it should be
- The stacktrace reaches into a polyfill for which there is not source
map, which causes Sentry to infer the issue grouping from the JS file
name. And the fingerprinted name changes on each release. So for each
release, the stacktrace is different ; and Sentry can't group issues
properly.
2020-04-23 12:27:26 +02:00
Pierre de La Morinerie
ef009f73e2 javascript: report upload FileReader errors to Sentry
We have quite a lot of `Error reading file` errors when uploading files.
These errors are generated by ActiveStorage `file_checksum.js` component
but it eats the actual reason of errors.

(See https://github.com/rails/rails/blob/5-2-stable/activestorage/app/javascript/activestorage/file_checksum.js#L38)

We can't really override the class to generate better errors, as they
are deeply nested in ActiveStorage class hierarchy, and not exported to
external code.

Instead, we hook into the FileReader event handler, to insert a logger
when this error occur. The original event handler will also still be
called as usual.

This is intended to be temporary. The debug code will be removed once
we get a better idea of what is going on.
2020-04-22 11:26:16 +02:00
Paul Chavard
bc8217e030 Carte Editor sends FeatureCollection to the server 2020-04-16 18:29:19 +02:00
Pierre de La Morinerie
769e98f63e javascript: fix the progress bar removal on success
When using auto-attach, the response HTML fragment replaces the progress
bar – so it doesn't need to be removed twice.
2020-04-16 17:02:23 +02:00
Pierre de La Morinerie
647ad3ba10 javascript: consider unknown upload errors as client errors 2020-04-16 12:59:14 +02:00
Pierre de La Morinerie
b006c33ebe javascript: parse the upload status code correctly
Previously the status was "Status: 422" instead of just 422.
2020-04-16 12:54:18 +02:00
Pierre de La Morinerie
b2231e98d5 javascript: don't report connectivity issues to Sentry 2020-04-16 11:20:45 +02:00
Pierre de La Morinerie
55788990da javascript: add a helpful message on connectivity error 2020-04-16 11:20:45 +02:00
Pierre de La Morinerie
432967bd76 javascript: make Uploader always throw the same kind of errors
A DirectUpload may fail for several reasons, and return many types of
errors (string, xhr response, Error objects, etc).

For convenience, wrap all these errors in a FileUploadError object.

- It makes easier for clients of the Uploader class to handle errors;
- It allows to propagate the error code and failure responsability.
2020-04-16 11:20:45 +02:00
Pierre de La Morinerie
d8f3b86b0e javascript: move auto-upload attachment to the Uploader class
Rationale:

- It makes more sense to handle the progress bar updates in a single class;
- This will allow us to unify the error handling.
2020-04-16 11:20:45 +02:00
Paul Chavard
442a6a3cdd Remove deprecated map reader 2020-04-15 18:07:09 +02:00