Skip to content

Commit

Permalink
Matrix: Rename isUniqueCaseSensitive to useCaseSensitiveComparison fi… (
Browse files Browse the repository at this point in the history
#9253)

* Matrix: Rename isUniqueCaseSensitive to useCaseSensitiveComparison fix #5079

* Add a deprecation message

---------

Co-authored-by: RomanTsukanov <[email protected]>
  • Loading branch information
andrewtelnov and RomanTsukanov authored Jan 7, 2025
1 parent b45bc1b commit 6ec2269
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 15 additions & 5 deletions packages/survey-core/src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
for (var i = 0; i < colNames.length; i++) matrix.addColumn(colNames[i]);
}
private detailPanelValue: PanelModel;
private isUniqueCaseSensitiveValue: boolean;
private useCaseSensitiveComparisonValue: boolean;
protected isRowChanging = false;
columnsChangedCallback: () => void;
onRenderedTableResetCallback: () => void;
Expand Down Expand Up @@ -1110,11 +1110,21 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
* Default value: `false`
* @see keyDuplicationError
*/
public get useCaseSensitiveComparison(): boolean {
return this.useCaseSensitiveComparisonValue !== undefined ? this.useCaseSensitiveComparisonValue : settings.comparator.caseSensitive;
}
public set useCaseSensitiveComparison(val: boolean) {
this.useCaseSensitiveComparisonValue = val;
}
/**
* Obsolete. Use the [`useCaseSensitiveComparison`](#useCaseSensitiveComparison) property instead.
* @deprecated
*/
public get isUniqueCaseSensitive(): boolean {
return this.isUniqueCaseSensitiveValue !== undefined ? this.isUniqueCaseSensitiveValue : settings.comparator.caseSensitive;
return this.useCaseSensitiveComparison;
}
public set isUniqueCaseSensitive(val: boolean) {
this.isUniqueCaseSensitiveValue = val;
this.useCaseSensitiveComparison = val;
}
/**
* Specifies the location of detail sections.
Expand Down Expand Up @@ -1703,7 +1713,7 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
* An error message displayed when users enter a duplicate value into a column that accepts only unique values (`isUnique` is set to `true` or `keyName` is specified).
*
* A default value for this property is taken from a [localization dictionary](https://github.com/surveyjs/survey-library/tree/01bd8abd0c574719956d4d579d48c8010cd389d4/packages/survey-core/src/localization). Refer to the following help topic for more information: [Localization & Globalization](https://surveyjs.io/form-library/documentation/localization).
* @see isUniqueCaseSensitive
* @see useCaseSensitiveComparison
*/
public get keyDuplicationError(): string {
return this.getLocalizableStringText("keyDuplicationError");
Expand Down Expand Up @@ -2210,7 +2220,7 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
val = !!rowVal ? rowVal[columnName] : undefined;
}
if(!this.isValueEmpty(val)) {
if(!this.isUniqueCaseSensitive && typeof val === "string") {
if(!this.useCaseSensitiveComparison && typeof val === "string") {
val = val.toLocaleLowerCase();
}
if(!keyValues[val]) {
Expand Down
8 changes: 4 additions & 4 deletions packages/survey-core/tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,17 @@ QUnit.test("column.isUnique, support settings.comparator.caseSensitive", functio
"There is ann error, abc!=Abc case-sensitive"
);
settings.comparator.caseSensitive = false;
question.isUniqueCaseSensitive = false;
question.useCaseSensitiveComparison = false;
assert.equal(
question.hasErrors(),
true,
"There is an error, abc=Abc case-in-sensitive, isUniqueCaseSensitive = false"
"There is an error, abc=Abc case-in-sensitive, useCaseSensitiveComparison = false"
);
question.isUniqueCaseSensitive = true;
question.useCaseSensitiveComparison = true;
assert.equal(
question.hasErrors(),
false,
"There is ann error, abc!=Abc case-sensitive, isUniqueCaseSensitive = false"
"There is ann error, abc!=Abc case-sensitive, useCaseSensitiveComparison = false"
);
});
QUnit.test("Matrixdynamic duplicationError in detailPanel", function (assert) {
Expand Down

0 comments on commit 6ec2269

Please sign in to comment.