-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move merge customization into its own file
- Loading branch information
1 parent
cb0f751
commit e349df2
Showing
2 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const {chain} = require('lodash') | ||
|
||
const NOM_VOIE_PRIORITY = { | ||
bal: 5, | ||
ban: 4, | ||
cadastre: 3, | ||
bano: 2, | ||
ftth: 1 | ||
} | ||
|
||
function selectByPriority(values, priorityMap) { | ||
if (Object.keys(values).length === 0) { | ||
return | ||
} | ||
return chain(values) | ||
.toPairs() | ||
.map(([source, value]) => ({source, value})) | ||
.maxBy(({source}) => priorityMap[source]) | ||
.value() | ||
.value | ||
} | ||
|
||
function computeNomVoie(nomsVoie) { | ||
return selectByPriority(nomsVoie, NOM_VOIE_PRIORITY) | ||
} | ||
|
||
function computePositionProps(positions) { | ||
if (positions.bal) { | ||
return {...positions.bal, positionSource: 'bal'} | ||
} | ||
if (positions.ban) { | ||
return {...positions.ban, positionSource: 'ban'} | ||
} | ||
if (positions.cadastre && positions.cadastre.positionType === 'entrée') { | ||
return {...positions.cadastre, positionSource: 'cadastre'} | ||
} | ||
if (positions.bano) { | ||
return {...positions.bano, positionSource: 'bano'} | ||
} | ||
if (positions.ftth) { | ||
return {...positions.ftth, positionSource: 'ftth'} | ||
} | ||
if (positions.cadastre) { | ||
return {...positions.cadastre, positionSource: 'cadastre'} // Centre de parcelle | ||
} | ||
return {} | ||
} | ||
|
||
module.exports = {computePositionProps, computeNomVoie} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters