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

Matrix Dynamic: Rename allowRowsDragAndDrop fix #5106 #9237

Merged
merged 3 commits into from
Jan 7, 2025
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
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
Loading