Skip to content

Commit

Permalink
If there is a unique error in a cell then detail panel is opened fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jul 5, 2024
1 parent f37ee3f commit 3488610
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2127,14 +2127,17 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
private showDuplicatedErrorsInRows(duplicatedRows: Array<MatrixDropdownRowModelBase>, columnName: string): void {
duplicatedRows.forEach(row => {
let question = row.getQuestionByName(columnName);
if(!question && this.detailPanel.getQuestionByName(columnName)) {
const inDetailPanel = this.detailPanel.getQuestionByName(columnName);
if(!question && inDetailPanel) {
row.showDetailPanel();
if(row.detailPanel) {
question = row.detailPanel.getQuestionByName(columnName);
}
}
if(question) {
row.showDetailPanel();
if(inDetailPanel) {
row.showDetailPanel();
}
this.addDuplicationError(question);
}
});
Expand Down
27 changes: 27 additions & 0 deletions tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,33 @@ QUnit.test("Matrixdynamic duplicationError in detailPanel", function (assert) {
matrix.value = [{ column1: "val1" }, { column1: "val2" }];
assert.equal(matrix.hasErrors(), false, "There is no errors, row[0].column1=val1 and row[1].column2=val2");
});
QUnit.test("Matrixdynamic duplicationError and no errors in detailPanel, do not expand panels", function (assert) {
var matrix = new QuestionMatrixDynamicModel("matrixDymanic");
matrix.rowCount = 2;
matrix.columns.push(new MatrixDropdownColumn("column1"));
matrix.columns.push(new MatrixDropdownColumn("column2"));
matrix.detailPanelMode = "underRow";
matrix.detailPanel.addNewQuestion("text", "col_q1");
matrix.columns[0].isUnique = true;
assert.equal(matrix.hasErrors(), false, "No errors");
matrix.value = [{ column1: "val1" }, {}];
assert.equal(
matrix.hasErrors(),
false,
"There is no errors, row[0].column1=val1"
);
const rows = matrix.visibleRows;
assert.equal(rows[0].isDetailPanelShowing, false, "detail panel row0 is showing, #1");
assert.equal(rows[1].isDetailPanelShowing, false, "detail panel row1 is showing, #2");
rows[1].getQuestionByName("column1").value = "val1";
assert.equal(
matrix.hasErrors(),
true,
"There is the error, row[0].column1=val1 and row[1].column2=val1"
);
assert.equal(rows[0].isDetailPanelShowing, false, "detail panel row0 is showing, #3");
assert.equal(rows[1].isDetailPanelShowing, false, "detail panel row1 is showing, #4");
});

QUnit.test("Matrixdynamic: remove duplicationError in cells and in detailPanels", function (assert) {
var matrix = new QuestionMatrixDynamicModel("matrixDymanic");
Expand Down

0 comments on commit 3488610

Please sign in to comment.