Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Knockout] Multi-Select Matrix - The totalText property doesn't work … #7397

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/defaultCss/defaultV2Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ export var defaultV2Css = {
rowHasEndActions: "sd-table__row--has-end-actions",
headerCell: "sd-table__cell sd-table__cell--header",
rowTextCell: "sd-table__cell sd-table__cell--row-text",
footerCell: "sd-table__cell sd-table__cell--footer",
footerTotalCell: "sd-table__cell sd-table__cell--footer-total",
columnTitleCell: "sd-table__cell--column-title",
cellRequiredText: "sd-question__required-text",
detailButton: "sd-table__cell--detail-button",
Expand Down Expand Up @@ -480,6 +482,7 @@ export var defaultV2Css = {
itemCell: "sd-table__cell--item",
headerCell: "sd-table__cell sd-table__cell--header",
rowTextCell: "sd-table__cell sd-table__cell--row-text",
footerCell: "sd-table__cell sd-table__cell--footer",
columnTitleCell: "sd-table__cell--column-title",
cellRequiredText: "sd-question__required-text",
button: "sd-action sd-matrixdynamic__btn",
Expand Down
9 changes: 9 additions & 0 deletions src/defaultV2-theme/blocks/sd-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@
}
}

.sd-table__cell--footer {
text-align: right;
}

.sd-table__cell--footer-total {
font-weight: 600;
text-align: left;
}

.sd-table__cell--detail-panel {
border-top: calcSize(1) solid transparent;
padding: calcSize(3) calcSize(1) calcSize(4);
Expand Down
7 changes: 5 additions & 2 deletions src/knockout/templates/question-matrixdynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<!-- /ko -->
</div>
<!-- /ko -->
<!-- ko ifnot: $data.matrix -->
<!-- ko if: $data.locTitle -->
<!-- ko template: { name: 'survey-string', data: $data.locTitle } --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</td>
</script>
<script type="text/html" id="survey-matrixtable">
Expand Down Expand Up @@ -172,9 +177,7 @@
<tfoot>
<tr>
<!-- ko foreach: question.koTable().footerRow.cells -->

<!-- ko template: { name: 'survey-matrixcell', afterRender: function(els) { $data.matrix && $data.matrix.koCellAfterRender(els, $data); } } --><!-- /ko -->

<!-- /ko -->
</tr>
</tfoot>
Expand Down
9 changes: 6 additions & 3 deletions src/question_matrixdropdownrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,10 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
this.footerRow.cells.push(this.createHeaderCell(null, "action"));
}
if (this.matrix.hasRowText) {
this.footerRow.cells.push(
this.createTextCell(this.matrix.getFooterText())
);
const cell = this.createTextCell(this.matrix.getFooterText());
cell.className = new CssClassBuilder().append(cell.className)
.append(this.cssClasses.footerTotalCell).toString();
this.footerRow.cells.push(cell);
}
var cells = this.matrix.visibleTotalRow.cells;
for (var i = 0; i < cells.length; i++) {
Expand All @@ -467,6 +468,8 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
if (cell.column) {
this.setHeaderCellWidth(cell.column, editCell);
}
editCell.className = new CssClassBuilder().append(editCell.className)
.append(this.cssClasses.footerCell).toString();
this.footerRow.cells.push(editCell);
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 48 additions & 1 deletion visualRegressionTests/tests/defaultV2/matrixdynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ frameworks.forEach(framework => {
});
});

test("Check Matrixdynamic with showInMultipleColumns", async (t) => {
test("Check matrixdropdown with showInMultipleColumns", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1280, 1100);
await initSurvey(framework, {
Expand Down Expand Up @@ -302,4 +302,51 @@ frameworks.forEach(framework => {
await takeElementScreenshot("matrixdynamic-with-totals.png", matrixdynamicRoot, t, comparer);
});
});
test("Check Matrixdropdown with totals", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1280, 1100);
await initSurvey(framework, {
showQuestionNumbers: "off",
elements: [
{
"type": "matrixdropdown",
"name": "question1",
"columns": [
{
"name": "col1",
"cellType": "text",
"inputType": "number",
"defaultValueExpression": "{rowIndex}",
"totalType": "sum"
},
{
"name": "col2",
"cellType": "text",
"inputType": "number",
"defaultValueExpression": "{rowIndex} + 5",
"totalType": "sum"
},
{
"name": "col3",
"cellType": "text",
"inputType": "number",
"defaultValueExpression": "{rowIndex} + 10",
"totalType": "sum"
}
],
"rows": [
"Row 1",
"Row 2",
"Row 3"
],
"totalText": "Total:"
}
]
});

const matrixdynamicRoot = Selector(".sd-question");
await resetFocusToBody();
await takeElementScreenshot("matrixdropdown-with-totals.png", matrixdynamicRoot, t, comparer);
});
});
});