commit
7ca89f9bb0
32 changed files with 385 additions and 532 deletions
|
@ -1,9 +1,9 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
function ComboAdresseSearch({
|
function ComboAdresseSearch({
|
||||||
mandatory,
|
mandatory,
|
||||||
|
@ -16,7 +16,7 @@ function ComboAdresseSearch({
|
||||||
const transformResults = useCallback((_, { features }) => features);
|
const transformResults = useCallback((_, { features }) => features);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
required={mandatory}
|
required={mandatory}
|
||||||
|
@ -28,7 +28,7 @@ function ComboAdresseSearch({
|
||||||
transformResult={transformResult}
|
transformResult={transformResult}
|
||||||
transformResults={transformResults}
|
transformResults={transformResults}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
function ComboAnnuaireEducationSearch(params) {
|
function ComboAnnuaireEducationSearch(params) {
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
hiddenFieldId={params.hiddenFieldId}
|
hiddenFieldId={params.hiddenFieldId}
|
||||||
|
@ -21,7 +21,7 @@ function ComboAnnuaireEducationSearch(params) {
|
||||||
}
|
}
|
||||||
}) => [id, `${nom_etablissement}, ${nom_commune} (${id})`]}
|
}) => [id, `${nom_etablissement}, ${nom_commune} (${id})`]}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
function ComboCommunesSearch(params) {
|
function ComboCommunesSearch(params) {
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
hiddenFieldId={params.hiddenFieldId}
|
hiddenFieldId={params.hiddenFieldId}
|
||||||
|
@ -17,7 +17,7 @@ function ComboCommunesSearch(params) {
|
||||||
`${nom} (${codesPostaux[0]})`
|
`${nom} (${codesPostaux[0]})`
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
import matchSorter from 'match-sorter';
|
import { matchSorter } from 'match-sorter';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
const extraTerms = [{ code: '99', nom: 'Etranger' }];
|
const extraTerms = [{ code: '99', nom: 'Etranger' }];
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ function ComboDepartementsSearch(params) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
hiddenFieldId={params.hiddenFieldId}
|
hiddenFieldId={params.hiddenFieldId}
|
||||||
|
@ -25,7 +25,7 @@ function ComboDepartementsSearch(params) {
|
||||||
transformResult={({ code, nom }) => [code, `${code} - ${nom}`]}
|
transformResult={({ code, nom }) => [code, `${code} - ${nom}`]}
|
||||||
transformResults={transformResults}
|
transformResults={transformResults}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
ComboboxPopover
|
ComboboxPopover
|
||||||
} from '@reach/combobox';
|
} from '@reach/combobox';
|
||||||
import '@reach/combobox/styles.css';
|
import '@reach/combobox/styles.css';
|
||||||
import matchSorter from 'match-sorter';
|
import { matchSorter } from 'match-sorter';
|
||||||
import { fire } from '@utils';
|
import { fire } from '@utils';
|
||||||
|
|
||||||
const Context = createContext();
|
const Context = createContext();
|
|
@ -1,12 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
function ComboPaysSearch(params) {
|
function ComboPaysSearch(params) {
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
hiddenFieldId={params.hiddenFieldId}
|
hiddenFieldId={params.hiddenFieldId}
|
||||||
|
@ -14,7 +14,7 @@ function ComboPaysSearch(params) {
|
||||||
minimumInputLength={0}
|
minimumInputLength={0}
|
||||||
transformResult={({ nom }) => [nom, nom]}
|
transformResult={({ nom }) => [nom, nom]}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ReactQueryCacheProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
|
|
||||||
import ComboSearch from './ComboSearch';
|
import ComboSearch from './ComboSearch';
|
||||||
import { queryCache } from './shared/queryCache';
|
import { queryClient } from './shared/queryClient';
|
||||||
|
|
||||||
function ComboRegionsSearch(params) {
|
function ComboRegionsSearch(params) {
|
||||||
return (
|
return (
|
||||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
hiddenFieldId={params.hiddenFieldId}
|
hiddenFieldId={params.hiddenFieldId}
|
||||||
|
@ -14,7 +14,7 @@ function ComboRegionsSearch(params) {
|
||||||
minimumInputLength={0}
|
minimumInputLength={0}
|
||||||
transformResult={({ code, nom }) => [code, nom]}
|
transformResult={({ code, nom }) => [code, nom]}
|
||||||
/>
|
/>
|
||||||
</ReactQueryCacheProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useMemo, useCallback, useRef } from 'react';
|
import React, { useState, useMemo, useCallback, useRef } from 'react';
|
||||||
import { useDebounce } from 'react-use';
|
import { useDebounce } from 'use-debounce';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import {
|
||||||
|
@ -41,7 +41,7 @@ function ComboSearch({
|
||||||
);
|
);
|
||||||
const initialValue = hiddenValueField && hiddenValueField.value;
|
const initialValue = hiddenValueField && hiddenValueField.value;
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState('');
|
const [debouncedSearchTerm] = useDebounce(searchTerm, 300);
|
||||||
const [value, setValue] = useState(initialValue);
|
const [value, setValue] = useState(initialValue);
|
||||||
const resultsMap = useRef({});
|
const resultsMap = useRef({});
|
||||||
const setExternalValue = useCallback((value) => {
|
const setExternalValue = useCallback((value) => {
|
||||||
|
@ -64,14 +64,6 @@ function ComboSearch({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useDebounce(
|
|
||||||
() => {
|
|
||||||
setDebouncedSearchTerm(searchTerm);
|
|
||||||
},
|
|
||||||
300,
|
|
||||||
[searchTerm]
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleOnChange = useCallback(
|
const handleOnChange = useCallback(
|
||||||
({ target: { value } }) => {
|
({ target: { value } }) => {
|
||||||
setValue(value);
|
setValue(value);
|
|
@ -1,4 +1,3 @@
|
||||||
import scrollToComponent from 'react-scroll-to-component';
|
|
||||||
import { debounce } from '@utils';
|
import { debounce } from '@utils';
|
||||||
import {
|
import {
|
||||||
createTypeDeChampOperation,
|
createTypeDeChampOperation,
|
||||||
|
@ -53,8 +52,10 @@ function addTypeDeChamp(state, typeDeChamps, insertAfter, done) {
|
||||||
state.flash.success();
|
state.flash.success();
|
||||||
done();
|
done();
|
||||||
if (insertAfter) {
|
if (insertAfter) {
|
||||||
scrollToComponent(insertAfter.target.nextElementSibling, {
|
insertAfter.target.nextElementSibling.scrollIntoView({
|
||||||
duration: 300
|
behavior: 'smooth',
|
||||||
|
block: 'start',
|
||||||
|
inline: 'nearest'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { QueryCache } from 'react-query';
|
import { QueryClient } from 'react-query';
|
||||||
import { isNumeric } from '@utils';
|
import { isNumeric } from '@utils';
|
||||||
import matchSorter from 'match-sorter';
|
import { matchSorter } from 'match-sorter';
|
||||||
|
|
||||||
const { api_geo_url, api_adresse_url, api_education_url } =
|
const { api_geo_url, api_adresse_url, api_education_url } =
|
||||||
gon.autocomplete || {};
|
gon.autocomplete || {};
|
||||||
|
|
||||||
export const queryCache = new QueryCache({
|
export const queryClient = new QueryClient({
|
||||||
defaultConfig: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
queryFn: defaultQueryFn
|
queryFn: defaultQueryFn
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ function buildOptions() {
|
||||||
return [{}, null];
|
return [{}, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function defaultQueryFn(scope, term) {
|
async function defaultQueryFn({ queryKey: [scope, term] }) {
|
||||||
if (scope == 'pays') {
|
if (scope == 'pays') {
|
||||||
return matchSorter(await getPays(), term, { keys: ['nom'] });
|
return matchSorter(await getPays(), term, { keys: ['nom'] });
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ default: &default
|
||||||
extensions:
|
extensions:
|
||||||
- .mjs
|
- .mjs
|
||||||
- .js
|
- .js
|
||||||
|
- .jsx
|
||||||
- .sass
|
- .sass
|
||||||
- .scss
|
- .scss
|
||||||
- .css
|
- .css
|
||||||
|
|
31
package.json
31
package.json
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/preset-react": "^7.10.4",
|
"@babel/preset-react": "^7.12.13",
|
||||||
"@fortawesome/fontawesome-svg-core": "^1.2.28",
|
"@fortawesome/fontawesome-svg-core": "^1.2.34",
|
||||||
"@fortawesome/free-solid-svg-icons": "^5.13.0",
|
"@fortawesome/free-solid-svg-icons": "^5.15.2",
|
||||||
"@fortawesome/react-fontawesome": "^0.1.9",
|
"@fortawesome/react-fontawesome": "^0.1.14",
|
||||||
"@mapbox/mapbox-gl-draw": "^1.2.0",
|
"@mapbox/mapbox-gl-draw": "^1.2.0",
|
||||||
"@rails/actiontext": "^6.0.3",
|
"@rails/actiontext": "^6.0.3",
|
||||||
"@rails/activestorage": "^6.0.3",
|
"@rails/activestorage": "^6.0.3",
|
||||||
"@rails/ujs": "^6.0.3",
|
"@rails/ujs": "^6.0.3",
|
||||||
"@rails/webpacker": "5.1.1",
|
"@rails/webpacker": "5.1.1",
|
||||||
"@reach/combobox": "^0.10.2",
|
"@reach/combobox": "^0.13.0",
|
||||||
"@sentry/browser": "^5.15.5",
|
"@sentry/browser": "^5.15.5",
|
||||||
"@tmcw/togeojson": "^4.0.0",
|
"@tmcw/togeojson": "^4.0.0",
|
||||||
"babel-plugin-macros": "^2.8.0",
|
"babel-plugin-macros": "^2.8.0",
|
||||||
|
@ -20,23 +20,22 @@
|
||||||
"dom4": "^2.1.5",
|
"dom4": "^2.1.5",
|
||||||
"email-butler": "^1.0.13",
|
"email-butler": "^1.0.13",
|
||||||
"highcharts": "^8.1.1",
|
"highcharts": "^8.1.1",
|
||||||
"intersection-observer": "^0.10.0",
|
"intersection-observer": "^0.12.0",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"mapbox-gl": "^1.11.1",
|
"mapbox-gl": "^1.11.1",
|
||||||
"match-sorter": "^4.2.1",
|
"match-sorter": "^6.2.0",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react": "^16.13.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-intersection-observer": "^8.26.2",
|
"react-intersection-observer": "^8.31.0",
|
||||||
"react-mapbox-gl": "^4.8.6",
|
"react-mapbox-gl": "^4.8.6",
|
||||||
"react-mapbox-gl-draw": "^2.0.4",
|
"react-mapbox-gl-draw": "^2.0.4",
|
||||||
"react-query": "^2.23.1",
|
"react-query": "^3.9.7",
|
||||||
"react-scroll-to-component": "^1.0.2",
|
|
||||||
"react-sortable-hoc": "^1.11.0",
|
"react-sortable-hoc": "^1.11.0",
|
||||||
"react-use": "^15.3.4",
|
|
||||||
"react_ujs": "^2.6.1",
|
"react_ujs": "^2.6.1",
|
||||||
"select2": "^4.0.13",
|
"select2": "^4.0.13",
|
||||||
"trix": "^1.2.3",
|
"trix": "^1.2.3",
|
||||||
|
"use-debounce": "^5.2.0",
|
||||||
"whatwg-fetch": "^3.0.0"
|
"whatwg-fetch": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -45,15 +44,15 @@
|
||||||
"eslint": "^7.0.0",
|
"eslint": "^7.0.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"eslint-plugin-react": "^7.20.0",
|
"eslint-plugin-react": "^7.22.0",
|
||||||
"eslint-plugin-react-hooks": "^4.0.2",
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
"netlify-cli": "^2.61.2",
|
"netlify-cli": "^2.61.2",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.0.5",
|
||||||
"webpack-bundle-analyzer": "^3.7.0",
|
"webpack-bundle-analyzer": "^3.7.0",
|
||||||
"webpack-dev-server": "^3.11.0"
|
"webpack-dev-server": "^3.11.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint:js": "eslint ./app/javascript ./config/webpack",
|
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx ./app/javascript ./config/webpack",
|
||||||
"webpack:build": "NODE_ENV=production bin/webpack",
|
"webpack:build": "NODE_ENV=production bin/webpack",
|
||||||
"graphql:docs:build": "graphdoc --force",
|
"graphql:docs:build": "graphdoc --force",
|
||||||
"graphql:docs:deploy": "netlify deploy -d ./docs/graphql --prod",
|
"graphql:docs:deploy": "netlify deploy -d ./docs/graphql --prod",
|
||||||
|
|
Loading…
Add table
Reference in a new issue