Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ELC_elections
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gestion-des-assemblees
ELC_elections
Commits
87b71a53
Commit
87b71a53
authored
4 years ago
by
Alexis POYEN
Browse files
Options
Downloads
Patches
Plain Diff
Refactor : split flow in an other file
parent
707b0cf6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/components/visualization/results-flow.js
+108
-0
108 additions, 0 deletions
web/components/visualization/results-flow.js
web/components/visualization/results-zone.js
+4
-90
4 additions, 90 deletions
web/components/visualization/results-zone.js
with
112 additions
and
90 deletions
web/components/visualization/results-flow.js
0 → 100644
+
108
−
0
View file @
87b71a53
// Imports
import
*
as
Auth
from
"
/services/auth/auth.js
"
;
import
*
as
PartyModel
from
"
/services/model/party-model.js
"
;
import
*
as
CandidateListModel
from
"
/services/model/candidateList-model.js
"
;
import
*
as
AreaModel
from
"
/services/model/area-model.js
"
;
import
*
as
Scroller
from
"
/services/common/scroller.js
"
;
import
*
as
Common
from
"
/services/common/common.js
"
;
export
async
function
mount
(
parent
)
{
const
flowComponent
=
new
FlowComponent
(
parent
);
return
flowComponent
;
}
class
FlowComponent
{
constructor
(
parent
)
{
this
.
parent
=
parent
;
this
.
PartyModel
=
PartyModel
.
getPartyModel
();
this
.
AreaModel
=
AreaModel
.
getAreaModel
();
}
resultFlowTemplate
(
zone
)
{
let
resultHandler
=
this
;
let
html
=
document
.
createElement
(
"
div
"
);
html
.
classList
=
"
card-list card-no-hover
"
;
html
.
innerHTML
=
/* HTML */
`
<div class="card-content clickable">
<div id="flow-content-
${
zone
.
ID
}
" class="content">
<h5 class="title is-5">
${
zone
.
Name
}
</h5>
</div>
</div>
`
;
html
.
addEventListener
(
"
click
"
,
async
()
=>
{
if
(
this
.
parent
.
parent
.
zone
==
"
sections
"
)
{
let
area
=
await
this
.
AreaModel
.
getArea
(
zone
.
AreaID
);
this
.
parent
.
refreshSections
(
area
);
document
.
getElementById
(
"
select-sections
"
).
value
=
zone
.
ID
;
document
.
getElementById
(
"
select-areas
"
).
value
=
zone
.
AreaID
;
resultHandler
.
areaDisplayed
=
area
;
resultHandler
.
sectionDisplayed
=
area
.
Sections
[
0
];
}
else
{
document
.
getElementById
(
"
select-areas
"
).
value
=
zone
.
ID
;
resultHandler
.
areaDisplayed
=
area
;
}
this
.
parent
.
displayZoneResults
(
zone
);
});
return
html
;
}
async
displayFlowAreas
()
{
let
areasResults
=
this
.
parent
.
parent
.
results
.
areasResults
;
areasResults
.
sort
(
function
(
a
,
b
)
{
return
b
.
DateCompletion
-
a
.
DateCompletion
;
});
for
(
let
j
in
areasResults
)
{
let
area
=
areasResults
[
j
];
if
(
area
.
status
===
this
.
parent
.
parent
.
filter
)
{
document
.
getElementById
(
"
news-flow
"
)
.
appendChild
(
this
.
resultFlowTemplate
(
area
));
for
(
let
i
in
area
.
candidateLists
)
{
let
party
=
await
this
.
PartyModel
.
getParty
(
area
.
candidateLists
[
i
].
PartyID
);
document
.
getElementById
(
"
flow-content-
"
+
area
.
ID
).
innerHTML
+=
await
this
.
parent
.
parent
.
progressBarTemplate
(
area
.
candidateLists
[
i
],
party
.
Color
);
}
}
}
}
async
displayFlowSections
()
{
let
sections
=
[];
this
.
parent
.
parent
.
results
.
areasResults
.
forEach
((
area
)
=>
{
sections
=
sections
.
concat
(
area
.
Sections
);
});
sections
.
sort
(
function
(
a
,
b
)
{
return
b
.
DateCompletion
-
a
.
DateCompletion
;
});
for
(
let
j
in
sections
)
{
let
section
=
sections
[
j
];
if
(
section
.
status
===
this
.
parent
.
parent
.
filter
)
{
document
.
getElementById
(
"
news-flow
"
)
.
appendChild
(
this
.
resultFlowTemplate
(
section
));
for
(
let
i
in
section
.
candidateLists
)
{
let
party
=
await
this
.
PartyModel
.
getParty
(
section
.
candidateLists
[
i
].
PartyID
);
document
.
getElementById
(
"
flow-content-
"
+
section
.
ID
).
innerHTML
+=
await
this
.
parent
.
parent
.
progressBarTemplate
(
section
.
candidateLists
[
i
],
party
.
Color
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
web/components/visualization/results-zone.js
+
4
−
90
View file @
87b71a53
...
...
@@ -5,6 +5,7 @@ import * as CandidateListModel from "/services/model/candidateList-model.js";
import
*
as
AreaModel
from
"
/services/model/area-model.js
"
;
import
*
as
Scroller
from
"
/services/common/scroller.js
"
;
import
*
as
Common
from
"
/services/common/common.js
"
;
import
*
as
ResultsFlow
from
"
/components/visualization/results-flow.js
"
;
export
async
function
mount
(
where
,
parent
)
{
const
resultZoneComponent
=
new
ResultZoneComponent
(
parent
);
...
...
@@ -88,6 +89,7 @@ class ResultZoneComponent {
</div>
</div>
`
;
this
.
ResultsFlow
=
await
ResultsFlow
.
mount
(
this
);
this
.
scroller
=
Scroller
.
scrollInit
(
"
news-flow
"
,
document
.
getElementById
(
"
auto-scroll
"
)
...
...
@@ -95,34 +97,6 @@ class ResultZoneComponent {
this
.
handleDom
();
}
resultFlowTemplate
(
zone
)
{
let
resultHandler
=
this
;
let
html
=
document
.
createElement
(
"
div
"
);
html
.
classList
=
"
card-list card-no-hover
"
;
html
.
innerHTML
=
/* HTML */
`
<div class="card-content clickable">
<div id="flow-content-
${
zone
.
ID
}
" class="content">
<h5 class="title is-5">
${
zone
.
Name
}
</h5>
</div>
</div>
`
;
html
.
addEventListener
(
"
click
"
,
async
()
=>
{
if
(
this
.
parent
.
zone
==
"
sections
"
)
{
let
area
=
await
this
.
AreaModel
.
getArea
(
zone
.
AreaID
);
this
.
refreshSections
(
area
);
document
.
getElementById
(
"
select-sections
"
).
value
=
zone
.
ID
;
document
.
getElementById
(
"
select-areas
"
).
value
=
zone
.
AreaID
;
resultHandler
.
areaDisplayed
=
area
;
resultHandler
.
sectionDisplayed
=
area
.
Sections
[
0
];
}
else
{
document
.
getElementById
(
"
select-areas
"
).
value
=
zone
.
ID
;
resultHandler
.
areaDisplayed
=
area
;
}
this
.
displayZoneResults
(
zone
);
});
return
html
;
}
handleDom
()
{
let
resultHandler
=
this
;
document
.
getElementById
(
"
zoom-map
"
).
addEventListener
(
"
click
"
,
function
()
{
...
...
@@ -271,74 +245,14 @@ class ResultZoneComponent {
async
displayResults
()
{
document
.
getElementById
(
"
news-flow
"
).
innerHTML
=
""
;
if
(
this
.
parent
.
zone
===
"
areas
"
)
{
await
this
.
displayFlowAreas
();
await
this
.
ResultsFlow
.
displayFlowAreas
();
this
.
displayAreasResults
();
}
else
if
(
this
.
parent
.
zone
===
"
sections
"
)
{
await
this
.
displayFlowSections
();
await
this
.
ResultsFlow
.
displayFlowSections
();
this
.
displaySectionsResults
();
}
}
async
displayFlowAreas
()
{
this
.
parent
.
results
.
areasResults
.
sort
(
function
(
a
,
b
)
{
return
b
.
DateCompletion
-
a
.
DateCompletion
;
});
for
(
let
j
in
this
.
parent
.
results
.
areasResults
)
{
let
area
=
this
.
parent
.
results
.
areasResults
[
j
];
if
(
area
.
status
===
this
.
parent
.
filter
)
{
document
.
getElementById
(
"
news-flow
"
)
.
appendChild
(
this
.
resultFlowTemplate
(
area
));
for
(
let
i
in
area
.
candidateLists
)
{
let
party
=
await
this
.
PartyModel
.
getParty
(
area
.
candidateLists
[
i
].
PartyID
);
document
.
getElementById
(
"
flow-content-
"
+
area
.
ID
).
innerHTML
+=
await
this
.
parent
.
progressBarTemplate
(
area
.
candidateLists
[
i
],
party
.
Color
);
}
}
}
}
async
displayFlowSections
()
{
let
sections
=
[];
this
.
parent
.
results
.
areasResults
.
forEach
((
area
)
=>
{
sections
=
sections
.
concat
(
area
.
Sections
);
});
sections
.
sort
(
function
(
a
,
b
)
{
return
b
.
DateCompletion
-
a
.
DateCompletion
;
});
for
(
let
j
in
sections
)
{
let
section
=
sections
[
j
];
if
(
section
.
status
===
this
.
parent
.
filter
)
{
document
.
getElementById
(
"
news-flow
"
)
.
appendChild
(
this
.
resultFlowTemplate
(
section
));
for
(
let
i
in
section
.
candidateLists
)
{
let
party
=
await
this
.
PartyModel
.
getParty
(
section
.
candidateLists
[
i
].
PartyID
);
document
.
getElementById
(
"
flow-content-
"
+
section
.
ID
).
innerHTML
+=
await
this
.
parent
.
progressBarTemplate
(
section
.
candidateLists
[
i
],
party
.
Color
);
}
}
}
}
displayAreasResults
()
{
this
.
refreshAreas
();
document
.
getElementById
(
"
select-sections
"
).
parentNode
.
style
.
display
=
...
...
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