Skip to content

Commit

Permalink
handle checkbox (multi-selection) grid CSS and logic (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeArmani authored Jun 7, 2024
1 parent 272061e commit ec22434
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ActiveLogic.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ for bootstrap -xs
font-size: clamp(12px, 1.5vw, 16px);
}

.quest-grid.table-layout input[type="checkbox"],
.quest-grid.table-layout input[type="radio"] {
position: absolute;
opacity: 0;
Expand Down Expand Up @@ -241,6 +242,7 @@ for bootstrap -xs
background-color: transparent;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label::after,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label::after {
content: '';
display: block;
Expand All @@ -265,6 +267,7 @@ for bootstrap -xs
box-shadow: 0 0 .75vw #b3b3b3;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label {
border: none;
background-color: transparent;
Expand Down Expand Up @@ -345,6 +348,7 @@ for bootstrap -xs
color: #333;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label::after,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label::after {
display: none;
}
Expand All @@ -353,6 +357,7 @@ for bootstrap -xs
display: none;
}

.quest-grid.table-layout td input[type="checkbox"]:checked + .custom-label,
.quest-grid.table-layout td input[type="radio"]:checked + .custom-label {
position: absolute;
top: 0;
Expand Down
5 changes: 5 additions & 0 deletions Default.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ for bootstrap -xs
font-size: clamp(12px, 1.5vw, 16px);
}

.quest-grid.table-layout input[type="checkbox"],
.quest-grid.table-layout input[type="radio"] {
position: absolute;
opacity: 0;
Expand Down Expand Up @@ -175,6 +176,7 @@ for bootstrap -xs
background-color: transparent;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label::after,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label::after {
content: '';
display: block;
Expand All @@ -199,6 +201,7 @@ for bootstrap -xs
box-shadow: 0 0 .75vw #b3b3b3;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label {
border: none;
background-color: transparent;
Expand Down Expand Up @@ -279,6 +282,7 @@ for bootstrap -xs
color: #333;
}

.quest-grid.table-layout input[type="checkbox"]:checked + .custom-label::after,
.quest-grid.table-layout input[type="radio"]:checked + .custom-label::after {
display: none;
}
Expand All @@ -287,6 +291,7 @@ for bootstrap -xs
display: none;
}

.quest-grid.table-layout td input[type="checkbox"]:checked + .custom-label,
.quest-grid.table-layout td input[type="radio"]:checked + .custom-label {
position: absolute;
top: 0;
Expand Down
8 changes: 4 additions & 4 deletions questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,8 @@ export function displayQuestion(nextElement) {

questionQueue.ptree();

// manage the question-specific listeners
refreshListeners(nextElement);
// manage the question-specific listeners in a live environment (skip in the renderer)
if (moduleParams.renderObj?.activate) refreshListeners(nextElement);
return nextElement;
}

Expand Down Expand Up @@ -1467,7 +1467,7 @@ export function gridHasAllAnswers(questionFieldset) {
if (current.style.display=='none') return acc // skip hidden rows

let name = current.dataset.questionId
let currentResponses = Array.from(current.parentElement.querySelectorAll(`input[type="radio"][name="${name}"]`))
let currentResponses = Array.from(current.parentElement.querySelectorAll(`input[type="radio"][name="${name}"], input[type="checkbox"][name="${name}"]`))
return acc && currentResponses.some(checked)
},true)
}
Expand All @@ -1479,7 +1479,7 @@ export function numberOfUnansweredGridQuestions(questionFieldset) {
if (current.style.display=='none') return acc // skip hidden rows

let name = current.dataset.questionId
let currentResponses = Array.from(current.querySelectorAll(`input[type="radio"][name="${name}"]`));
let currentResponses = Array.from(current.querySelectorAll(`input[type="radio"][name="${name}"], input[type="checkbox"][name="${name}"]`));
return currentResponses.some(checked)?acc:(acc+1)
},0)
}
Expand Down

0 comments on commit ec22434

Please sign in to comment.