2018-09-11 17:53:11 +02:00
|
|
|
import '../shared/polyfills';
|
2019-07-02 14:38:42 +02:00
|
|
|
import Rails from '@rails/ujs';
|
|
|
|
import * as ActiveStorage from '@rails/activestorage';
|
2022-03-31 12:07:52 +02:00
|
|
|
import 'whatwg-fetch'; // window.fetch polyfill
|
2022-04-20 11:14:48 +02:00
|
|
|
import { Application } from '@hotwired/stimulus';
|
2022-04-29 18:13:59 +02:00
|
|
|
import * as Turbo from '@hotwired/turbo';
|
2018-07-12 11:50:47 +02:00
|
|
|
|
2019-02-13 14:16:22 +01:00
|
|
|
import '../shared/activestorage/ujs';
|
2020-01-29 12:16:38 +01:00
|
|
|
import '../shared/remote-poller';
|
2018-08-31 12:56:56 +02:00
|
|
|
import '../shared/safari-11-file-xhr-workaround';
|
2018-10-02 16:54:08 +02:00
|
|
|
import '../shared/franceconnect';
|
2019-02-19 14:29:06 +01:00
|
|
|
import '../shared/toggle-target';
|
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 23:18:17 +02:00
|
|
|
import '../shared/ujs-error-handling';
|
2018-07-12 11:50:47 +02:00
|
|
|
|
2022-04-20 11:14:48 +02:00
|
|
|
import {
|
|
|
|
ReactController,
|
|
|
|
registerComponents
|
|
|
|
} from '../controllers/react_controller';
|
2022-04-14 20:46:28 +02:00
|
|
|
import { TurboEventController } from '../controllers/turbo_event_controller';
|
2022-04-22 09:40:52 +02:00
|
|
|
import { GeoAreaController } from '../controllers/geo_area_controller';
|
2022-05-03 19:43:49 +02:00
|
|
|
import { TurboInputController } from '../controllers/turbo_input_controller';
|
2022-04-20 11:14:48 +02:00
|
|
|
|
2018-09-11 17:51:44 +02:00
|
|
|
import '../new_design/dropdown';
|
2018-07-12 11:50:47 +02:00
|
|
|
import '../new_design/form-validation';
|
2019-04-01 15:04:11 +02:00
|
|
|
import '../new_design/procedure-context';
|
2019-10-21 18:12:57 +02:00
|
|
|
import '../new_design/procedure-form';
|
2019-02-21 17:50:18 +01:00
|
|
|
import '../new_design/spinner';
|
|
|
|
import '../new_design/support';
|
2021-05-20 11:20:28 +02:00
|
|
|
import '../new_design/messagerie';
|
2020-03-19 17:48:21 +01:00
|
|
|
import '../new_design/dossiers/auto-save';
|
2020-03-30 15:34:56 +02:00
|
|
|
import '../new_design/dossiers/auto-upload';
|
2018-07-12 11:50:47 +02:00
|
|
|
|
|
|
|
import '../new_design/champs/linked-drop-down-list';
|
2019-01-30 16:14:15 +01:00
|
|
|
import '../new_design/champs/repetition';
|
2021-10-26 20:42:17 +02:00
|
|
|
import '../new_design/champs/drop-down-list';
|
2018-07-12 11:50:47 +02:00
|
|
|
|
2020-10-06 17:10:34 +02:00
|
|
|
import {
|
|
|
|
toggleCondidentielExplanation,
|
|
|
|
replaceSemicolonByComma
|
|
|
|
} from '../new_design/avis';
|
2019-02-18 17:52:15 +01:00
|
|
|
import {
|
|
|
|
showMotivation,
|
|
|
|
motivationCancel,
|
|
|
|
showImportJustificatif
|
|
|
|
} from '../new_design/state-button';
|
2019-12-02 14:20:26 +01:00
|
|
|
import {
|
|
|
|
acceptEmailSuggestion,
|
|
|
|
discardEmailSuggestionBox
|
|
|
|
} from '../new_design/user-sign_up';
|
2021-10-13 09:23:40 +02:00
|
|
|
import {
|
2021-10-13 09:26:54 +02:00
|
|
|
showFusion,
|
2021-10-13 01:08:57 +02:00
|
|
|
showNewAccount,
|
|
|
|
showNewAccountPasswordConfirmation
|
2021-10-13 09:23:40 +02:00
|
|
|
} from '../new_design/fc-fusion';
|
2018-07-12 11:50:47 +02:00
|
|
|
|
2022-04-20 11:14:48 +02:00
|
|
|
registerComponents({
|
|
|
|
Chartkick: () => import('../components/Chartkick'),
|
|
|
|
ComboAdresseSearch: () => import('../components/ComboAdresseSearch'),
|
|
|
|
ComboAnnuaireEducationSearch: () =>
|
|
|
|
import('../components/ComboAnnuaireEducationSearch'),
|
|
|
|
ComboCommunesSearch: () => import('../components/ComboCommunesSearch'),
|
|
|
|
ComboDepartementsSearch: () =>
|
|
|
|
import('../components/ComboDepartementsSearch'),
|
|
|
|
ComboMultipleDropdownList: () =>
|
|
|
|
import('../components/ComboMultipleDropdownList'),
|
|
|
|
ComboMultiple: () => import('../components/ComboMultiple'),
|
|
|
|
ComboPaysSearch: () => import('../components/ComboPaysSearch'),
|
|
|
|
ComboRegionsSearch: () => import('../components/ComboRegionsSearch'),
|
|
|
|
MapEditor: () => import('../components/MapEditor'),
|
|
|
|
MapReader: () => import('../components/MapReader'),
|
|
|
|
Trix: () => import('../components/Trix'),
|
|
|
|
TypesDeChampEditor: () => import('../components/TypesDeChampEditor')
|
2021-12-21 16:30:29 +01:00
|
|
|
});
|
|
|
|
|
2018-07-12 11:50:47 +02:00
|
|
|
// This is the global application namespace where we expose helpers used from rails views
|
|
|
|
const DS = {
|
2018-11-14 16:28:02 +01:00
|
|
|
fire: (eventName, data) => Rails.fire(document, eventName, data),
|
2018-07-12 11:50:47 +02:00
|
|
|
toggleCondidentielExplanation,
|
|
|
|
showMotivation,
|
|
|
|
motivationCancel,
|
2019-02-18 17:52:15 +01:00
|
|
|
showImportJustificatif,
|
2021-10-13 09:23:40 +02:00
|
|
|
showFusion,
|
2021-10-13 09:26:54 +02:00
|
|
|
showNewAccount,
|
2021-10-13 01:08:57 +02:00
|
|
|
showNewAccountPasswordConfirmation,
|
2019-12-02 13:07:40 +01:00
|
|
|
replaceSemicolonByComma,
|
|
|
|
acceptEmailSuggestion,
|
|
|
|
discardEmailSuggestionBox
|
2018-07-12 11:50:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Start Rails helpers
|
2022-03-31 12:07:52 +02:00
|
|
|
Rails.start();
|
2018-07-12 11:50:47 +02:00
|
|
|
ActiveStorage.start();
|
2022-04-20 14:17:40 +02:00
|
|
|
Turbo.session.drive = false;
|
2018-07-12 11:50:47 +02:00
|
|
|
|
2022-04-20 11:14:48 +02:00
|
|
|
const Stimulus = Application.start();
|
|
|
|
Stimulus.register('react', ReactController);
|
2022-04-14 20:46:28 +02:00
|
|
|
Stimulus.register('turbo-event', TurboEventController);
|
2022-04-22 09:40:52 +02:00
|
|
|
Stimulus.register('geo-area', GeoAreaController);
|
2022-05-03 19:43:49 +02:00
|
|
|
Stimulus.register('turbo-input', TurboInputController);
|
2022-04-20 11:14:48 +02:00
|
|
|
|
2019-12-03 16:13:20 +01:00
|
|
|
// Expose globals
|
|
|
|
window.DS = window.DS || DS;
|