Skip to content

Commit

Permalink
work for the #5328 (api rename)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Jun 16, 2023
1 parent d77194f commit dfc9763
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div *ngIf="!model.selectToRank" [class]="model.rootClass" #contentElement>
<div *ngIf="!model.selectToRankEnabled" [class]="model.rootClass" #contentElement>
<ng-container *ngFor="let item of model.rankingChoices; index as index; trackBy: trackItemBy">
<ng-template [component]="{ name: getItemValueComponentName(item), data: getItemValueComponentData(item, index) }"></ng-template>
</ng-container>
</div>

<div *ngIf="model.selectToRank" [class]="model.rootClass" #contentElement>
<div *ngIf="model.selectToRankEnabled" [class]="model.rootClass" #contentElement>
<div [class]='model.getContainerClasses("from")' data-ranking="from-container">
<ng-container *ngFor="let item of model.unRankingChoices; index as index; trackBy: trackItemBy">
<ng-template [component]="{ name: getItemValueComponentName(item), data: getItemValueComponentData(item, index, true) }"></ng-template>
Expand Down
4 changes: 2 additions & 2 deletions src/dragdrop/ranking-select-to-rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class DragDropRankingSelectToRank extends DragDropRankingChoices {
} else {
toIndex = rankingChoices.indexOf(this.dropTarget);
}
this.selectToRank(questionModel, fromIndex, toIndex);
this.selectToRankEnabled(questionModel, fromIndex, toIndex);
this.doUIEffects(dropTargetNode, fromIndex, toIndex);
return;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ export class DragDropRankingSelectToRank extends DragDropRankingChoices {
return !this.isDropTargetRanked;
}

