Skip to main content
Homepage
Explore
Search or go to…
/
Register
Sign in
Explore
Primary navigation
Project
L
leximpact-socio-fiscal-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur socio-fiscal
leximpact-socio-fiscal-ui
Commits
df66a269
Commit
df66a269
authored
Dec 9, 2022
by
Emmanuel Raviart
Browse files
Options
Downloads
Patches
Plain Diff
Add compact & inline options to ValueChange
parent
046abf18
No related branches found
No related tags found
1 merge request
!90
Carte budget etat
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib/components/IrBudgetView.svelte
+7
-1
7 additions, 1 deletion
src/lib/components/IrBudgetView.svelte
src/lib/components/ValueChange.svelte
+37
-19
37 additions, 19 deletions
src/lib/components/ValueChange.svelte
src/lib/values.ts
+16
-6
16 additions, 6 deletions
src/lib/values.ts
with
60 additions
and
26 deletions
src/lib/components/IrBudgetView.svelte
+
7
−
1
View file @
df66a269
...
@@ -84,7 +84,8 @@
...
@@ -84,7 +84,8 @@
title=
"⚠️ Les dispositifs n'étant pas tous à jour, cette somme est à considérer avec prudence."
title=
"⚠️ Les dispositifs n'étant pas tous à jour, cette somme est à considérer avec prudence."
>
>
<ValueChange
<ValueChange
legend=
{
true
}
compact
legend
unitName=
"currency-EUR"
unitName=
"currency-EUR"
valueByCalculationName=
{
{
valueByCalculationName=
{
{
amendment
:
amendmentStateBudget
.
irpp
,
amendment
:
amendmentStateBudget
.
irpp
,
...
@@ -139,6 +140,8 @@
...
@@ -139,6 +140,8 @@
<!-- TODO use M€, etc -->
<!-- TODO use M€, etc -->
<span
class=
"text-xl font-bold"
<span
class=
"text-xl font-bold"
><ValueChange
><ValueChange
compact
inline
unitName=
"currency-EUR"
unitName=
"currency-EUR"
valueByCalculationName=
{
{
valueByCalculationName=
{
{
amendment
:
amendmentQuantile
.
irpp
,
amendment
:
amendmentQuantile
.
irpp
,
...
@@ -150,6 +153,7 @@
...
@@ -150,6 +153,7 @@
</p>
</p>
<p
class=
"text-xs text-gray-600"
>
<p
class=
"text-xs text-gray-600"
>
Soit
<ValueChange
Soit
<ValueChange
inline
unitName=
"/1"
unitName=
"/1"
valueByCalculationName=
{
{
valueByCalculationName=
{
{
amendment
:
amendmentQuantile
.
irpp
/
amendmentStateBudget
.
irpp
,
amendment
:
amendmentQuantile
.
irpp
/
amendmentStateBudget
.
irpp
,
...
@@ -167,6 +171,7 @@
...
@@ -167,6 +171,7 @@
En moyenne, un foyer de ce décile est prélevé de
<span
En moyenne, un foyer de ce décile est prélevé de
<span
class=
"text-xl font-bold"
class=
"text-xl font-bold"
><ValueChange
><ValueChange
inline
unitName=
"currency-EUR"
unitName=
"currency-EUR"
valueByCalculationName=
{
{
valueByCalculationName=
{
{
amendment
:
amendmentQuantile
.
irpp
/
amendmentQuantile
.
count
,
amendment
:
amendmentQuantile
.
irpp
/
amendmentQuantile
.
count
,
...
@@ -179,6 +184,7 @@
...
@@ -179,6 +184,7 @@
<p
class=
"text-xs text-gray-600"
>
<p
class=
"text-xs text-gray-600"
>
<!-- TODO: Remplacer lawQuantile.rfr par lawQuantile.rfr_moyen (ie lawQuantile.rfr_total / lawQuantile.count ) -->
<!-- TODO: Remplacer lawQuantile.rfr par lawQuantile.rfr_moyen (ie lawQuantile.rfr_total / lawQuantile.count ) -->
Soit
<ValueChange
Soit
<ValueChange
inline
unitName=
"/1"
unitName=
"/1"
valueByCalculationName=
{
{
valueByCalculationName=
{
{
amendment
:
amendment
:
...
...
...
...
This diff is collapsed.
Click to expand it.
src/lib/components/ValueChange.svelte
+
37
−
19
View file @
df66a269
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
import
{
valueFormatter
}
from
"
$lib/values
"
import
{
valueFormatter
}
from
"
$lib/values
"
import
type
{
VariableValueByCalculationName
}
from
"
$lib/variables
"
import
type
{
VariableValueByCalculationName
}
from
"
$lib/variables
"
export
let
compact
=
false
// For example: 1,2 Md €
export
let
inline
=
false
export
let
legend
=
false
export
let
unitName
:
string
|
undefined
|
null
export
let
unitName
:
string
|
undefined
|
null
export
let
valueByCalculationName
:
VariableValueByCalculationName
export
let
valueByCalculationName
:
VariableValueByCalculationName
export
let
legend
=
false
$
:
amendmentValue
=
valueByCalculationName
.
amendment
as
number
|
undefined
$
:
amendmentValue
=
valueByCalculationName
.
amendment
as
number
|
undefined
...
@@ -19,7 +21,7 @@
...
@@ -19,7 +21,7 @@
:
billValue
:
billValue
:
lawValue
:
lawValue
$
:
format
=
valueFormatter
(
baseValue
,
unitName
)
$
:
format
=
valueFormatter
(
baseValue
,
unitName
,
compact
)
$
:
amendmentValueFormatted
=
$
:
amendmentValueFormatted
=
amendmentValue
===
undefined
?
undefined
:
format
(
amendmentValue
)
amendmentValue
===
undefined
?
undefined
:
format
(
amendmentValue
)
...
@@ -56,39 +58,55 @@
...
@@ -56,39 +58,55 @@
</script>
</script>
{
#if
showLawValue
}
{
#if
showLawValue
}
<
div
class
=
"flex flex-col"
>
<
span
class
:block=
{
!
inline
}
>
<
div
<
span
class=
{
showBillValue
class=
{
showBillValue
?
"
line-through-bill
"
?
"
line-through-bill
"
:
showAmendmentValue
:
showAmendmentValue
?
"
line-through-amendment
"
?
"
line-through-amendment
"
:
""
}
:
""
}
class:block=
{
!
inline
}
>
>
{
lawValueFormatted
}
{
lawValueFormatted
}
</div>
</span>
{
#if
legend
}
<div
class=
"text-xs font-normal"
>
{
#if
legend
}
<span
class=
"text-xs font-normal"
class:block=
{
!
inline
}
>
(Droit
en
vigueur)
(Droit
en
vigueur)
</div>
{
/if
}
</span>
</div>
{
/if
}
</span>
{
/if
}
{
/if
}
{
#if
showBillValue
}
{
#if
showBillValue
}
<
div
>
<
span
class:block=
{
!
inline
}
>
<
div
<
span
class=
" text-le-rouge-bill"
class=
" text-le-rouge-bill"
class:block=
{
!
inline
}
class:line-through-amendment=
{
showAmendmentValue
}
class:line-through-amendment=
{
showAmendmentValue
}
>
>
{
billValueFormatted
}
{
billValueFormatted
}
</div>
</span>
{
#if
legend
}
<div
class=
"text-xs font-normal text-le-rouge-bill"
>
{
#if
legend
}
<span
class=
"text-xs font-normal text-le-rouge-bill"
class:block=
{
!
inline
}
>
(PLF/PLFSS)
(PLF/PLFSS)
</div>
{
/if
}
</span>
</div>
{
/if
}
</span>
{
/if
}
{
/if
}
{
#if
showAmendmentValue
}
{
#if
showAmendmentValue
}
<div>
<span
class:block=
{
!
inline
}
>
<div
class=
"bg-le-jaune px-1 text-black"
>
{
amendmentValueFormatted
}
</div>
<span
class=
"bg-le-jaune px-1 text-black"
class:block=
{
!
inline
}
>
{
#if
legend
}
<div
class=
"text-xs font-normal text-le-jaune-dark"
>
{
amendmentValueFormatted
}
</span>
{
#if
legend
}
<span
class=
"text-xs font-normal text-le-jaune-dark"
class:block=
{
!
inline
}
>
(Votre
réforme)
(Votre
réforme)
</div>
{
/if
}
</span>
</div>
{
/if
}
</span>
{
/if
}
{
/if
}
This diff is collapsed.
Click to expand it.
src/lib/values.ts
+
16
−
6
View file @
df66a269
...
@@ -5,6 +5,7 @@ export function formatValue(value: number, unitName?: string): string {
...
@@ -5,6 +5,7 @@ export function formatValue(value: number, unitName?: string): string {
export
function
valueFormatter
(
export
function
valueFormatter
(
baseValue
:
unknown
,
baseValue
:
unknown
,
unitName
?:
string
|
undefined
|
null
,
unitName
?:
string
|
undefined
|
null
,
compact
:
boolean
=
false
,
):
(
value
:
unknown
)
=>
string
{
):
(
value
:
unknown
)
=>
string
{
return
baseValue
===
undefined
return
baseValue
===
undefined
?
((()
=>
""
)
as
(
value
:
unknown
)
=>
string
)
?
((()
=>
""
)
as
(
value
:
unknown
)
=>
string
)
...
@@ -20,7 +21,16 @@ export function valueFormatter(
...
@@ -20,7 +21,16 @@ export function valueFormatter(
style
:
"
percent
"
,
style
:
"
percent
"
,
}).
format
as
(
value
:
unknown
)
=>
string
)
}).
format
as
(
value
:
unknown
)
=>
string
)
:
unitName
!=
null
&&
unitName
.
startsWith
(
"
currency-
"
)
:
unitName
!=
null
&&
unitName
.
startsWith
(
"
currency-
"
)
?
(
new
Intl
.
NumberFormat
(
"
fr-FR
"
,
{
?
compact
?
(
value
:
unknown
):
string
=>
new
Intl
.
NumberFormat
(
"
fr-FR
"
,
{
currency
:
unitName
.
replace
(
/^currency-/
,
""
),
maximumFractionDigits
:
2
,
minimumFractionDigits
:
0
,
notation
:
"
compact
"
,
// Example: 3,2 Md €
style
:
"
currency
"
,
}).
format
(
Math
.
round
(
value
as
number
))
:
(
new
Intl
.
NumberFormat
(
"
fr-FR
"
,
{
currency
:
unitName
.
replace
(
/^currency-/
,
""
),
currency
:
unitName
.
replace
(
/^currency-/
,
""
),
maximumFractionDigits
:
0
,
maximumFractionDigits
:
0
,
minimumFractionDigits
:
0
,
minimumFractionDigits
:
0
,
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment