Skip to content

Commit

Permalink
Work for surveyjs/survey-creator#3390: add wrapper for panel in panel…
Browse files Browse the repository at this point in the history
…dynamic (#4931)
  • Loading branch information
dk981234 committed Sep 30, 2022
1 parent 1943701 commit 214e56b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- add track by [key]="panel.id" -->
<ng-container *ngFor="let panel of renderedPanels; index as index">
<div [class]="model.getPanelWrapperCss()">
<sv-ng-panel [model]="panel"></sv-ng-panel>
<ng-template [component]="{ name: getPanelComponentName(panel), data: getPanelComponentData(panel) }"></ng-template>
<ng-container *ngTemplateOutlet="removeBtn; context: { panel }"></ng-container>
</div>
<!-- add track by [key]="'separator' + panel.id" -->
Expand Down
27 changes: 25 additions & 2 deletions packages/survey-angular-ui/src/questions/paneldynamic.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { QuestionAngular } from "../question";
import { PanelModel, QuestionPanelDynamicModel } from "survey-core";
import { PanelModel, QuestionPanelDynamicModel, SurveyModel } from "survey-core";
import { AngularComponentFactory } from "../component-factory";

@Component({
Expand Down Expand Up @@ -39,7 +39,30 @@ export class PanelDynamicQuestionComponent extends QuestionAngular<QuestionPanel
this.model.renderModeChangedCallback = () => {};
super.ngOnDestroy();
}

public getPanelComponentName(panel: PanelModel): string {
const survey = this.surveyModel as SurveyModel;
if(!!survey) {
const name = survey.getElementWrapperComponentName(panel);
if(!!name) {
return name;
}
}
return "panel";
}
public getPanelComponentData(panel: PanelModel): any {
const survey = this.surveyModel as SurveyModel;
let data: any;
if(!!survey) {
data = survey.getElementWrapperComponentData(panel);
}
return {
componentName: "panel",
componentData: {
model: panel,
data: data
}
};
}
}

AngularComponentFactory.Instance.registerComponent("paneldynamic-question", PanelDynamicQuestionComponent);

0 comments on commit 214e56b

Please sign in to comment.