fix new prettier defaults

This commit is contained in:
Paul Chavard 2020-04-30 15:42:29 +02:00
parent 02b15e10cf
commit 43a1ead1cb
40 changed files with 111 additions and 122 deletions

View file

@ -1,3 +1,4 @@
module.exports = { module.exports = {
singleQuote: true singleQuote: true,
trailingComma: 'none'
}; };

View file

@ -1,20 +1,11 @@
/* globals $ */ /* globals $ */
$(document).on('click', '.delete', function() { $(document).on('click', '.delete', function () {
$(this).hide(); $(this).hide();
$(this) $(this).closest('td').find('.confirm').show();
.closest('td')
.find('.confirm')
.show();
}); });
$(document).on('click', '.cancel', function() { $(document).on('click', '.cancel', function () {
$(this) $(this).closest('td').find('.delete').show();
.closest('td') $(this).closest('td').find('.confirm').hide();
.find('.delete')
.show();
$(this)
.closest('td')
.find('.confirm')
.hide();
}); });

View file

@ -1,11 +1,11 @@
/* globals $ */ /* globals $ */
$(document).on('click', 'button#archive-procedure', function() { $(document).on('click', 'button#archive-procedure', function () {
$('button#archive-procedure').hide(); $('button#archive-procedure').hide();
$('#confirm').show(); $('#confirm').show();
}); });
$(document).on('click', '#confirm #cancel', function() { $(document).on('click', '#confirm #cancel', function () {
$('button#archive-procedure').show(); $('button#archive-procedure').show();
$('#confirm').hide(); $('#confirm').hide();
}); });

View file

