Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MACAO Hugo
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
MACAO
MACAO Hugo
Commits
25d029a8
Commit
25d029a8
authored
Jul 8, 2024
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Fix Clear button not working with custom question
parent
76d38242
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
macao/assets/gapfill-select.js
+15
-1
15 additions, 1 deletion
macao/assets/gapfill-select.js
with
15 additions
and
1 deletion
macao/assets/gapfill-select.js
+
15
−
1
View file @
25d029a8
...
@@ -51,11 +51,25 @@ export const gapfillSelectWidget = {
...
@@ -51,11 +51,25 @@ export const gapfillSelectWidget = {
optionElem
.
innerText
=
opt
;
optionElem
.
innerText
=
opt
;
segmentElem
.
appendChild
(
optionElem
);
segmentElem
.
appendChild
(
optionElem
);
}
}
// Add
listener
to update the question's value when the selector's value changes
// Add
callback
to update the question's value when the selector's value changes
segmentElem
.
addEventListener
(
"
change
"
,
(
e
)
=>
{
segmentElem
.
addEventListener
(
"
change
"
,
(
e
)
=>
{
// The select node knows its index, therefore is able to update the question value at the correct index
// The select node knows its index, therefore is able to update the question value at the correct index
question
.
value
[
parseInt
(
e
.
target
.
getAttribute
(
"
data-index
"
))]
=
e
.
target
.
value
;
question
.
value
[
parseInt
(
e
.
target
.
getAttribute
(
"
data-index
"
))]
=
e
.
target
.
value
;
});
});
// Add callback to update the DOM nodes when the question's value changes
question
.
valueChangedCallback
=
()
=>
{
const
gaps
=
question
.
wrapperElement
.
querySelectorAll
(
"
#gapfill-container select
"
);
if
(
question
.
value
instanceof
Array
&&
question
.
value
.
length
===
gaps
.
length
)
{
for
(
const
i
in
question
.
value
)
{
gaps
[
i
].
value
=
question
.
value
[
i
];
}
}
else
{
// Unknown value -> reset all fields
for
(
const
gap
of
gaps
)
{
gap
.
value
=
undefined
;
}
}
}
nbGaps
++
;
nbGaps
++
;
}
}
// Add segment
// Add segment
...
...
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