-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR: Ranking - Support the
itemComponent
setting and allow developer…
…s to create a custom item template (#8306) * work for the #8284 * work for the #8284 * work for the #8284 * work for the #8284 * work for the #8284 * work for the #8284 * work for the #8284 * work for the #8284 * work for the https://github.com/surveyjs/survey-library/issues/8284work for the #8209 * work for the #8284 * work for the #8284 * work for the #8284
- Loading branch information
1 parent
ed6b812
commit 0dbc06d
Showing
28 changed files
with
241 additions
and
20 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
6 changes: 6 additions & 0 deletions
6
packages/survey-angular-ui/example/src/app/components/itemContentTemplateComponent.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ng-template #template> | ||
<div class="sv-ranking-item__text" style="display: flex; align-items: center; gap: 8px;"> | ||
<svg [iconName]="'icon-next_16x16'" [size]="'16'" sv-ng-svg-icon></svg> | ||
<sv-ng-string [model]="item.locText"></sv-ng-string> | ||
</div> | ||
</ng-template> |
15 changes: 15 additions & 0 deletions
15
packages/survey-angular-ui/example/src/app/components/itemContentTemplateComponent.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { AngularComponentFactory, EmbeddedViewContentComponent } from "survey-angular-ui"; | ||
import { ItemValue } from "survey-core"; | ||
|
||
@Component({ | ||
selector: "sv-new-item-content", | ||
templateUrl: "./itemContentTemplateComponent.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class AngularItemContentTemplateComponent extends EmbeddedViewContentComponent { | ||
@Input() item!: ItemValue; | ||
@Input() cssClasses: any; | ||
} | ||
|
||
AngularComponentFactory.Instance.registerComponent("new-item-content", AngularItemContentTemplateComponent); |
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
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
5 changes: 5 additions & 0 deletions
5
packages/survey-angular-ui/src/questions/ranking-item-content.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ng-template #template> | ||
<div [class]="cssClasses.controlLabel"> | ||
<sv-ng-string [model]="item.locText"></sv-ng-string> | ||
</div> | ||
</ng-template> |
15 changes: 15 additions & 0 deletions
15
packages/survey-angular-ui/src/questions/ranking-item-content.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { ItemValue } from "survey-core"; | ||
import { AngularComponentFactory } from "../component-factory"; | ||
import { EmbeddedViewContentComponent } from "../embedded-view-content.component"; | ||
|
||
@Component({ | ||
selector: "sv-ranking-item-content", | ||
templateUrl: "./ranking-item-content.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class RankingItemContentComponent extends EmbeddedViewContentComponent { | ||
@Input() item!: ItemValue; | ||
@Input() cssClasses: any; | ||
} | ||
AngularComponentFactory.Instance.registerComponent("sv-ranking-item-content", RankingItemContentComponent); |
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
10 changes: 10 additions & 0 deletions
10
packages/survey-vue3-ui/example/src/components/test/test-custom-components/ItemContent.vue
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div class="sv-ranking-item__text" :style="{display: 'flex', alignItems: 'center', gap: '8px'}"> | ||
<sv-svg-icon iconName="icon-next_16x16" size = "16"></sv-svg-icon> | ||
<survey-string :locString="item.locText" /> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import type { ItemValue } from 'survey-core'; | ||
defineProps<{ item: ItemValue, cssClasses: any }>() | ||
</script> |
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<template> | ||
<div :class="cssClasses.controlLabel"> | ||
<survey-string :locString="item.locText" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { ItemValue } from "survey-core"; | ||
defineOptions({ inheritAttrs: false }); | ||
const props = defineProps<{ | ||
item: ItemValue; | ||
cssClasses: any; | ||
}>(); | ||
</script> |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div data-bind="css: cssClasses.controlLabel"> | ||
<!-- ko template: { name: 'survey-string', data: item.locText } --> | ||
<!-- /ko --> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as ko from "knockout"; | ||
|
||
const template = require("./item-content.html"); | ||
|
||
export var RankingItemContenViewModel: any; | ||
|
||
ko.components.register("sv-ranking-item-content", { | ||
viewModel: { | ||
createViewModel: (params: any, componentInfo: any) => { | ||
return params; | ||
}, | ||
}, | ||
template: template, | ||
}); |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<div :class="cssClasses.controlLabel"> | ||
<survey-string :locString="item.locText" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
import { Component, Prop } from "vue-property-decorator"; | ||
import { ItemValue } from "survey-core"; | ||
@Component | ||
export class RankingItemContent extends Vue { | ||
@Prop() item: ItemValue; | ||
@Prop() cssClasses: any | ||
} | ||
Vue.component("sv-ranking-item-content", RankingItemContent); | ||
export default RankingItemContent; | ||
</script> |
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
Oops, something went wrong.