Skip to content

Commit

Permalink
Matrix Dynamic: Rename allowRowsDragAndDrop fix #5106 (#9237)
Browse files Browse the repository at this point in the history
* Matrix Dynamic: Rename allowRowsDragAndDrop fix #5106

* Update the deprecation message

---------

Co-authored-by: RomanTsukanov <[email protected]>
  • Loading branch information
andrewtelnov and RomanTsukanov authored Jan 7, 2025
1 parent d2fbde2 commit 436e870
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 15 additions & 5 deletions packages/survey-core/src/question_matrixdynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase
this.createLocalizableString("removeRowText", this, false, "removeRow");
this.createLocalizableString("emptyRowsText", this, false, true);
this.registerPropertyChangedHandlers(["hideColumnsIfEmpty", "allowAddRows"], () => { this.updateShowTableAndAddRow(); });
this.registerPropertyChangedHandlers(["allowRowsDragAndDrop", "isReadOnly", "lockedRowCount"], () => { this.resetRenderedTable(); });
this.registerPropertyChangedHandlers(["allowRowReorder", "isReadOnly", "lockedRowCount"], () => { this.resetRenderedTable(); });
this.registerPropertyChangedHandlers(["minRowCount"], () => { this.onMinRowCountChanged(); });
this.registerPropertyChangedHandlers(["maxRowCount"], () => { this.onMaxRowCountChanged(); });
this.dragOrClickHelper = new DragOrClickHelper(this.startDragMatrixRow);
Expand Down Expand Up @@ -301,14 +301,24 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase
*
* Default value: `false`
*/
public get allowRowReorder(): boolean {
return this.getPropertyValue("allowRowReorder");
}
public set allowRowReorder(val: boolean) {
this.setPropertyValue("allowRowReorder", val);
}
/**
* Obsolete. Use the [`allowRowReorder`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model#allowRowReorder) property instead.
* @deprecated
*/
public get allowRowsDragAndDrop(): boolean {
return this.getPropertyValue("allowRowsDragAndDrop");
return this.allowRowReorder;
}
public set allowRowsDragAndDrop(val: boolean) {
this.setPropertyValue("allowRowsDragAndDrop", val);
this.allowRowReorder = val;
}
public get isRowsDragAndDrop(): boolean {
return this.allowRowsDragAndDrop && !this.isReadOnly;
return this.allowRowReorder && !this.isReadOnly;
}
public get lockedRowCount(): number {
return this.getPropertyValue("lockedRowCount", 0);
Expand Down Expand Up @@ -1057,7 +1067,7 @@ Serializer.addClass(
return obj.detailPanelMode !== "none";
},
},
"allowRowsDragAndDrop:switch"
{ name: "allowRowReorder:switch", alternativeName: "allowRowsDragAndDrop" },
],
function() {
return new QuestionMatrixDynamicModel("");
Expand Down
10 changes: 5 additions & 5 deletions packages/survey-core/tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8176,7 +8176,7 @@ QUnit.test("Drag handler cell in rendered table", function (assert) {
);
});

QUnit.test("allowRowsDragAndDrop with readOnly", function (assert) {
QUnit.test("allowRowReorder with readOnly", function (assert) {
var survey = new SurveyModel({
elements: [
{
Expand All @@ -8194,14 +8194,14 @@ QUnit.test("allowRowsDragAndDrop with readOnly", function (assert) {
assert.equal(matrix.renderedTable.isRowsDragAndDrop, true, "#2");
});

QUnit.test("allowRowsDragAndDrop &mode=display", function (assert) {
QUnit.test("allowRowReorder &mode=display", function (assert) {
const survey = new SurveyModel({
mode: "display",
elements: [
{
type: "matrixdynamic",
name: "matrix",
allowRowsDragAndDrop: true,
allowRowReorder: true,
columns: ["col1"]
},
],
Expand Down Expand Up @@ -8773,13 +8773,13 @@ QUnit.test("Load old JSON where columns without cellType set correctly", functio
assert.deepEqual(cellQuestion.choices.length, 4, "load 4 choices");
assert.equal(cellQuestion.choices[2].value, "c", "load choices correctly");
});
QUnit.test("Vertical column layout & allowRowsDragAndDrop, rendered table", function (assert) {
QUnit.test("Vertical column layout & allowRowReorder, rendered table", function (assert) {
var survey = new SurveyModel({
"elements": [
{
"type": "matrixdynamic",
"name": "matrix",
"allowRowsDragAndDrop": true,
"allowRowReorder": true,
"columnLayout": "vertical",
columns: [
{ cellType: "text", name: "col1" },
Expand Down

0 comments on commit 436e870

Please sign in to comment.