Skip to content
Snippets Groups Projects
Commit dac766b7 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Remove unused code.

parent 64052900
No related branches found
No related tags found
1 merge request!87Resolve "Faire apparaître les revenus du capital et de rente et RSA dans les étiquettes cas types"
Pipeline #3873 passed
<script lang="ts">
import type {
DecompositionReference,
Variable,
Waterfall,
} from "@openfisca/json-model"
import type { DecompositionReference, Waterfall } from "@openfisca/json-model"
import { Unit } from "@openfisca/json-model"
import { createEventDispatcher, getContext } from "svelte"
import type { Writable } from "svelte/store"
import { session } from "$app/stores"
import type { CalculationByName, CalculationName } from "$lib/calculations"
// import PictoArbreMetropole from "$lib/components/pictos/PictoArbreMetropole.svelte"
import Icon from "@iconify/svelte"
import Spinner from "$lib/components/Spinner.svelte"
import TestCaseSummary from "$lib/components/test_cases/TestCaseSummary.svelte"
......@@ -25,10 +20,6 @@
import { entityByKey, personEntityKey } from "$lib/entities"
import type { ParametricReform } from "$lib/reforms"
import type { Situation, Slider } from "$lib/situations"
import {
getSituationVariableValue,
setSituationVariableValue,
} from "$lib/situations"
import { variableSummaryByName } from "$lib/variables"
export let decompositionByName: DecompositionByName
......@@ -42,12 +33,6 @@
) as Writable<CalculationByName>
const childrenKey = $session.childrenKey
const dispatch = createEventDispatcher()
const euroAmountFormatter = new Intl.NumberFormat("fr-FR", {
currency: "EUR",
maximumFractionDigits: 0,
minimumFractionDigits: 0,
style: "currency",
})
const evaluationByNameArray = getContext("evaluationByNameArray") as Writable<
EvaluationByName[]
>
......@@ -95,8 +80,6 @@
: situationsToCompare[situationIndex][sliderEntity.key_plural],
)
// $: updateSituation(year, adultes, enfants)
function calculateTotal(
evaluationByName: EvaluationByName,
calculationName: CalculationName,
......@@ -124,102 +107,9 @@
return total
}
function changeVectorIndex(
index: number,
situationIndex: number,
event: Event,
) {
const target = event.target as HTMLInputElement
const vectorIndex = parseInt(target.value)
// Update situation.
let situation = situationsToCompare[index]
const slider = situation.slider
const variable = variableSummaryByName[slider.name]
const updatedSituation = setSituationVariableValue(
entityByKey,
situation,
variable,
slider.id,
year,
Math.round(slider.stepValue * vectorIndex),
)
updatedSituation.slider = {
...slider,
vectorIndex,
}
situation = updatedSituation
situationsToCompare[index] = situation
dispatch("changeSituation", { situation, situationIndex })
}
function changeWaterfall(waterfallName: string) {
$waterfall = waterfalls.find(({ name }) => name === waterfallName)
}
function getVariableValue(
situation: Situation,
variableName: string,
populationId: string,
): number | undefined {
const variable = variableSummaryByName[variableName]
if (variable === undefined) {
return undefined
}
return getSituationVariableValue(
situation,
variable,
populationId,
year,
) as number
}
function toggleSlider(
situationIndex: number,
situation: Situation,
variable: Variable,
) {
if (situation.slider === undefined) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const slider = situation.sliders!.find(
(slider) =>
slider.entity === variable.entity && slider.name === variable.name,
)
const stepValue = (slider.max - slider.min) / 100
const value = getSituationVariableValue(
situation,
variable,
slider.id,
year,
) as number
const vectorIndex = Math.max(
0,
Math.min(100, Math.round(value / stepValue)),
)
let updatedSituation = setSituationVariableValue(
entityByKey,
situation,
variable,
slider.id,
year,
Math.round(stepValue * vectorIndex),
)
if (updatedSituation === situation) {
// This can occur, when slider was deselected, then reselected.
updatedSituation = { ...situation }
}
updatedSituation.slider = {
...slider,
stepValue,
vectorIndex,
}
situation = updatedSituation
} else {
situation = { ...situation }
delete situation.slider
}
dispatch("changeSituation", { situationIndex, situation })
}
</script>
<div
......
......@@ -57,26 +57,12 @@
[],
)
$: childrenCount = Object.values(familySituation).reduce(
(count: number, family) =>
count + ((family[childrenKey] as string[] | undefined)?.length ?? 0),
0,
)
$: personSituation = situation[personEntity.key_plural]
$: personsCount = Object.keys(personSituation).length
$: adultsCount = personsCount - childrenCount
$: slider = situation.sliders?.[0]
$: sliderEntity =
slider === undefined ? undefined : entityByKey[slider.entity]
$: sliderEntitySituation =
sliderEntity === undefined ? undefined : situation[sliderEntity.key_plural]
function changeVectorIndex(event: Event) {
const target = event.target as HTMLInputElement
const vectorIndex = parseInt(target.value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment