dispatch({ type: 'onSortTypeDeChamps', params })}
+ onSortEnd={(params) =>
+ dispatch({ type: 'onSortTypeDeChamps', params })
+ }
useDragHandle
>
{state.typeDeChamps.map((typeDeChamp, index) => (
diff --git a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamps.js b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamps.js
index 0f96464db..fa909b5b5 100644
--- a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamps.js
+++ b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamps.js
@@ -12,12 +12,14 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
typeDeChamps
});
- const hasUnsavedChamps = state.typeDeChamps.some(tdc => tdc.id == undefined);
+ const hasUnsavedChamps = state.typeDeChamps.some(
+ (tdc) => tdc.id == undefined
+ );
return (
dispatch({ type: 'onSortTypeDeChamps', params })}
+ onSortEnd={(params) => dispatch({ type: 'onSortTypeDeChamps', params })}
lockAxis="y"
useDragHandle
>
diff --git a/app/javascript/components/TypesDeChampEditor/operations.js b/app/javascript/components/TypesDeChampEditor/operations.js
index aed8926a8..c88215807 100644
--- a/app/javascript/components/TypesDeChampEditor/operations.js
+++ b/app/javascript/components/TypesDeChampEditor/operations.js
@@ -5,7 +5,7 @@ export function createTypeDeChampOperation(typeDeChamp, queue) {
method: 'post',
payload: { type_de_champ: typeDeChamp }
})
- .then(data => {
+ .then((data) => {
handleResponseData(typeDeChamp, data);
});
}
@@ -33,7 +33,7 @@ export function updateTypeDeChampOperation(typeDeChamp, queue) {
method: 'patch',
payload: { type_de_champ: typeDeChamp }
})
- .then(data => {
+ .then((data) => {
handleResponseData(typeDeChamp, data);
});
}
diff --git a/app/javascript/components/TypesDeChampEditor/typeDeChampsReducer.js b/app/javascript/components/TypesDeChampEditor/typeDeChampsReducer.js
index d18c849b3..f594ecf67 100644
--- a/app/javascript/components/TypesDeChampEditor/typeDeChampsReducer.js
+++ b/app/javascript/components/TypesDeChampEditor/typeDeChampsReducer.js
@@ -59,7 +59,7 @@ function addTypeDeChamp(state, typeDeChamps, insertAfter, done) {
});
}
})
- .catch(message => state.flash.error(message));
+ .catch((message) => state.flash.error(message));
let newTypeDeChamps = [...typeDeChamps, typeDeChamp];
if (insertAfter) {
@@ -127,7 +127,7 @@ function updateTypeDeChamp(
function removeTypeDeChamp(state, typeDeChamps, { typeDeChamp }) {
destroyTypeDeChampOperation(typeDeChamp, state.queue)
.then(() => state.flash.success())
- .catch(message => state.flash.error(message));
+ .catch((message) => state.flash.error(message));
return {
...state,
@@ -141,7 +141,7 @@ function moveTypeDeChampUp(state, typeDeChamps, { typeDeChamp }) {
moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue)
.then(() => state.flash.success())
- .catch(message => state.flash.error(message));
+ .catch((message) => state.flash.error(message));
return {
...state,
@@ -155,7 +155,7 @@ function moveTypeDeChampDown(state, typeDeChamps, { typeDeChamp }) {
moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue)
.then(() => state.flash.success())
- .catch(message => state.flash.error(message));
+ .catch((message) => state.flash.error(message));
return {
...state,
@@ -166,7 +166,7 @@ function moveTypeDeChampDown(state, typeDeChamps, { typeDeChamp }) {
function onSortTypeDeChamps(state, typeDeChamps, { oldIndex, newIndex }) {
moveTypeDeChampOperation(typeDeChamps[oldIndex], newIndex, state.queue)
.then(() => state.flash.success())
- .catch(message => state.flash.error(message));
+ .catch((message) => state.flash.error(message));
return {
...state,
@@ -191,13 +191,13 @@ function getUpdateHandler(typeDeChamp, { queue, flash }) {
let handler = updateHandlers.get(typeDeChamp);
if (!handler) {
handler = debounce(
- done =>
+ (done) =>
updateTypeDeChampOperation(typeDeChamp, queue)
.then(() => {
flash.success();
done();
})
- .catch(message => flash.error(message)),
+ .catch((message) => flash.error(message)),
200
);
updateHandlers.set(typeDeChamp, handler);
diff --git a/app/javascript/new_design/champs/linked-drop-down-list.js b/app/javascript/new_design/champs/linked-drop-down-list.js
index c1e14d50d..e26b4f42a 100644
--- a/app/javascript/new_design/champs/linked-drop-down-list.js
+++ b/app/javascript/new_design/champs/linked-drop-down-list.js
@@ -4,7 +4,7 @@ const PRIMARY_SELECTOR = 'select[data-secondary-options]';
const SECONDARY_SELECTOR = 'select[data-secondary]';
const CHAMP_SELECTOR = '.editable-champ';
-delegate('change', PRIMARY_SELECTOR, evt => {
+delegate('change', PRIMARY_SELECTOR, (evt) => {
const primary = evt.target;
const secondary = primary
.closest(CHAMP_SELECTOR)
diff --git a/app/javascript/new_design/champs/repetition.js b/app/javascript/new_design/champs/repetition.js
index b6a380f1d..061cd519e 100644
--- a/app/javascript/new_design/champs/repetition.js
+++ b/app/javascript/new_design/champs/repetition.js
@@ -4,7 +4,7 @@ const BUTTON_SELECTOR = '.button.remove-row';
const DESTROY_INPUT_SELECTOR = 'input[type=hidden][name*=_destroy]';
const CHAMP_SELECTOR = '.editable-champ';
-delegate('click', BUTTON_SELECTOR, evt => {
+delegate('click', BUTTON_SELECTOR, (evt) => {
evt.preventDefault();
const row = evt.target.closest('.row');
diff --git a/app/javascript/new_design/dossiers/auto-save-controller.js b/app/javascript/new_design/dossiers/auto-save-controller.js
index 83bc1a2e1..e828332bd 100644
--- a/app/javascript/new_design/dossiers/auto-save-controller.js
+++ b/app/javascript/new_design/dossiers/auto-save-controller.js
@@ -41,7 +41,7 @@ export default class AutoSaveController {
headers: { Accept: 'application/json' }
};
- return window.fetch(form.action, fetchOptions).then(response => {
+ return window.fetch(form.action, fetchOptions).then((response) => {
if (response.ok) {
resolve(response);
} else {
@@ -64,7 +64,7 @@ export default class AutoSaveController {
const fileInputs = form.querySelectorAll(
'input[type="file"]:not([disabled]), .editable-champ-piece_justificative input:not([disabled])'
);
- fileInputs.forEach(fileInput => (fileInput.disabled = true));
+ fileInputs.forEach((fileInput) => (fileInput.disabled = true));
// Generate the form data
let formData = null;
@@ -75,7 +75,7 @@ export default class AutoSaveController {
return [null, error];
} finally {
// Re-enable disabled file inputs
- fileInputs.forEach(fileInput => (fileInput.disabled = false));
+ fileInputs.forEach((fileInput) => (fileInput.disabled = false));
}
}
diff --git a/app/javascript/new_design/dossiers/auto-save.js b/app/javascript/new_design/dossiers/auto-save.js
index 0bdfe9870..c96a97e6c 100644
--- a/app/javascript/new_design/dossiers/auto-save.js
+++ b/app/javascript/new_design/dossiers/auto-save.js
@@ -47,7 +47,7 @@ addEventListener('autosave:end', () => {
hideSucceededStatusAfterDelay();
});
-addEventListener('autosave:error', event => {
+addEventListener('autosave:error', (event) => {
enable(document.querySelector('button.autosave-retry'));
setState('failed');
logError(event.detail);
diff --git a/app/javascript/new_design/dossiers/auto-upload.js b/app/javascript/new_design/dossiers/auto-upload.js
index 784fdd314..b12d5f62e 100644
--- a/app/javascript/new_design/dossiers/auto-upload.js
+++ b/app/javascript/new_design/dossiers/auto-upload.js
@@ -5,18 +5,18 @@ import { delegate } from '@utils';
const autoUploadsControllers = new AutoUploadsControllers();
function startUpload(input) {
- Array.from(input.files).forEach(file => {
+ Array.from(input.files).forEach((file) => {
autoUploadsControllers.upload(input, file);
});
}
const fileInputSelector = `input[type=file][data-direct-upload-url][data-auto-attach-url]:not([disabled])`;
-delegate('change', fileInputSelector, event => {
+delegate('change', fileInputSelector, (event) => {
startUpload(event.target);
});
const retryButtonSelector = `button.attachment-error-retry`;
-delegate('click', retryButtonSelector, function() {
+delegate('click', retryButtonSelector, function () {
const inputSelector = this.dataset.inputTarget;
const input = document.querySelector(inputSelector);
startUpload(input);
diff --git a/app/javascript/new_design/dossiers/auto-uploads-controllers.js b/app/javascript/new_design/dossiers/auto-uploads-controllers.js
index 90348566b..18b0bc882 100644
--- a/app/javascript/new_design/dossiers/auto-uploads-controllers.js
+++ b/app/javascript/new_design/dossiers/auto-uploads-controllers.js
@@ -40,18 +40,18 @@ export default class AutoUploadsControllers {
if (form) {
form
.querySelectorAll('button[type=submit]')
- .forEach(submitButton => Rails.disableElement(submitButton));
+ .forEach((submitButton) => Rails.disableElement(submitButton));
}
//
// DEBUG: hook into FileReader onload event
//
if (FileReader.prototype.addEventListener === originalImpl) {
- FileReader.prototype.addEventListener = function() {
+ FileReader.prototype.addEventListener = function () {
// When DirectUploads attempts to add an event listener for "error",
// also insert a custom event listener of our that will report errors to Sentry.
if (arguments[0] == 'error') {
- let handler = event => {
+ let handler = (event) => {
let message = `FileReader ${event.target.error.name}: ${event.target.error.message}`;
fire(document, 'sentry:capture-exception', new Error(message));
};
@@ -71,7 +71,7 @@ export default class AutoUploadsControllers {
if (this.inFlightUploadsCount == 0 && form) {
form
.querySelectorAll('button[type=submit]')
- .forEach(submitButton => Rails.enableElement(submitButton));
+ .forEach((submitButton) => Rails.enableElement(submitButton));
}
//
diff --git a/app/javascript/new_design/dropdown.js b/app/javascript/new_design/dropdown.js
index 13d8965c2..1614c08d3 100644
--- a/app/javascript/new_design/dropdown.js
+++ b/app/javascript/new_design/dropdown.js
@@ -1,14 +1,14 @@
import { delegate } from '@utils';
-delegate('click', 'body', event => {
+delegate('click', 'body', (event) => {
if (!event.target.closest('.dropdown')) {
- [...document.querySelectorAll('.dropdown')].forEach(element =>
+ [...document.querySelectorAll('.dropdown')].forEach((element) =>
element.classList.remove('open', 'fade-in-down')
);
}
});
-delegate('click', '.dropdown-button', event => {
+delegate('click', '.dropdown-button', (event) => {
event.stopPropagation();
const parent = event.target.closest('.dropdown-button').parentElement;
if (parent.classList.contains('dropdown')) {
diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js
index 1b3cf05a5..e92aad0ce 100644
--- a/app/javascript/new_design/select2.js
+++ b/app/javascript/new_design/select2.js
@@ -5,15 +5,15 @@ import { isNumeric } from '@utils';
const { api_geo_url, api_adresse_url } = gon.autocomplete || {};
const language = {
- errorLoading: function() {
+ errorLoading: function () {
return 'Les résultats ne peuvent pas être chargés.';
},
- inputTooLong: function(args) {
+ inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
return 'Supprimez ' + overChars + ' caractère' + (overChars > 1 ? 's' : '');
},
- inputTooShort: function(args) {
+ inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length;
return (
@@ -23,10 +23,10 @@ const language = {
(remainingChars > 1 ? 's' : '')
);
},
- loadingMore: function() {
+ loadingMore: function () {
return 'Chargement de résultats supplémentaires…';
},
- maximumSelected: function(args) {
+ maximumSelected: function (args) {
return (
'Vous pouvez seulement sélectionner ' +
args.maximum +
@@ -34,13 +34,13 @@ const language = {
(args.maximum > 1 ? 's' : '')
);
},
- noResults: function() {
+ noResults: function () {
return 'Aucun résultat trouvé';
},
- searching: function() {
+ searching: function () {
return 'Recherche en cours…';
},
- removeAllItems: function() {
+ removeAllItems: function () {
return 'Supprimer tous les éléments';
}
};
diff --git a/app/javascript/shared/activestorage/ujs.js b/app/javascript/shared/activestorage/ujs.js
index bdc3b5031..a3459bbb9 100644
--- a/app/javascript/shared/activestorage/ujs.js
+++ b/app/javascript/shared/activestorage/ujs.js
@@ -12,7 +12,7 @@ const ERROR_EVENT = 'direct-upload:error';
const END_EVENT = 'direct-upload:end';
function addUploadEventListener(type, handler) {
- addEventListener(type, event => {
+ addEventListener(type, (event) => {
// Internet Explorer and Edge will sometime replay Javascript events
// that were dispatched just before a page navigation (!), but without
// the event payload.
@@ -43,7 +43,7 @@ addUploadEventListener(PROGRESS_EVENT, ({ detail: { id, progress } }) => {
ProgressBar.progress(id, progress);
});
-addUploadEventListener(ERROR_EVENT, event => {
+addUploadEventListener(ERROR_EVENT, (event) => {
let id = event.detail.id;
let errorMsg = event.detail.error;
diff --git a/app/javascript/shared/activestorage/uploader.js b/app/javascript/shared/activestorage/uploader.js
index 2c1c081de..d1454acd6 100644
--- a/app/javascript/shared/activestorage/uploader.js
+++ b/app/javascript/shared/activestorage/uploader.js
@@ -92,7 +92,7 @@ export default class Uploader {
}
directUploadWillStoreFileWithXHR(xhr) {
- xhr.upload.addEventListener('progress', event =>
+ xhr.upload.addEventListener('progress', (event) =>
this.uploadRequestDidProgress(event)
);
}
diff --git a/app/javascript/shared/carte-editor.js b/app/javascript/shared/carte-editor.js
index 9849a6312..8717c2e5f 100644
--- a/app/javascript/shared/carte-editor.js
+++ b/app/javascript/shared/carte-editor.js
@@ -63,8 +63,8 @@ function initMap(element, { position }) {
}
function toLatLngs({ coordinates }) {
- return coordinates.map(polygon =>
- polygon[0].map(point => L.GeoJSON.coordsToLatLng(point))
+ return coordinates.map((polygon) =>
+ polygon[0].map((point) => L.GeoJSON.coordsToLatLng(point))
);
}
@@ -137,7 +137,7 @@ function findInput(selector) {
}
function clearLayers(map) {
- map.eachLayer(layer => {
+ map.eachLayer((layer) => {
if (layer instanceof L.GeoJSON) {
map.removeLayer(layer);
}
@@ -185,7 +185,7 @@ const RPG_POLYGON_STYLE = Object.assign({}, POLYGON_STYLE, {
fillColor: '#31708f'
});
-delegate('click', '.carte.edit', event => {
+delegate('click', '.carte.edit', (event) => {
const map = getCurrentMap(event.target);
if (map) {
@@ -200,7 +200,7 @@ delegate('click', '.carte.edit', event => {
}
});
-delegate('click', '.toolbar .new-area', event => {
+delegate('click', '.toolbar .new-area', (event) => {
event.preventDefault();
const map = getCurrentMap(event.target);
@@ -209,7 +209,7 @@ delegate('click', '.toolbar .new-area', event => {
}
});
-$(document).on('select2:select', 'select[data-address]', event => {
+$(document).on('select2:select', 'select[data-address]', (event) => {
const map = getCurrentMap(event.target);
const { geometry } = event.params.data;
diff --git a/app/javascript/shared/franceconnect.js b/app/javascript/shared/franceconnect.js
index c6d7653a7..748121209 100644
--- a/app/javascript/shared/franceconnect.js
+++ b/app/javascript/shared/franceconnect.js
@@ -34,7 +34,7 @@ function toggleElement(event) {
function closeFCPopin(event) {
event.preventDefault();
fconnect.popin.className = 'fade-out';
- setTimeout(function() {
+ setTimeout(function () {
document.body.removeChild(fconnect.popin);
}, 200);
}
@@ -49,7 +49,7 @@ function openFCPopin() {
fconnect.popin.appendChild(iframe);
- setTimeout(function() {
+ setTimeout(function () {
fconnect.popin.className = 'fade-in';
}, 200);
}
@@ -112,7 +112,7 @@ var messageEvent = eventMethod == 'attachEvent' ? 'onmessage' : 'message';
// Listen to message from child window
eventer(
messageEvent,
- function(e) {
+ function (e) {
var key = e.message ? 'message' : 'data';
var data = e[key];
if (data === 'close_popup') {
diff --git a/app/javascript/shared/page-update-event.js b/app/javascript/shared/page-update-event.js
index c5038f81d..3f2cac2fb 100644
--- a/app/javascript/shared/page-update-event.js
+++ b/app/javascript/shared/page-update-event.js
@@ -1,9 +1,9 @@
import { fire } from '@utils';
-addEventListener('turbolinks:load', function() {
+addEventListener('turbolinks:load', function () {
fire(document, 'ds:page:update');
});
-addEventListener('ajax:success', function() {
+addEventListener('ajax:success', function () {
fire(document, 'ds:page:update');
});
diff --git a/app/javascript/shared/polyfills/dataset.js b/app/javascript/shared/polyfills/dataset.js
index 00d648ea1..653787247 100644
--- a/app/javascript/shared/polyfills/dataset.js
+++ b/app/javascript/shared/polyfills/dataset.js
@@ -18,7 +18,7 @@ function clearDataset(event) {
}
function toCamelCase(string) {
- return string.replace(dash, function(_, letter) {
+ return string.replace(dash, function (_, letter) {
return letter.toUpperCase();
});
}
diff --git a/app/javascript/shared/rails-ujs-fix.js b/app/javascript/shared/rails-ujs-fix.js
index 44c7f6c4c..4c12c029b 100644
--- a/app/javascript/shared/rails-ujs-fix.js
+++ b/app/javascript/shared/rails-ujs-fix.js
@@ -6,10 +6,10 @@ import jQuery from 'jquery';
// https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9
addEventListener('load', () => {
const { href, handleRemote } = Rails;
- Rails.href = function(element) {
+ Rails.href = function (element) {
return element.href || href(element);
};
- Rails.handleRemote = function(e) {
+ Rails.handleRemote = function (e) {
if (this instanceof HTMLElement) {
handleRemote.call(this, e);
} else {
diff --git a/app/javascript/shared/remote-poller.js b/app/javascript/shared/remote-poller.js
index ffb1cb9e7..84cf3a8ca 100644
--- a/app/javascript/shared/remote-poller.js
+++ b/app/javascript/shared/remote-poller.js
@@ -24,7 +24,7 @@ addEventListener('export:update', ({ detail: { url } }) => {
exportPoller.add(url);
});
-delegate('click', '[data-attachment-refresh]', event => {
+delegate('click', '[data-attachment-refresh]', (event) => {
event.preventDefault();
attachementPoller.check();
});
diff --git a/app/javascript/shared/safari-11-file-xhr-workaround.js b/app/javascript/shared/safari-11-file-xhr-workaround.js
index 1cedc369e..2d7fa2707 100644
--- a/app/javascript/shared/safari-11-file-xhr-workaround.js
+++ b/app/javascript/shared/safari-11-file-xhr-workaround.js
@@ -3,9 +3,9 @@
// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty
// https://github.com/rails/rails/issues/32440
-document.addEventListener('ajax:before', function(e) {
+document.addEventListener('ajax:before', function (e) {
let inputs = e.target.querySelectorAll('input[type="file"]:not([disabled])');
- inputs.forEach(function(input) {
+ inputs.forEach(function (input) {
if (input.files.length > 0) {
return;
}
@@ -15,11 +15,11 @@ document.addEventListener('ajax:before', function(e) {
});
// You should call this by yourself when you aborted an ajax request by stopping a event in ajax:before hook.
-document.addEventListener('ajax:beforeSend', function(e) {
+document.addEventListener('ajax:beforeSend', function (e) {
let inputs = e.target.querySelectorAll(
'input[type="file"][data-safari-temp-disabled]'
);
- inputs.forEach(function(input) {
+ inputs.forEach(function (input) {
input.removeAttribute('data-safari-temp-disabled');
input.removeAttribute('disabled');
});
diff --git a/app/javascript/shared/toggle-target.js b/app/javascript/shared/toggle-target.js
index 0b4faf0f5..945c379e1 100644
--- a/app/javascript/shared/toggle-target.js
+++ b/app/javascript/shared/toggle-target.js
@@ -9,7 +9,7 @@ import { delegate, toggle } from '@utils';
const TOGGLE_SOURCE_SELECTOR = '[data-toggle-target]';
-delegate('click', TOGGLE_SOURCE_SELECTOR, evt => {
+delegate('click', TOGGLE_SOURCE_SELECTOR, (evt) => {
evt.preventDefault();
const targetSelector = evt.target.dataset.toggleTarget;
diff --git a/app/javascript/shared/track/matomo.js b/app/javascript/shared/track/matomo.js
index 533c5a817..12db6b112 100644
--- a/app/javascript/shared/track/matomo.js
+++ b/app/javascript/shared/track/matomo.js
@@ -29,7 +29,7 @@ if (enabled) {
// Send Matomo a new event when navigating to a new page using Turbolinks
// (see https://developer.matomo.org/guides/spa-tracking)
let previousPageUrl = null;
- addEventListener('turbolinks:load', event => {
+ addEventListener('turbolinks:load', (event) => {
if (previousPageUrl) {
window._paq.push(['setReferrerUrl', previousPageUrl]);
window._paq.push(['setCustomUrl', window.location.href]);
diff --git a/app/javascript/shared/track/sentry.js b/app/javascript/shared/track/sentry.js
index 2db2fd708..faa02741a 100644
--- a/app/javascript/shared/track/sentry.js
+++ b/app/javascript/shared/track/sentry.js
@@ -6,13 +6,13 @@ const { key, enabled, user, environment, browser } = gon.sentry || {};
if (enabled && key) {
Sentry.init({ dsn: key, environment });
- Sentry.configureScope(scope => {
+ Sentry.configureScope((scope) => {
scope.setUser(user);
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
});
// Register a way to explicitely capture messages from a different bundle.
- addEventListener('sentry:capture-exception', event => {
+ addEventListener('sentry:capture-exception', (event) => {
const error = event.detail;
Sentry.captureException(error);
});
diff --git a/app/javascript/shared/utils.js b/app/javascript/shared/utils.js
index ac1d3246f..595e277b8 100644
--- a/app/javascript/shared/utils.js
+++ b/app/javascript/shared/utils.js
@@ -46,7 +46,7 @@ export function removeClass(el, cssClass) {
export function delegate(eventNames, selector, callback) {
eventNames
.split(' ')
- .forEach(eventName =>
+ .forEach((eventName) =>
Rails.delegate(document, selector, eventName, callback)
);
}
@@ -90,13 +90,13 @@ export function scrollToBottom(container) {
}
export function on(selector, eventName, fn) {
- [...document.querySelectorAll(selector)].forEach(element =>
- element.addEventListener(eventName, event => fn(event, event.detail))
+ [...document.querySelectorAll(selector)].forEach((element) =>
+ element.addEventListener(eventName, (event) => fn(event, event.detail))
);
}
export function to(promise) {
- return promise.then(result => [result]).catch(error => [null, error]);
+ return promise.then((result) => [result]).catch((error) => [null, error]);
}
export function isNumeric(n) {