-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work for surveyjs/survey-creator#3390: implement ranking item wrapper
- Loading branch information
Showing
4 changed files
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
packages/survey-angular-ui/src/questions/ranking.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<div [class]="model.rootClass" #contentElement> | ||
<sv-ng-ranking-item | ||
*ngFor="let item of model.rankingChoices; index as index; trackBy: trackItemBy" | ||
[index]="index" | ||
[question]="model" | ||
[model]="item" | ||
></sv-ng-ranking-item> | ||
<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> |
14 changes: 11 additions & 3 deletions
14
packages/survey-angular-ui/src/questions/ranking.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import { Component } from "@angular/core"; | ||
import { QuestionAngular } from "../question"; | ||
import { ItemValue, QuestionRankingModel } from "survey-core"; | ||
import { AngularComponentFactory } from "../component-factory"; | ||
import { SelectBaseComponent } from "./selectbase.component"; | ||
|
||
@Component({ | ||
selector: "sv-ng-ranking-question", | ||
templateUrl: "./ranking.component.html", | ||
}) | ||
export class RankingQuestionComponent extends QuestionAngular<QuestionRankingModel> { | ||
export class RankingQuestionComponent extends SelectBaseComponent<QuestionRankingModel> { | ||
public override inputType: string = ""; | ||
trackItemBy = (index: number, item: ItemValue): string => { | ||
return item.value + "-" + index + "-item"; | ||
} | ||
public override getDefaultComponentName(): string { | ||
return "sv-ng-ranking-item"; | ||
} | ||
public override getItemValueComponentData(item: ItemValue, index?: number): any { | ||
const res = super.getItemValueComponentData(item); | ||
res.componentData.index = index; | ||
return res; | ||
} | ||
} | ||
|
||
AngularComponentFactory.Instance.registerComponent("ranking-question", RankingQuestionComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters