From 2c21bcabc1329013c597b99becac83023f30e5c6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 27 Jul 2023 12:45:41 +0300 Subject: [PATCH] Add survey.getProgressTypeComponent to remove code duplication in Creator (#6601) --- src/survey.ts | 3 +++ tests/surveytests.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/survey.ts b/src/survey.ts index b5ccfc59a4..b9a78c4c88 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -2481,6 +2481,9 @@ export class SurveyModel extends SurveyElementCore if (!this.canShowProresBar()) return false; return this.showProgressBar === "bottom" || this.showProgressBar === "both"; } + public getProgressTypeComponent(): string { + return "sv-progress-" + this.progressBarType.toLowerCase(); + } public getProgressCssClasses(): string { return new CssClassBuilder() .append(this.css.progress) diff --git a/tests/surveytests.ts b/tests/surveytests.ts index cfbb2a1c5f..f38e16732b 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -851,7 +851,9 @@ QUnit.test("progressText, 'requiredQuestions' type and design mode", function ( assert.equal(survey.progressText, "Page 1 of 4"); survey.progressBarType = "questions"; assert.equal(survey.progressText, "Answered 0/4 questions"); + assert.equal(survey.getProgressTypeComponent(), "sv-progress-questions", "questions component"); survey.progressBarType = "requiredQuestions"; + assert.equal(survey.getProgressTypeComponent(), "sv-progress-requiredquestions", "requiredQuestions component"); assert.equal(survey.progressText, "Answered 0/2 questions"); }); QUnit.test("progressText, 'requiredQuestions' type and required matrix dropdown, bug#5375", function (