@ -3,7 +3,7 @@
$(document).on('turbolinks:load', wysihtml5_active); $(document).on('turbolinks:load', wysihtml5_active);
function wysihtml5_active() { function wysihtml5_active() {
$('.wysihtml5').each(function(i, elem) { $('.wysihtml5').each(function (i, elem) {
$(elem).wysihtml5({ $(elem).wysihtml5({
toolbar: { toolbar: {
fa: true, fa: true,

View file

@ -7,11 +7,11 @@ function init_default_data_block() {
$('.default-data-block #dossier .carret-right').toggle(); $('.default-data-block #dossier .carret-right').toggle();
$('.default-data-block #dossier .carret-down').toggle(); $('.default-data-block #dossier .carret-down').toggle();
$('.default-data-block .title').click(function() { $('.default-data-block .title').click(function () {
toggle_default_data_bloc(this, 400); toggle_default_data_bloc(this, 400);
}); });
$('.new-action').click(function() { $('.new-action').click(function () {
var messages_block = $(this) var messages_block = $(this)
.parents() .parents()
.closest('.default-data-block') .closest('.default-data-block')
@ -19,7 +19,7 @@ function init_default_data_block() {
toggle_default_data_bloc(messages_block, 400); toggle_default_data_bloc(messages_block, 400);
}); });
$('.default-data-block.default_visible').each(function() { $('.default-data-block.default_visible').each(function () {
toggle_default_data_bloc($(this).find('.title'), 0); toggle_default_data_bloc($(this).find('.title'), 0);
}); });

View file

@ -3,30 +3,23 @@
$(document).on('turbolinks:load', filters_init); $(document).on('turbolinks:load', filters_init);
function filters_init() { function filters_init() {
$('html').click(function(event) { $('html').click(function (event) {
var visible_filter = $('.filter_framed:visible'); var visible_filter = $('.filter_framed:visible');
if (visible_filter.length) { if (visible_filter.length) {
if ( if (!$(event.target).closest('.filter_framed').is(':visible')) {
!$(event.target)
.closest('.filter_framed')
.is(':visible')
) {
visible_filter.hide(); visible_filter.hide();
} }
} }
}); });
$('.filter').on('click', function(event) { $('.filter').on('click', function (event) {
filter_framed_show(event); filter_framed_show(event);
filter_framed_close_all_excepted(framed_id(event)); filter_framed_close_all_excepted(framed_id(event));
event.stopPropagation(); event.stopPropagation();
}); });
$('.erase-filter').on('click', function() { $('.erase-filter').on('click', function () {
$(this) $(this).parent().find('.filter_input').val('');
.parent()
.find('.filter_input')
.val('');
}); });
} }

View file

@ -1,6 +1,6 @@
/* globals $ */ /* globals $ */
$(document).on('click', '#dossiers-list tr', function(event) { $(document).on('click', '#dossiers-list tr', function (event) {
var href = $(this).data('href'); var href = $(this).data('href');
if (href && event.target.tagName !== 'A') { if (href && event.target.tagName !== 'A') {
location.href = href; location.href = href;

View file

@ -3,15 +3,15 @@
$(document).on('turbolinks:load', action_type_de_champs); $(document).on('turbolinks:load', action_type_de_champs);
function action_type_de_champs() { function action_type_de_champs() {
$("input[type='email']").on('change', function() { $("input[type='email']").on('change', function () {
toggleErrorClass(this, validateEmail($(this).val())); toggleErrorClass(this, validateEmail($(this).val()));
}); });
$("input[type='number']").on('change', function() { $("input[type='number']").on('change', function () {
toggleErrorClass(this, validateNumber($(this).val())); toggleErrorClass(this, validateNumber($(this).val()));
}); });
$("input[type='phone']").on('change', function() { $("input[type='phone']").on('change', function () {
var val = $(this).val(); var val = $(this).val();
val = val.replace(/[ ]/g, ''); val = val.replace(/[ ]/g, '');

View file

@ -3,7 +3,7 @@
$(document).on('turbolinks:load', modal_action); $(document).on('turbolinks:load', modal_action);
function modal_action() { function modal_action() {
$('#pj-modal').on('show.bs.modal', function(event) { $('#pj-modal').on('show.bs.modal', function (event) {
$('#pj-modal .modal-body .table .tr-content').hide(); $('#pj-modal .modal-body .table .tr-content').hide();
var button = $(event.relatedTarget); // Button that triggered the modal var button = $(event.relatedTarget); // Button that triggered the modal

View file

@ -8,7 +8,7 @@ function button_edit_procedure_init() {
} }
function buttons_api_carto() { function buttons_api_carto() {
$('#procedure-module-api-carto-use-api-carto').on('change', function() { $('#procedure-module-api-carto-use-api-carto').on('change', function () {
$('#modules-api-carto').toggle(); $('#modules-api-carto').toggle();
}); });
@ -17,7 +17,7 @@ function buttons_api_carto() {
} }
function button_individual() { function button_individual() {
$('#procedure_for_individual').on('change', function() { $('#procedure_for_individual').on('change', function () {
$('#individual-with-siret').toggle(); $('#individual-with-siret').toggle();
}); });

View file

@ -2,7 +2,7 @@ import Chartkick from 'chartkick';
import Highcharts from 'highcharts'; import Highcharts from 'highcharts';
import { toggle, delegate } from '@utils'; import { toggle, delegate } from '@utils';
export default function() { export default function () {
return null; return null;
} }

View file

@ -3,6 +3,6 @@ import Loadable from 'react-loadable';
const loading = () => <div className="spinner left" />; const loading = () => <div className="spinner left" />;
export default function(loader) { export default function (loader) {
return Loadable({ loader, loading }); return Loadable({ loader, loading });
} }

View file

@ -11,12 +11,12 @@ import '@reach/combobox/styles.css';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
let cache = {}; let cache = {};
const useAddressSearch = searchTerm => { const useAddressSearch = (searchTerm) => {
const [addresses, setAddresses] = useState([]); const [addresses, setAddresses] = useState([]);
useEffect(() => { useEffect(() => {
if (searchTerm.trim() !== '') { if (searchTerm.trim() !== '') {
let isFresh = true; let isFresh = true;
fetchAddresses(searchTerm).then(addresses => { fetchAddresses(searchTerm).then((addresses) => {
if (isFresh) setAddresses(addresses); if (isFresh) setAddresses(addresses);
}); });
return () => (isFresh = false); return () => (isFresh = false);
@ -25,12 +25,12 @@ const useAddressSearch = searchTerm => {
return addresses; return addresses;
}; };
const fetchAddresses = value => { const fetchAddresses = (value) => {
if (cache[value]) { if (cache[value]) {
return Promise.resolve(cache[value]); return Promise.resolve(cache[value]);
} }
const url = `https://api-adresse.data.gouv.fr/search/`; const url = `https://api-adresse.data.gouv.fr/search/`;
return getJSON(url, { q: value, limit: 5 }, 'get').then(result => { return getJSON(url, { q: value, limit: 5 }, 'get').then((result) => {
if (result) { if (result) {
cache[value] = result; cache[value] = result;
} }
@ -41,7 +41,7 @@ const fetchAddresses = value => {
const SearchInput = ({ getCoords }) => { const SearchInput = ({ getCoords }) => {
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
const addresses = useAddressSearch(searchTerm); const addresses = useAddressSearch(searchTerm);
const handleSearchTermChange = event => { const handleSearchTermChange = (event) => {
setSearchTerm(event.target.value); setSearchTerm(event.target.value);
}; };
return ( return (
@ -72,7 +72,7 @@ const SearchInput = ({ getCoords }) => {
> >
{addresses.features.length > 0 ? ( {addresses.features.length > 0 ? (
<ComboboxList> <ComboboxList>
{addresses.features.map(feature => { {addresses.features.map((feature) => {
const str = `${feature.properties.name}, ${feature.properties.city}`; const str = `${feature.properties.name}, ${feature.properties.city}`;
return ( return (
<ComboboxOption <ComboboxOption

View file

@ -18,7 +18,7 @@ function filterFeatureCollection(featureCollection, source) {
return { return {
type: 'FeatureCollection', type: 'FeatureCollection',
features: featureCollection.features.filter( features: featureCollection.features.filter(
feature => feature.properties.source === source (feature) => feature.properties.source === source
) )
}; };
} }
@ -75,7 +75,7 @@ const MapEditor = ({ featureCollection, url }) => {
updateFeaturesList(features); updateFeaturesList(features);
} }
const onMapLoad = map => { const onMapLoad = (map) => {
setCurrentMap(map); setCurrentMap(map);
drawControl.current.draw.set( drawControl.current.draw.set(
@ -83,7 +83,7 @@ const MapEditor = ({ featureCollection, url }) => {
); );
}; };
const onCadastresUpdate = evt => { const onCadastresUpdate = (evt) => {
if (currentMap) { if (currentMap) {
currentMap currentMap
.getSource('cadastres-layer') .getSource('cadastres-layer')
@ -93,10 +93,10 @@ const MapEditor = ({ featureCollection, url }) => {
} }
}; };
const onGpxImport = e => { const onGpxImport = (e) => {
let reader = new FileReader(); let reader = new FileReader();
reader.readAsText(e.target.files[0], 'UTF-8'); reader.readAsText(e.target.files[0], 'UTF-8');
reader.onload = async event => { reader.onload = async (event) => {
const featureCollection = gpx( const featureCollection = gpx(
new DOMParser().parseFromString(event.target.result, 'text/xml') new DOMParser().parseFromString(event.target.result, 'text/xml')
); );
@ -149,14 +149,14 @@ const MapEditor = ({ featureCollection, url }) => {
}} }}
> >
<SearchInput <SearchInput
getCoords={searchTerm => { getCoords={(searchTerm) => {
setCoords(searchTerm); setCoords(searchTerm);
setZoom([17]); setZoom([17]);
}} }}
/> />
</div> </div>
<Map <Map
onStyleLoad={map => onMapLoad(map)} onStyleLoad={(map) => onMapLoad(map)}
fitBounds={bbox} fitBounds={bbox}
fitBoundsOptions={{ padding: 100 }} fitBoundsOptions={{ padding: 100 }}
center={coords} center={coords}

View file

@ -72,7 +72,7 @@ function onFileChange(handler, directUploadUrl) {
function uploadFile(input, file, directUploadUrl) { function uploadFile(input, file, directUploadUrl) {
const controller = new Uploader(input, file, directUploadUrl); const controller = new Uploader(input, file, directUploadUrl);
return controller.start().then(signedId => { return controller.start().then((signedId) => {
input.value = null; input.value = null;
return signedId; return signedId;
}); });

View file

@ -17,7 +17,9 @@ function TypeDeChampRepetitionOptions({
return ( return (
<div className="repetition flex-grow cell"> <div className="repetition flex-grow cell">
<SortableContainer <SortableContainer
onSortEnd={params => dispatch({ type: 'onSortTypeDeChamps', params })} onSortEnd={(params) =>
dispatch({ type: 'onSortTypeDeChamps', params })
}
useDragHandle useDragHandle
> >
{state.typeDeChamps.map((typeDeChamp, index) => ( {state.typeDeChamps.map((typeDeChamp, index) => (

View file

@ -12,12 +12,14 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
typeDeChamps typeDeChamps
}); });
const hasUnsavedChamps = state.typeDeChamps.some(tdc => tdc.id == undefined); const hasUnsavedChamps = state.typeDeChamps.some(
(tdc) => tdc.id == undefined
);
return ( return (
<div className="champs-editor"> <div className="champs-editor">
<SortableContainer <SortableContainer
onSortEnd={params => dispatch({ type: 'onSortTypeDeChamps', params })} onSortEnd={(params) => dispatch({ type: 'onSortTypeDeChamps', params })}
lockAxis="y" lockAxis="y"
useDragHandle useDragHandle
> >

View file

@ -5,7 +5,7 @@ export function createTypeDeChampOperation(typeDeChamp, queue) {
method: 'post', method: 'post',
payload: { type_de_champ: typeDeChamp } payload: { type_de_champ: typeDeChamp }
}) })
.then(data => { .then((data) => {
handleResponseData(typeDeChamp, data); handleResponseData(typeDeChamp, data);
}); });
} }
@ -33,7 +33,7 @@ export function updateTypeDeChampOperation(typeDeChamp, queue) {
method: 'patch', method: 'patch',
payload: { type_de_champ: typeDeChamp } payload: { type_de_champ: typeDeChamp }
}) })
.then(data => { .then((data) => {
handleResponseData(typeDeChamp, data); handleResponseData(typeDeChamp, data);
}); });
} }

View file

@ -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]; let newTypeDeChamps = [...typeDeChamps, typeDeChamp];
if (insertAfter) { if (insertAfter) {
@ -127,7 +127,7 @@ function updateTypeDeChamp(
function removeTypeDeChamp(state, typeDeChamps, { typeDeChamp }) { function removeTypeDeChamp(state, typeDeChamps, { typeDeChamp }) {
destroyTypeDeChampOperation(typeDeChamp, state.queue) destroyTypeDeChampOperation(typeDeChamp, state.queue)
.then(() => state.flash.success()) .then(() => state.flash.success())
.catch(message => state.flash.error(message)); .catch((message) => state.flash.error(message));
return { return {
...state, ...state,
@ -141,7 +141,7 @@ function moveTypeDeChampUp(state, typeDeChamps, { typeDeChamp }) {
moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue) moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue)
.then(() => state.flash.success()) .then(() => state.flash.success())
.catch(message => state.flash.error(message)); .catch((message) => state.flash.error(message));
return { return {
...state, ...state,
@ -155,7 +155,7 @@ function moveTypeDeChampDown(state, typeDeChamps, { typeDeChamp }) {
moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue) moveTypeDeChampOperation(typeDeChamp, newIndex, state.queue)
.then(() => state.flash.success()) .then(() => state.flash.success())
.catch(message => state.flash.error(message)); .catch((message) => state.flash.error(message));
return { return {
...state, ...state,
@ -166,7 +166,7 @@ function moveTypeDeChampDown(state, typeDeChamps, { typeDeChamp }) {
function onSortTypeDeChamps(state, typeDeChamps, { oldIndex, newIndex }) { function onSortTypeDeChamps(state, typeDeChamps, { oldIndex, newIndex }) {
moveTypeDeChampOperation(typeDeChamps[oldIndex], newIndex, state.queue) moveTypeDeChampOperation(typeDeChamps[oldIndex], newIndex, state.queue)
.then(() => state.flash.success()) .then(() => state.flash.success())
.catch(message => state.flash.error(message)); .catch((message) => state.flash.error(message));
return { return {
...state, ...state,
@ -191,13 +191,13 @@ function getUpdateHandler(typeDeChamp, { queue, flash }) {
let handler = updateHandlers.get(typeDeChamp); let handler = updateHandlers.get(typeDeChamp);
if (!handler) { if (!handler) {
handler = debounce( handler = debounce(
done => (done) =>
updateTypeDeChampOperation(typeDeChamp, queue) updateTypeDeChampOperation(typeDeChamp, queue)
.then(() => { .then(() => {
flash.success(); flash.success();
done(); done();
}) })
.catch(message => flash.error(message)), .catch((message) => flash.error(message)),
200 200
); );
updateHandlers.set(typeDeChamp, handler); updateHandlers.set(typeDeChamp, handler);

View file

@ -4,7 +4,7 @@ const PRIMARY_SELECTOR = 'select[data-secondary-options]';
const SECONDARY_SELECTOR = 'select[data-secondary]'; const SECONDARY_SELECTOR = 'select[data-secondary]';
const CHAMP_SELECTOR = '.editable-champ'; const CHAMP_SELECTOR = '.editable-champ';
delegate('change', PRIMARY_SELECTOR, evt => { delegate('change', PRIMARY_SELECTOR, (evt) => {
const primary = evt.target; const primary = evt.target;
const secondary = primary const secondary = primary
.closest(CHAMP_SELECTOR) .closest(CHAMP_SELECTOR)

View file

@ -4,7 +4,7 @@ const BUTTON_SELECTOR = '.button.remove-row';
const DESTROY_INPUT_SELECTOR = 'input[type=hidden][name*=_destroy]'; const DESTROY_INPUT_SELECTOR = 'input[type=hidden][name*=_destroy]';
const CHAMP_SELECTOR = '.editable-champ'; const CHAMP_SELECTOR = '.editable-champ';
delegate('click', BUTTON_SELECTOR, evt => { delegate('click', BUTTON_SELECTOR, (evt) => {
evt.preventDefault(); evt.preventDefault();
const row = evt.target.closest('.row'); const row = evt.target.closest('.row');

View file

@ -41,7 +41,7 @@ export default class AutoSaveController {
headers: { Accept: 'application/json' } headers: { Accept: 'application/json' }
}; };
return window.fetch(form.action, fetchOptions).then(response => { return window.fetch(form.action, fetchOptions).then((response) => {
if (response.ok) { if (response.ok) {
resolve(response); resolve(response);
} else { } else {
@ -64,7 +64,7 @@ export default class AutoSaveController {
const fileInputs = form.querySelectorAll( const fileInputs = form.querySelectorAll(
'input[type="file"]:not([disabled]), .editable-champ-piece_justificative input:not([disabled])' '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 // Generate the form data
let formData = null; let formData = null;
@ -75,7 +75,7 @@ export default class AutoSaveController {
return [null, error]; return [null, error];
} finally { } finally {
// Re-enable disabled file inputs // Re-enable disabled file inputs
fileInputs.forEach(fileInput => (fileInput.disabled = false)); fileInputs.forEach((fileInput) => (fileInput.disabled = false));
} }
} }

View file

@ -47,7 +47,7 @@ addEventListener('autosave:end', () => {
hideSucceededStatusAfterDelay(); hideSucceededStatusAfterDelay();
}); });
addEventListener('autosave:error', event => { addEventListener('autosave:error', (event) => {
enable(document.querySelector('button.autosave-retry')); enable(document.querySelector('button.autosave-retry'));
setState('failed'); setState('failed');
logError(event.detail); logError(event.detail);

View file

@ -5,18 +5,18 @@ import { delegate } from '@utils';
const autoUploadsControllers = new AutoUploadsControllers(); const autoUploadsControllers = new AutoUploadsControllers();
function startUpload(input) { function startUpload(input) {
Array.from(input.files).forEach(file => { Array.from(input.files).forEach((file) => {
autoUploadsControllers.upload(input, file); autoUploadsControllers.upload(input, file);
}); });
} }
const fileInputSelector = `input[type=file][data-direct-upload-url][data-auto-attach-url]:not([disabled])`; 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); startUpload(event.target);
}); });
const retryButtonSelector = `button.attachment-error-retry`; const retryButtonSelector = `button.attachment-error-retry`;
delegate('click', retryButtonSelector, function() { delegate('click', retryButtonSelector, function () {
const inputSelector = this.dataset.inputTarget; const inputSelector = this.dataset.inputTarget;
const input = document.querySelector(inputSelector); const input = document.querySelector(inputSelector);
startUpload(input); startUpload(input);

View file

@ -40,18 +40,18 @@ export default class AutoUploadsControllers {
if (form) { if (form) {
form form
.querySelectorAll('button[type=submit]') .querySelectorAll('button[type=submit]')
.forEach(submitButton => Rails.disableElement(submitButton)); .forEach((submitButton) => Rails.disableElement(submitButton));
} }
// //
// DEBUG: hook into FileReader onload event // DEBUG: hook into FileReader onload event
// //
if (FileReader.prototype.addEventListener === originalImpl) { if (FileReader.prototype.addEventListener === originalImpl) {
FileReader.prototype.addEventListener = function() { FileReader.prototype.addEventListener = function () {
// When DirectUploads attempts to add an event listener for "error", // When DirectUploads attempts to add an event listener for "error",
// also insert a custom event listener of our that will report errors to Sentry. // also insert a custom event listener of our that will report errors to Sentry.
if (arguments[0] == 'error') { if (arguments[0] == 'error') {
let handler = event => { let handler = (event) => {
let message = `FileReader ${event.target.error.name}: ${event.target.error.message}`; let message = `FileReader ${event.target.error.name}: ${event.target.error.message}`;
fire(document, 'sentry:capture-exception', new Error(message)); fire(document, 'sentry:capture-exception', new Error(message));
}; };
@ -71,7 +71,7 @@ export default class AutoUploadsControllers {
if (this.inFlightUploadsCount == 0 && form) { if (this.inFlightUploadsCount == 0 && form) {
form form
.querySelectorAll('button[type=submit]') .querySelectorAll('button[type=submit]')
.forEach(submitButton => Rails.enableElement(submitButton)); .forEach((submitButton) => Rails.enableElement(submitButton));
} }
// //

View file

@ -1,14 +1,14 @@
import { delegate } from '@utils'; import { delegate } from '@utils';
delegate('click', 'body', event => { delegate('click', 'body', (event) => {
if (!event.target.closest('.dropdown')) { if (!event.target.closest('.dropdown')) {
[...document.querySelectorAll('.dropdown')].forEach(element => [...document.querySelectorAll('.dropdown')].forEach((element) =>
element.classList.remove('open', 'fade-in-down') element.classList.remove('open', 'fade-in-down')
); );
} }
}); });
delegate('click', '.dropdown-button', event => { delegate('click', '.dropdown-button', (event) => {
event.stopPropagation(); event.stopPropagation();
const parent = event.target.closest('.dropdown-button').parentElement; const parent = event.target.closest('.dropdown-button').parentElement;
if (parent.classList.contains('dropdown')) { if (parent.classList.contains('dropdown')) {

View file

@ -5,15 +5,15 @@ import { isNumeric } from '@utils';
const { api_geo_url, api_adresse_url } = gon.autocomplete || {}; const { api_geo_url, api_adresse_url } = gon.autocomplete || {};
const language = { const language = {
errorLoading: function() { errorLoading: function () {
return 'Les résultats ne peuvent pas être chargés.'; return 'Les résultats ne peuvent pas être chargés.';
}, },
inputTooLong: function(args) { inputTooLong: function (args) {
var overChars = args.input.length - args.maximum; var overChars = args.input.length - args.maximum;
return 'Supprimez ' + overChars + ' caractère' + (overChars > 1 ? 's' : ''); return 'Supprimez ' + overChars + ' caractère' + (overChars > 1 ? 's' : '');
}, },
inputTooShort: function(args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
return ( return (
@ -23,10 +23,10 @@ const language = {
(remainingChars > 1 ? 's' : '') (remainingChars > 1 ? 's' : '')
); );
}, },
loadingMore: function() { loadingMore: function () {
return 'Chargement de résultats supplémentaires…'; return 'Chargement de résultats supplémentaires…';
}, },
maximumSelected: function(args) { maximumSelected: function (args) {
return ( return (
'Vous pouvez seulement sélectionner ' + 'Vous pouvez seulement sélectionner ' +
args.maximum + args.maximum +
@ -34,13 +34,13 @@ const language = {
(args.maximum > 1 ? 's' : '') (args.maximum > 1 ? 's' : '')
); );
}, },
noResults: function() { noResults: function () {
return 'Aucun résultat trouvé'; return 'Aucun résultat trouvé';
}, },
searching: function() { searching: function () {
return 'Recherche en cours…'; return 'Recherche en cours…';
}, },
removeAllItems: function() { removeAllItems: function () {
return 'Supprimer tous les éléments'; return 'Supprimer tous les éléments';
} }
}; };

View file

@ -12,7 +12,7 @@ const ERROR_EVENT = 'direct-upload:error';
const END_EVENT = 'direct-upload:end'; const END_EVENT = 'direct-upload:end';
function addUploadEventListener(type, handler) { function addUploadEventListener(type, handler) {
addEventListener(type, event => { addEventListener(type, (event) => {
// Internet Explorer and Edge will sometime replay Javascript events // Internet Explorer and Edge will sometime replay Javascript events
// that were dispatched just before a page navigation (!), but without // that were dispatched just before a page navigation (!), but without
// the event payload. // the event payload.
@ -43,7 +43,7 @@ addUploadEventListener(PROGRESS_EVENT, ({ detail: { id, progress } }) => {
ProgressBar.progress(id, progress); ProgressBar.progress(id, progress);
}); });
addUploadEventListener(ERROR_EVENT, event => { addUploadEventListener(ERROR_EVENT, (event) => {
let id = event.detail.id; let id = event.detail.id;
let errorMsg = event.detail.error; let errorMsg = event.detail.error;

View file

@ -92,7 +92,7 @@ export default class Uploader {
} }
directUploadWillStoreFileWithXHR(xhr) { directUploadWillStoreFileWithXHR(xhr) {
xhr.upload.addEventListener('progress', event => xhr.upload.addEventListener('progress', (event) =>
this.uploadRequestDidProgress(event) this.uploadRequestDidProgress(event)
); );
} }

View file

@ -63,8 +63,8 @@ function initMap(element, { position }) {
} }
function toLatLngs({ coordinates }) { function toLatLngs({ coordinates }) {
return coordinates.map(polygon => return coordinates.map((polygon) =>
polygon[0].map(point => L.GeoJSON.coordsToLatLng(point)) polygon[0].map((point) => L.GeoJSON.coordsToLatLng(point))
); );
} }
@ -137,7 +137,7 @@ function findInput(selector) {
} }
function clearLayers(map) { function clearLayers(map) {
map.eachLayer(layer => { map.eachLayer((layer) => {
if (layer instanceof L.GeoJSON) { if (layer instanceof L.GeoJSON) {
map.removeLayer(layer); map.removeLayer(layer);
} }
@ -185,7 +185,7 @@ const RPG_POLYGON_STYLE = Object.assign({}, POLYGON_STYLE, {
fillColor: '#31708f' fillColor: '#31708f'
}); });
delegate('click', '.carte.edit', event => { delegate('click', '.carte.edit', (event) => {
const map = getCurrentMap(event.target); const map = getCurrentMap(event.target);
if (map) { 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(); event.preventDefault();
const map = getCurrentMap(event.target); 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 map = getCurrentMap(event.target);
const { geometry } = event.params.data; const { geometry } = event.params.data;

View file

@ -34,7 +34,7 @@ function toggleElement(event) {
function closeFCPopin(event) { function closeFCPopin(event) {
event.preventDefault(); event.preventDefault();
fconnect.popin.className = 'fade-out'; fconnect.popin.className = 'fade-out';
setTimeout(function() { setTimeout(function () {
document.body.removeChild(fconnect.popin); document.body.removeChild(fconnect.popin);
}, 200); }, 200);
} }
@ -49,7 +49,7 @@ function openFCPopin() {
fconnect.popin.appendChild(iframe); fconnect.popin.appendChild(iframe);
setTimeout(function() { setTimeout(function () {
fconnect.popin.className = 'fade-in'; fconnect.popin.className = 'fade-in';
}, 200); }, 200);
} }
@ -112,7 +112,7 @@ var messageEvent = eventMethod == 'attachEvent' ? 'onmessage' : 'message';
// Listen to message from child window // Listen to message from child window
eventer( eventer(
messageEvent, messageEvent,
function(e) { function (e) {
var key = e.message ? 'message' : 'data'; var key = e.message ? 'message' : 'data';
var data = e[key]; var data = e[key];
if (data === 'close_popup') { if (data === 'close_popup') {

View file

@ -1,9 +1,9 @@
import { fire } from '@utils'; import { fire } from '@utils';
addEventListener('turbolinks:load', function() { addEventListener('turbolinks:load', function () {
fire(document, 'ds:page:update'); fire(document, 'ds:page:update');
}); });
addEventListener('ajax:success', function() { addEventListener('ajax:success', function () {
fire(document, 'ds:page:update'); fire(document, 'ds:page:update');
}); });

View file

@ -18,7 +18,7 @@ function clearDataset(event) {
} }
function toCamelCase(string) { function toCamelCase(string) {
return string.replace(dash, function(_, letter) { return string.replace(dash, function (_, letter) {
return letter.toUpperCase(); return letter.toUpperCase();
}); });
} }

View file

@ -6,10 +6,10 @@ import jQuery from 'jquery';
// https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9 // https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9
addEventListener('load', () => { addEventListener('load', () => {
const { href, handleRemote } = Rails; const { href, handleRemote } = Rails;
Rails.href = function(element) { Rails.href = function (element) {
return element.href || href(element); return element.href || href(element);
}; };
Rails.handleRemote = function(e) { Rails.handleRemote = function (e) {
if (this instanceof HTMLElement) { if (this instanceof HTMLElement) {
handleRemote.call(this, e); handleRemote.call(this, e);
} else { } else {

View file

@ -24,7 +24,7 @@ addEventListener('export:update', ({ detail: { url } }) => {
exportPoller.add(url); exportPoller.add(url);
}); });
delegate('click', '[data-attachment-refresh]', event => { delegate('click', '[data-attachment-refresh]', (event) => {
event.preventDefault(); event.preventDefault();
attachementPoller.check(); attachementPoller.check();
}); });

View file

@ -3,9 +3,9 @@
// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty // 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 // 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])'); let inputs = e.target.querySelectorAll('input[type="file"]:not([disabled])');
inputs.forEach(function(input) { inputs.forEach(function (input) {
if (input.files.length > 0) { if (input.files.length > 0) {
return; 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. // 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( let inputs = e.target.querySelectorAll(
'input[type="file"][data-safari-temp-disabled]' 'input[type="file"][data-safari-temp-disabled]'
); );
inputs.forEach(function(input) { inputs.forEach(function (input) {
input.removeAttribute('data-safari-temp-disabled'); input.removeAttribute('data-safari-temp-disabled');
input.removeAttribute('disabled'); input.removeAttribute('disabled');
}); });

View file

@ -9,7 +9,7 @@ import { delegate, toggle } from '@utils';
const TOGGLE_SOURCE_SELECTOR = '[data-toggle-target]'; const TOGGLE_SOURCE_SELECTOR = '[data-toggle-target]';
delegate('click', TOGGLE_SOURCE_SELECTOR, evt => { delegate('click', TOGGLE_SOURCE_SELECTOR, (evt) => {
evt.preventDefault(); evt.preventDefault();
const targetSelector = evt.target.dataset.toggleTarget; const targetSelector = evt.target.dataset.toggleTarget;

View file

@ -29,7 +29,7 @@ if (enabled) {
// Send Matomo a new event when navigating to a new page using Turbolinks // Send Matomo a new event when navigating to a new page using Turbolinks
// (see https://developer.matomo.org/guides/spa-tracking) // (see https://developer.matomo.org/guides/spa-tracking)
let previousPageUrl = null; let previousPageUrl = null;
addEventListener('turbolinks:load', event => { addEventListener('turbolinks:load', (event) => {
if (previousPageUrl) { if (previousPageUrl) {
window._paq.push(['setReferrerUrl', previousPageUrl]); window._paq.push(['setReferrerUrl', previousPageUrl]);
window._paq.push(['setCustomUrl', window.location.href]); window._paq.push(['setCustomUrl', window.location.href]);

View file

@ -6,13 +6,13 @@ const { key, enabled, user, environment, browser } = gon.sentry || {};
if (enabled && key) { if (enabled && key) {
Sentry.init({ dsn: key, environment }); Sentry.init({ dsn: key, environment });
Sentry.configureScope(scope => { Sentry.configureScope((scope) => {
scope.setUser(user); scope.setUser(user);
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy'); scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
}); });
// Register a way to explicitely capture messages from a different bundle. // 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; const error = event.detail;
Sentry.captureException(error); Sentry.captureException(error);
}); });

View file

@ -46,7 +46,7 @@ export function removeClass(el, cssClass) {
export function delegate(eventNames, selector, callback) { export function delegate(eventNames, selector, callback) {
eventNames eventNames
.split(' ') .split(' ')
.forEach(eventName => .forEach((eventName) =>
Rails.delegate(document, selector, eventName, callback) Rails.delegate(document, selector, eventName, callback)
); );
} }
@ -90,13 +90,13 @@ export function scrollToBottom(container) {
} }
export function on(selector, eventName, fn) { export function on(selector, eventName, fn) {
[...document.querySelectorAll(selector)].forEach(element => [...document.querySelectorAll(selector)].forEach((element) =>
element.addEventListener(eventName, event => fn(event, event.detail)) element.addEventListener(eventName, (event) => fn(event, event.detail))
); );
} }
export function to(promise) { 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) { export function isNumeric(n) {