Skip to main content
Sign in
Snippets Groups Projects
Commit c50c0598 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Rename types used for parametric reforms.

parent ea76e7e4
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import { waterfalls } from "$lib/decompositions" import { waterfalls } from "$lib/decompositions"
import type { EditionMode } from "$lib/editions" import type { EditionMode } from "$lib/editions"
import { entityByKey, personEntityKey } from "$lib/entities" import { entityByKey, personEntityKey } from "$lib/entities"
import type { Reform } from "$lib/reforms" import type { ParametricReform } from "$lib/reforms"
import type { AxisDescription, Situation } from "$lib/situations" import type { AxisDescription, Situation } from "$lib/situations"
import { import {
getSituationVariableValue, getSituationVariableValue,
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
) as Writable<EvaluationByNameArrayByCalculationName> ) as Writable<EvaluationByNameArrayByCalculationName>
const familyEntity = entityByKey[$session.familyEntityKey] const familyEntity = entityByKey[$session.familyEntityKey]
const personEntity = entityByKey[personEntityKey] const personEntity = entityByKey[personEntityKey]
const reform = getContext("reform") as Writable<Reform> const reform = getContext("reform") as Writable<ParametricReform>
const variableDefinitionByName = { const variableDefinitionByName = {
age: { age: {
allowSlider: true, allowSlider: true,
... ...
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import ScaleAtInstantEdit from "$lib/components/parameters/ScaleAtInstantEdit.svelte" import ScaleAtInstantEdit from "$lib/components/parameters/ScaleAtInstantEdit.svelte"
import type { CalculationName } from "$lib/decompositions" import type { CalculationName } from "$lib/decompositions"
import type { Reform } from "$lib/reforms" import type { ParametricReform } from "$lib/reforms"
import { ReformChangeType } from "$lib/reforms" import { ReformChangeType } from "$lib/reforms"
import VariableReferredParameterHeader from "./VariableReferredParameterHeader.svelte" import VariableReferredParameterHeader from "./VariableReferredParameterHeader.svelte"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
export let depth: number export let depth: number
export let parameter: ScaleParameter export let parameter: ScaleParameter
const reform = getContext("reform") as Writable<Reform> const reform = getContext("reform") as Writable<ParametricReform>
const requestedCalculationsName = getContext( const requestedCalculationsName = getContext(
"requestedCalculationsName", "requestedCalculationsName",
) as Writable<Set<CalculationName>> ) as Writable<Set<CalculationName>>
... ...
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import type { Writable } from "svelte/store" import type { Writable } from "svelte/store"
import type { CalculationName } from "$lib/decompositions" import type { CalculationName } from "$lib/decompositions"
import type { Reform, ReformChangeParameter } from "$lib/reforms" import type { ParametricReform, ValueParameterReform } from "$lib/reforms"
import { ReformChangeType } from "$lib/reforms" import { ReformChangeType } from "$lib/reforms"
import VariableReferredParameterHeader from "./VariableReferredParameterHeader.svelte" import VariableReferredParameterHeader from "./VariableReferredParameterHeader.svelte"
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
export let parameter: ValueParameter export let parameter: ValueParameter
let instantValueCouplesArray: [string, ValueAtInstant][] let instantValueCouplesArray: [string, ValueAtInstant][]
const reform = getContext("reform") as Writable<Reform> const reform = getContext("reform") as Writable<ParametricReform>
const requestedCalculationsName = getContext( const requestedCalculationsName = getContext(
"requestedCalculationsName", "requestedCalculationsName",
) as Writable<Set<CalculationName>> ) as Writable<Set<CalculationName>>
let validValue = undefined let validValue = undefined
let valueError = null let valueError = null
$: change = $reform[parameter.name] as ReformChangeParameter | undefined $: change = $reform[parameter.name] as ValueParameterReform | undefined
$: instantValueCouplesArray = Object.entries(parameter.values).sort( $: instantValueCouplesArray = Object.entries(parameter.values).sort(
([instant1], [instant2]) => instant2.localeCompare(instant1), ([instant1], [instant2]) => instant2.localeCompare(instant1),
... ...
......
import type { ScaleAtInstant } from "@openfisca/json-model" import type { ScaleAtInstant } from "@openfisca/json-model"
export interface Reform { export type ParameterReform = ValueParameterReform | ScaleParameterReform
[parameterName: string]: ReformChange
}
export type ReformChange = ReformChangeParameter | ReformChangeScale
export interface ReformChangeBase { export interface ParameterReformBase {
start: string start: string
stop?: string stop?: string
type: ReformChangeType type: ReformChangeType
} }
export interface ReformChangeParameter extends ReformChangeBase { export interface ParametricReform {
type: ReformChangeType.Parameter [parameterName: string]: ParameterReform
value: number
} }
export interface ReformChangeScale extends ReformChangeBase { export interface ScaleParameterReform extends ParameterReformBase {
type: ReformChangeType.Scale type: ReformChangeType.Scale
scale: ScaleAtInstant scale: ScaleAtInstant
} }
export interface ValueParameterReform extends ParameterReformBase {
type: ReformChangeType.Parameter
value: number
}
export enum ReformChangeType { export enum ReformChangeType {
Parameter = "parameter", Parameter = "parameter",
Scale = "scale", Scale = "scale",
... ...
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
waterfalls, waterfalls,
} from "$lib/decompositions" } from "$lib/decompositions"
import { entityByKey } from "$lib/entities" import { entityByKey } from "$lib/entities"
import type { Reform } from "$lib/reforms" import type { ParametricReform } from "$lib/reforms"
import type { Situation } from "$lib/situations" import type { Situation } from "$lib/situations"
import { import {
buildTestCasesWithoutNonInputVariables, buildTestCasesWithoutNonInputVariables,
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
) )
setContext("nonVirtualDecompositionsName", nonVirtualDecompositionsName) setContext("nonVirtualDecompositionsName", nonVirtualDecompositionsName)
let reformValue: Reform let reformValue: ParametricReform
if (browser) { if (browser) {
const reformJson = localStorage.getItem("reform") const reformJson = localStorage.getItem("reform")
if (reformJson !== null) { if (reformJson !== null) {
... ...
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
} from "$lib/decompositions" } from "$lib/decompositions"
import type { EditionMode } from "$lib/editions" import type { EditionMode } from "$lib/editions"
import { entityByKey } from "$lib/entities" import { entityByKey } from "$lib/entities"
import type { Reform } from "$lib/reforms" import type { ParametricReform } from "$lib/reforms"
import type { import type {
Axis, Axis,
PopulationWithoutId, PopulationWithoutId,
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
}> }>
> >
setContext("newSelfTargetAProps", newSelfTargetAProps) setContext("newSelfTargetAProps", newSelfTargetAProps)
const reform = getContext("reform") as Writable<Reform> const reform = getContext("reform") as Writable<ParametricReform>
const requestedCalculationsName = getContext( const requestedCalculationsName = getContext(
"requestedCalculationsName", "requestedCalculationsName",
) as Writable<Set<CalculationName>> ) as Writable<Set<CalculationName>>
... ...
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
import type { Writable } from "svelte/store" import type { Writable } from "svelte/store"
import { goto } from "$app/navigation" import { goto } from "$app/navigation"
import type { Reform } from "$lib/reforms" import type { ParametricReform } from "$lib/reforms"
import type { Situation } from "$lib/situations" import type { Situation } from "$lib/situations"
export let simulation: { reform: Reform; testCases: Situation[] } export let simulation: { reform: ParametricReform; testCases: Situation[] }
const reform = getContext("reform") as Writable<Reform> const reform = getContext("reform") as Writable<ParametricReform>
const testCases = getContext("testCases") as Writable<Situation[]> const testCases = getContext("testCases") as Writable<Situation[]>
onMount(() => { onMount(() => {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment