Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
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
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur socio-fiscal
leximpact-socio-fiscal-ui
Commits
a19bee41
Commit
a19bee41
authored
Nov 10, 2022
by
Emmanuel Raviart
Browse files
Options
Downloads
Patches
Plain Diff
Use name ranges for rows
parent
1a8c434c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#7082
failed
Nov 23, 2022
Stage: build
Changes
1
Pipelines
3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/routes/variables/[variable]/xlsx/+page.svelte
+40
-36
40 additions, 36 deletions
src/routes/variables/[variable]/xlsx/+page.svelte
with
40 additions
and
36 deletions
src/routes/variables/[variable]/xlsx/+page.svelte
+
40
−
36
View file @
a19bee41
...
...
@@ -255,6 +255,7 @@
[
personId
:
string
]:
number
}
}
=
{}
const
refByName
:
{
[
name
:
string
]:
string
}
=
{}
const
roleByGroupEntityKeyByPersonIdBySituationIndex
:
{
[
situationIndex
:
number
]:
{
[
personId
:
string
]:
{
[
groupEntityKey
:
string
]:
string
}
...
...
@@ -340,17 +341,15 @@
let
table
=
tableByEntityKey
[
entityKey
]
if
(
table
===
undefined
)
{
const
entity
=
entityByKey
[
entityKey
]
const
header
:
string
[]
=
[
"
C
as
type
"
,
"
D
escription
"
,
"
N
om
"
]
const
header
:
string
[]
=
[
"
uid
"
,
"
c
as
_
type
"
,
"
d
escription
"
,
"
n
om
"
]
if
(
entity
.
is_person
)
{
for
(
const
[
groupEntityKey
,
groupEntity
]
of
Object
.
entries
(
entityByKey
,
).
sort
(([
key1
],
[
key2
])
=>
key1
.
localeCompare
(
key2
)))
{
if
(
!
groupEntity
.
is_person
)
{
header
.
push
(
g
ro
upEntityKey
,
`Rô
le
dans
${
groupEntityKey
}
`
)
header
.
push
(
`
role
_
dans
_
${
groupEntityKey
}
`
)
}
}
}
else
{
header
.
push
(
"
Membres
"
)
}
table
=
tableByEntityKey
[
entityKey
]
=
[
header
]
for
(
const
[
situationIndex
,
situation
]
of
$testCases
.
entries
())
{
...
...
@@ -364,33 +363,32 @@
personIndexByIdBySituationIndex
[
situationIndex
]
const
roleByGroupEntityKeyByPersonId
=
roleByGroupEntityKeyByPersonIdBySituationIndex
[
situationIndex
]
for
(
const
populationId
of
Object
.
keys
(
entitySituation
).
sort
(
(
populationId1
,
populationId2
)
=>
for
(
const
[
populationIndex
,
populationId
]
of
Object
.
keys
(
entitySituation
,
)
.
sort
((
populationId1
,
populationId2
)
=>
populationId1
.
localeCompare
(
populationId2
),
))
{
)
.
entries
())
{
const
uid
=
`cas_type_
${
situationIndex
+
1
}
_
${
entityKey
}
_
${
populationIndex
+
1
}
`
const
row
:
unknown
[]
=
[
uid
,
situation
.
title
??
`Cas type n°
${
situationIndex
+
1
}
`
,
situation
.
description
,
populationId
,
]
if
(
entity
.
is_person
)
{
const
personIndex
=
personIndexById
[
populationId
]
refByName
[
uid
]
=
`
${
entityKey
}
!$
${
personIndex
+
1
}
:$
${
personIndex
+
1
}
`
for
(
const
[
groupEntityKey
,
groupEntity
]
of
Object
.
entries
(
entityByKey
,
).
sort
(([
key1
],
[
key2
])
=>
key1
.
localeCompare
(
key2
)))
{
if
(
!
groupEntity
.
is_person
)
{
const
groupInfosById
=
groupInfosByIdByEntityKey
[
groupEntityKey
]
const
groupInfos
=
Object
.
values
(
groupInfosById
).
find
(
(
groupInfos
)
=>
groupInfos
.
personsId
.
includes
(
populationId
),
)
const
groupRange
=
`$
${
groupEntityKey
}
.
${
groupInfos
.
groupIndex
+
1
}
:
${
groupInfos
.
groupIndex
+
1
}
`
row
.
push
(
{
f
:
groupRange
,
v
:
groupRange
,
},
roleByGroupEntityKeyByPersonId
[
populationId
][
groupEntityKey
],
...
...
@@ -398,22 +396,19 @@
}
}
}
else
{
const
groupInfosById
=
groupInfosByIdByEntityKey
[
entityKey
]
// TODO: Add sheet, etc to each member row reference.
const
membersDisjointRange
=
groupInfosById
[
populationId
].
personsId
const
groupInfos
=
groupInfosByIdByEntityKey
[
entityKey
][
populationId
]
refByName
[
uid
]
=
`
${
entityKey
}
!$
${
groupInfos
.
groupIndex
+
1
}
:$
${
groupInfos
.
groupIndex
+
1
}
`
refByName
[
`
${
uid
}
_membres`
]
=
groupInfos
.
personsId
.
map
((
personId
)
=>
{
const
personIndex
=
personIndexById
[
personId
]
return
`$
$
{
personEntityKey
}
.
${
personIndex
+
1
}
:
${
return
`
${
personEntityKey
}
!$
${
personIndex
+
1
}
:$
$
{
personIndex
+
1
}
`
})
.
join
(
"
:
"
)
row
.
push
({
f
:
membersDisjointRange
,
v
:
membersDisjointRange
,
})
}
table
.
push
(
row
)
}
...
...
@@ -550,21 +545,30 @@
for
(
const
[
columnIndex
,
cell
]
of
table
[
0
].
entries
())
{
const
variableNameWithPeriod
=
typeof
cell
===
"
string
"
?
cell
:
(
cell
as
{
v
:
string
}).
v
const
vectorRange
=
XLSX
.
utils
.
encode_range
({
s
:
{
c
:
columnIndex
,
r
:
1
},
e
:
{
c
:
columnIndex
,
r
:
table
.
length
-
1
},
})
// Use variable name to name vector in sheet..
// Use variable name to name vector in sheet.
workbook
.
Workbook
.
Names
.
push
({
// Comment:
Name
:
variableNameWithPeriod
,
Ref
:
`
${
entityKey
}
!
${
vectorRange
}
`
,
Ref
:
`
${
entityKey
}
!$
${
XLSX
.
utils
.
encode_col
(
columnIndex
,
)}
$
${
XLSX
.
utils
.
encode_row
(
1
)}
:$
${
XLSX
.
utils
.
encode_col
(
columnIndex
,
)}
$
${
XLSX
.
utils
.
encode_row
(
table
.
length
-
1
)}
`
,
Sheet
:
null
,
})
}
}
// Add rows-related named ranges.
for
(
const
[
name
,
ref
]
of
Object
.
entries
(
refByName
))
{
workbook
.
Workbook
.
Names
.
push
({
// Comment:
Name
:
name
,
Ref
:
ref
,
Sheet
:
null
,
})
}
XLSX
.
writeFile
(
workbook
,
`leximpact_
${
requestedVariableName
}
_
${
$year
}
.xlsx`
,
...
...
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