Skip to content

Commit

Permalink
Work for surveyjs/survey-creator#3390 - added wrapper for question co…
Browse files Browse the repository at this point in the history
…ntent
  • Loading branch information
tsv2013 committed Oct 4, 2022
1 parent 3f84a32 commit aa0b041
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/survey-angular-ui/src/question.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<div [element]="model" *ngIf="model.hasTitleOnLeftTop" sv-ng-element-header></div>
<div [class]="model.cssContent" role="presentation" [visible]="!model.isCollapsed">
<div *ngIf="model.showErrorOnTop && model.hasVisibleErrors" [element]="model" sv-ng-errors></div>
<ng-template [component]="{ name: getComponentName(), data: { model }, default: 'skeleton-question' }" ></ng-template>
<ng-template [component]="{ name: getQuestionContentWrapperComponentName(), data: getQuestionContentWrapperComponentData(), default: 'skeleton-question' }">
</ng-template>
<div *ngIf="model.hasComment" [class]="model.cssClasses.formGroup">
<div>{{ model.commentText }}</div>
<div [question]="model" sv-ng-comment></div>
Expand Down
14 changes: 13 additions & 1 deletion packages/survey-angular-ui/src/question.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class QuestionComponent extends EmbeddedViewContentComponent {
return this.model;
}
ngAfterViewInit(): void {
if(!!this.rootEl?.nativeElement) {
if (!!this.rootEl?.nativeElement) {
this.model.afterRender(this.rootEl?.nativeElement);
}
}
Expand All @@ -25,6 +25,18 @@ export class QuestionComponent extends EmbeddedViewContentComponent {
}
return this.model.getComponentName();
}
public getQuestionContentWrapperComponentName(): string {
return (<any>this.model.survey).getQuestionContentWrapperComponentName(this.model) || this.getComponentName();
}
public getQuestionContentWrapperComponentData(): any {
return {
componentName: this.getComponentName(),
componentData: {
model: this.model,
data: (<any>this.model.survey).getElementWrapperComponentData(this.model)
}
};
}
}

AngularComponentFactory.Instance.registerComponent("question", QuestionComponent);

0 comments on commit aa0b041

Please sign in to comment.