Skip to content

Commit

Permalink
Merge pull request #279 from InseeFr/V3.0.16
Browse files Browse the repository at this point in the history
V3.0.16
  • Loading branch information
JeromeMBourgeois authored Mar 4, 2022
2 parents 1e66daa + 400f3af commit 6a9e44f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bauhaus",
"version": "3.0.15",
"version": "3.0.16",
"description": "Web application for the management of concepts, classifications and other statistical objects",
"repository": {
"type": "git",
Expand Down
63 changes: 44 additions & 19 deletions packages/operations/src/sims/sims-geography-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import SimsGeographyField from './sims-geography-field';
import './sims-geography-picker.scss';
import { SimsGeographyI18NLabel } from 'bauhaus-operations';


const SimsGeographyPicker = ({ onChange, value, loadGeographies }) => {
const [territory, setTerritory] = useState();
const geographiesOptions = useSelector(Stores.Geographies.getAllOptions);
Expand All @@ -19,15 +18,20 @@ const SimsGeographyPicker = ({ onChange, value, loadGeographies }) => {
}, []);

const openViewPanel = useCallback(() => {
setTerritory(geographiesOptions?.find(({ value: v }) => v === value)?.geography);
setTerritory(
geographiesOptions?.find(({ value: v }) => v === value)?.geography
);
setSlidingModal(true);
}, [geographiesOptions, value]);

const onSave = useCallback((territoryUri) => {
setSlidingModal(false);
loadGeographies();
onChange(territoryUri)
}, [loadGeographies, onChange]);
const onSave = useCallback(
(territoryUri) => {
setSlidingModal(false);
loadGeographies();
onChange(territoryUri);
},
[loadGeographies, onChange]
);

const onCancel = useCallback(() => {
setTerritory(undefined);
Expand All @@ -37,7 +41,9 @@ const SimsGeographyPicker = ({ onChange, value, loadGeographies }) => {
return <SimsGeographyI18NLabel geography={geography} />;
};

const shouldSeeViewButton = geographiesOptions?.find(({ value: v }) => v === value)?.typeTerritory === "Territoire Statistique";
const shouldSeeViewButton =
geographiesOptions?.find(({ value: v }) => v === value)?.typeTerritory ===
'Territoire Statistique';
return (
<>
<div className="bauhaus-sims-geography-picker">
Expand All @@ -48,11 +54,13 @@ const SimsGeographyPicker = ({ onChange, value, loadGeographies }) => {
)}
filterOption={(option, searchValue) => {
const search = searchValue.toLowerCase();
const label = option.data.label.toLowerCase();
const typeTerritory = option.data.typeTerritory.toLowerCase();
return !searchValue
|| label.indexOf(search) >= 0
|| typeTerritory.indexOf(search) >= 0
const label = option.label.toLowerCase();
const typeTerritory = option.typeTerritory.toLowerCase();
return (
!searchValue ||
label.indexOf(search) >= 0 ||
typeTerritory.indexOf(search) >= 0
);
}}
options={geographiesOptions}
onChange={(e) => onChange(e ? e.value : '')}
Expand All @@ -65,16 +73,34 @@ const SimsGeographyPicker = ({ onChange, value, loadGeographies }) => {
</div>

<Auth.AuthGuard roles={[Auth.ADMIN]}>
<button type="button" className="btn btn-default" onClick={openNewPanel}>
<button
type="button"
className="btn btn-default"
onClick={openNewPanel}
>
{D.btnNew}
</button>
</Auth.AuthGuard>
<button disabled={!shouldSeeViewButton} type="button" className="btn btn-default" onClick={openViewPanel}>
<button
disabled={!shouldSeeViewButton}
type="button"
className="btn btn-default"
onClick={openViewPanel}
>
{D.btnSee}
</button>
</div>
<SlidingPanel type={'right'} isOpen={slidingModal} size={60} backdropClicked={() => setSlidingModal(false)}>
<SimsGeographyField onCancel={onCancel} onSave={onSave} territory={territory}/>
<SlidingPanel
type={'right'}
isOpen={slidingModal}
size={60}
backdropClicked={() => setSlidingModal(false)}
>
<SimsGeographyField
onCancel={onCancel}
onSave={onSave}
territory={territory}
/>
</SlidingPanel>
</>
);
Expand All @@ -83,5 +109,4 @@ const mapDispatchToProps = {
loadGeographies: Stores.Geographies.loadGeographies,
};

export default connect(undefined, mapDispatchToProps)(SimsGeographyPicker)

export default connect(undefined, mapDispatchToProps)(SimsGeographyPicker);
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sonar.host.url=https://sonarcloud.io

# Project name & version
sonar.projectName=Bauhaus
sonar.projectVersion=3.0.15
sonar.projectVersion=3.0.16

# Path to sources
sonar.sources=app/src,packages/operations/src,packages/structures/src,packages/utilities/src
Expand Down

0 comments on commit 6a9e44f

Please sign in to comment.