public selectToRank(questionModel: QuestionRankingModel, fromIndex: number, toIndex: number): void {
public selectToRankEnabled(questionModel: QuestionRankingModel, fromIndex: number, toIndex: number): void {
const rankingChoices = questionModel.rankingChoices;
const unRankingChoices = questionModel.unRankingChoices;
const item = unRankingChoices[fromIndex];
Expand Down
4 changes: 2 additions & 2 deletions src/knockout/templates/question-ranking.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/html" id="survey-question-ranking">
<!-- ko ifnot: question.selectToRank -->
<!-- ko ifnot: question.selectToRankEnabled -->
<div data-bind="css: question.rootClass">
<!-- ko foreach: { data: question.rankingChoices, as: 'item', afterRender: question.koAfterRender } -->
<!-- ko component: { name: question.getItemValueWrapperComponentName(item), params: { componentData: question.getItemValueWrapperComponentData(item), templateData: { name: 'survey-ranking-item', data: item } } } -->
Expand All @@ -8,7 +8,7 @@
</div>
<!-- /ko -->

<!-- ko if: question.selectToRank -->
<!-- ko if: question.selectToRankEnabled -->
<div data-bind="css: question.rootClass">
<div data-bind="css: question.getContainerClasses('from')" data-ranking="from-container">
<!-- ko foreach: { data: question.unRankingChoices, as: 'item', afterRender: question.koAfterRender } -->
Expand Down
42 changes: 21 additions & 21 deletions src/question_ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
.append(this.cssClasses.rootDesignMode, !!this.isDesignMode)
.append(this.cssClasses.itemOnError, this.errors.length > 0)
.append(this.cssClasses.rootDragHandleAreaIcon, settings.rankingDragHandleArea === "icon")
.append(this.cssClasses.rootSelectToRankMod, this.selectToRank)
.append(this.cssClasses.rootSelectToRankAlignHorizontal, this.selectToRank && this.selectToRankAlign === "horizontal")
.append(this.cssClasses.rootSelectToRankAlignVertical, this.selectToRank && this.selectToRankAlign === "vertical")
.append(this.cssClasses.rootSelectToRankMod, this.selectToRankEnabled)
.append(this.cssClasses.rootSelectToRankAlignHorizontal, this.selectToRankEnabled && this.selectToRankAreasLayout === "horizontal")
.append(this.cssClasses.rootSelectToRankAlignVertical, this.selectToRankEnabled && this.selectToRankAreasLayout === "vertical")
.toString();
}

Expand Down Expand Up @@ -103,7 +103,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
public getItemIndexClasses(item: ItemValue) {
let noNumber;

if (this.selectToRank) {
if (this.selectToRankEnabled) {
noNumber = this.unRankingChoices.indexOf(item) !== -1;
} else {
noNumber = this.isEmpty();
Expand Down Expand Up @@ -147,7 +147,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
return;
}

if (this.selectToRank) {
if (this.selectToRankEnabled) {
this.updateRankingChoices();
return;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
}

private updateRankingChoices(forceUpdate = false): ItemValue[] {
if (this.selectToRank) {
if (this.selectToRankEnabled) {
this.updateRankingChoicesSelectToRankMode(forceUpdate);
return;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
endLoadingFromJson(): void {
super.endLoadingFromJson();

if (this.selectToRank) {
if (this.selectToRankEnabled) {
this.dragDropRankingChoices = new DragDropRankingSelectToRank(this.survey, null, this.longTap);
} else {
this.dragDropRankingChoices = new DragDropRankingChoices(this.survey, null, this.longTap);
Expand Down Expand Up @@ -308,7 +308,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
const key: any = event.key;
let index = this.rankingChoices.indexOf(choice);

if (this.selectToRank) {
if (this.selectToRankEnabled) {
this.handleKeydownSelectToRank(event, choice);
return;
}
Expand Down Expand Up @@ -371,7 +371,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
if (key === " " && isMovedElementUnRanked) {
fromIndex = unRankingChoices.indexOf(movedElement);
toIndex = 0;
dnd.selectToRank(this, fromIndex, toIndex);
dnd.selectToRankEnabled(this, fromIndex, toIndex);
this.setValueAfterKeydown(toIndex, "to-container");
return;
}
Expand Down Expand Up @@ -416,7 +416,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
}

private focusItem = (index: number, container?: string) => {
if (this.selectToRank && container) {
if (this.selectToRankEnabled && container) {
const containerSelector = "[data-ranking='" + container + "']";
const itemsNodes: any = this.domNode.querySelectorAll(
containerSelector + " " + "." + this.cssClasses.item
Expand Down Expand Up @@ -470,15 +470,15 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
*
* Default value: `false`
*/
public get selectToRank(): boolean {
return this.getPropertyValue("selectToRank", false);
public get selectToRankEnabled(): boolean {
return this.getPropertyValue("selectToRankEnabled", false);
}
public set selectToRank(val: boolean) {
this.setPropertyValue("selectToRank", val);
public set selectToRankEnabled(val: boolean) {
this.setPropertyValue("selectToRankEnabled", val);
}

/**
* Set alignment for the selectToRank mode
* Set alignment for the selectToRankEnabled mode
*
* Possible values:
*
Expand All @@ -487,11 +487,11 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
*
* Default value: `horizontal`
*/
public get selectToRankAlign(): string {
return this.getPropertyValue("selectToRankAlign", "horizontal");
public get selectToRankAreasLayout(): string {
return this.getPropertyValue("selectToRankAreasLayout", "horizontal");
}
public set selectToRankAlign(val: string) {
this.setPropertyValue("selectToRankAlign", val);
public set selectToRankAreasLayout(val: string) {
this.setPropertyValue("selectToRankAreasLayout", val);
}

@property({ localizable: { defaultStr: "selectToRankFromContainerPlaceholder" } }) selectToRankFromContainerPlaceholder: string;
Expand Down Expand Up @@ -526,13 +526,13 @@ Serializer.addClass(
isSerializable: false,
},
{
name: "selectToRank",
name: "selectToRankEnabled",
default: false,
visible: false,
isSerializable: true,
},
{
name: "selectToRankAlign",
name: "selectToRankAreasLayout",
default: "horizontal",
visible: false,
isSerializable: true,
Expand Down
2 changes: 1 addition & 1 deletion src/react/reactquestion_ranking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SurveyQuestionRanking extends SurveyQuestionElementBase {

protected renderElement(): JSX.Element {

if (!this.question.selectToRank) {
if (!this.question.selectToRankEnabled) {
return (
<div
className={this.question.rootClass}
Expand Down
8 changes: 4 additions & 4 deletions src/vue/ranking/ranking.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="question.rootClass">
<survey-ranking-item v-if="!question.selectToRank"
<survey-ranking-item v-if="!question.selectToRankEnabled"
v-for="(item, index) in (question.rankingChoices)"
:key="item.value + '-' + index + '-item'"
:class="question.getItemClass(item)"
Expand All @@ -12,7 +12,7 @@
:item="item"
></survey-ranking-item>

<div v-if="question.selectToRank" :class='question.getContainerClasses("from")' data-ranking="from-container">
<div v-if="question.selectToRankEnabled" :class='question.getContainerClasses("from")' data-ranking="from-container">
<survey-ranking-item
v-for="(item, index) in (question.unRankingChoices)"
:key="item.value + '-' + index + '-item'"
Expand All @@ -29,9 +29,9 @@
<div v-if="question.unRankingChoices.length === 0" :class="question.cssClasses.containerPlaceholder"> {{question.selectToRankFromContainerPlaceholder}} </div>
</div>

<div v-if="question.selectToRank" :class="question.cssClasses.containersDivider"></div>
<div v-if="question.selectToRankEnabled" :class="question.cssClasses.containersDivider"></div>

<div v-if="question.selectToRank" :class='question.getContainerClasses("to")' data-ranking="to-container">
<div v-if="question.selectToRankEnabled" :class='question.getContainerClasses("to")' data-ranking="to-container">
<survey-ranking-item
v-for="(item, index) in (question.rankingChoices)"
:key="item.value + '-' + index + '-item'"
Expand Down
10 changes: 5 additions & 5 deletions tests/dragdrophelpertests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ QUnit.test("createImagePickerShortcut", function (assert) {
assert.equal(result2.querySelectorAll("img").length, 1);
});

// SelectToRank
// selectToRankEnabled
function createRankingQuestionModel(withDefaultValue = false) {
const json = {
"selectToRank": true,
"selectToRankEnabled": true,
"choices": [
"11",
"22",
Expand All @@ -264,11 +264,11 @@ function createRankingQuestionModel(withDefaultValue = false) {
return model;
}

QUnit.test("DragDropRankingSelectToRank : selectToRank", function (assert) {
QUnit.test("DragDropRankingSelectToRank : selectToRankEnabled", function (assert) {
const dndModel = new DragDropRankingSelectToRank();
const questionModel = createRankingQuestionModel();

dndModel.selectToRank(questionModel, 1, 0);
dndModel.selectToRankEnabled(questionModel, 1, 0);
assert.equal(questionModel.unRankingChoices.length, 2, "unRankingChoices count");
assert.equal(questionModel.rankingChoices.length, 1, "rankingChoices count");
});
Expand All @@ -293,4 +293,4 @@ QUnit.test("DragDropRankingSelectToRank reorderRankedItem", function (assert) {
assert.equal(questionModel.rankingChoices[1].value, "33", "item 2 is correct");
assert.equal(questionModel.rankingChoices.length, 2, "rankingChoices count");
});
// EO SelectToRank
// EO selectToRankEnabled
14 changes: 7 additions & 7 deletions tests/markup/etalon_ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ registerMarkupTests(
snapshot: "ranking-design",
},
{
name: "Ranking selectToRank empty",
name: "Ranking selectToRankEnabled empty",
json: {
questions: [
{
"type": "ranking",
"name": "name",
"selectToRank": true,
"selectToRankEnabled": true,
"title": "Question title",
"choices": [
"item1",
Expand All @@ -59,17 +59,17 @@ registerMarkupTests(
}
]
},
snapshot: "ranking-selecttorank-empty",
snapshot: "ranking-selectToRankEnabled-empty",
},
{
name: "Ranking selectToRank selectToRankAlign Vertical",
name: "Ranking selectToRankEnabled selectToRankAreasLayout Vertical",
json: {
questions: [
{
"type": "ranking",
"name": "name",
"selectToRank": true,
"selectToRankAlign": "vertical",
"selectToRankEnabled": true,
"selectToRankAreasLayout": "vertical",
"title": "Question title",
"choices": [
"item1",
Expand All @@ -80,7 +80,7 @@ registerMarkupTests(
}
]
},
snapshot: "ranking-selecttorank-vertical",
snapshot: "ranking-selectToRankEnabled-vertical",
},
]
);
22 changes: 11 additions & 11 deletions tests/question_ranking_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ QUnit.test("Ranking: items visibleIf and value, Bug#5959", function(assert) {
assert.equal(q2.rankingChoices.length, 2, "2 items are shown");
});

// SelectToRank
function createRankingQuestionModel(selectToRank = false, withDefaultValue = false) {
// selectToRankEnabled
function createRankingQuestionModel(selectToRankEnabled = false, withDefaultValue = false) {
const json = {
"choices": [
"11",
Expand All @@ -326,8 +326,8 @@ function createRankingQuestionModel(selectToRank = false, withDefaultValue = fal
]
};

if (selectToRank) {
json["selectToRank"] = true;
if (selectToRankEnabled) {
json["selectToRankEnabled"] = true;
}

if (withDefaultValue) {
Expand All @@ -339,18 +339,18 @@ function createRankingQuestionModel(selectToRank = false, withDefaultValue = fal
return model;
}

QUnit.test("selectToRank : initial", function (assert) {
const selectToRank = true;
const questionModel = createRankingQuestionModel(selectToRank);
QUnit.test("selectToRankEnabled : initial", function (assert) {
const selectToRankEnabled = true;
const questionModel = createRankingQuestionModel(selectToRankEnabled);
assert.equal(questionModel.unRankingChoices.length, 3, "unRankingChoices count");
assert.equal(questionModel.rankingChoices.length, 0, "rankingChoices count");
});

QUnit.test("selectToRank : defaultValue", function (assert) {
const selectToRank = true;
QUnit.test("selectToRankEnabled : defaultValue", function (assert) {
const selectToRankEnabled = true;
const withDefaultValue = true;
const questionWithDefaultValueModel = createRankingQuestionModel(selectToRank, withDefaultValue);
const questionWithDefaultValueModel = createRankingQuestionModel(selectToRankEnabled, withDefaultValue);
assert.equal(questionWithDefaultValueModel.unRankingChoices.length, 1, "unRankingChoices count");
assert.equal(questionWithDefaultValueModel.rankingChoices.length, 2, "rankingChoices count");
});
// EO SelectToRank
// EO selectToRankEnabled
10 changes: 5 additions & 5 deletions visualRegressionTests/tests/defaultV2/ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ frameworks.forEach(framework => {
});
});

test("Check ranking question selectToRank", async (t) => {
test("Check ranking question selectToRankEnabled", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1920, 1080);
await initSurvey(framework, {
Expand All @@ -88,15 +88,15 @@ frameworks.forEach(framework => {
title: "Tell me about a time you strongly disagreed with your manager. What did you do to convince him or her that you were right? What happened?",
name: "ranking_question",
choices: ["item1", "item2", "item3", "item4"],
selectToRank: true
selectToRankEnabled: true
}
]
});
await takeElementScreenshot("question-ranking-select-to-rank.png", Selector(".sd-question"), t, comparer);
});
});

test("Check ranking question selectToRank vertical mode", async (t) => {
test("Check ranking question selectToRankEnabled vertical mode", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1920, 1080);
await initSurvey(framework, {
Expand All @@ -107,8 +107,8 @@ frameworks.forEach(framework => {
title: "Tell me about a time you strongly disagreed with your manager. What did you do to convince him or her that you were right? What happened?",
name: "ranking_question",
choices: ["item1", "item2", "item3", "item4"],
selectToRank: true,
selectToRankAlign: "vertical"
selectToRankEnabled: true,
selectToRankAreasLayout: "vertical"
}
]
});
Expand Down

0 comments on commit dfc9763

Please sign in to comment.