Skip to content

Commit

Permalink
Work for #5551 - Implement TOC navigation - fixed vr-tests - header/f…
Browse files Browse the repository at this point in the history
…ooter containers rendering - no wrapper now
  • Loading branch information
tsv2013 committed Feb 27, 2023
1 parent ae7562f commit a3cfa5d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 13 deletions.
15 changes: 11 additions & 4 deletions packages/survey-angular-ui/src/components-container.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<ng-template #template>
<div *ngIf="components.length > 0" class="sv-components-column">
<ng-container *ngFor="let component of components">
<ng-template [component]="{ name: component.component, data: { survey: survey, model: component.data } }"></ng-template>
<ng-container *ngIf="isNeedRenderWrapper">
<div *ngIf="components.length > 0" class="sv-components-column">
<ng-container *ngFor="let component of components">
<ng-template [component]="{ name: component.component, data: { survey: survey, model: component.data } }"></ng-template>
</ng-container>
</div>
</ng-container>
<ng-container *ngIf="!isNeedRenderWrapper && components.length > 0">
<ng-container *ngFor="let component of components">
<ng-template [component]="{ name: component.component, data: { survey: survey, model: component.data } }"></ng-template>
</ng-container>
</ng-container>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import { EmbeddedViewContentComponent } from "./embedded-view-content.component"
export class ComponentsContainerComponent extends EmbeddedViewContentComponent {
@Input() survey!: SurveyModel;
@Input() container!: string;
@Input() needRenderWrapper?: boolean;
get components(): Array<any> {
return this.survey.getContainerContent(this.container as any);
}
get isNeedRenderWrapper(): boolean {
return this.needRenderWrapper === false ? false : true;
}
}
AngularComponentFactory.Instance.registerComponent("sv-components-container", ComponentsContainerComponent);
4 changes: 2 additions & 2 deletions packages/survey-angular-ui/src/survey-content.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="sv_custom_header" [hidden]="model.hasLogo"></div>
<div [class]="model.css.container">
<div *ngIf="model.renderedHasHeader" [class]="model.css.header" [survey]="model" sv-ng-survey-header></div>
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'header' } }"></ng-template>
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'header', needRenderWrapper: false } }"></ng-template>
<!-- <ng-container *ngIf="model.isTimerPanelShowingOnTop && !model.isShowStartingPage">
<sv-timerpanel [model]="model.timerModel"></sv-timerpanel>
</ng-container> -->
Expand Down Expand Up @@ -36,7 +36,7 @@
<!-- <ng-container *ngIf="model.isTimerPanelShowingOnBottom && !model.isShowStartingPage">
<sv-timerpanel [model]="model.timerModel"></sv-timerpanel>
</ng-container> -->
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'footer' } }"></ng-template>
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'footer', needRenderWrapper: false } }"></ng-template>
<div *ngIf="model.state === 'completed' && model.showCompletedPage" [class]="model.completedCss"
[innerHtml]="model.processedCompletedHtml"></div>
<div *ngIf="model.state === 'completedbefore'" [class]="model.css.body"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- ko if: components.length > 0 -->
<!-- ko if: $data.needRenderWrapper -->
<div data-bind="css: css">
<!-- ko foreach: components -->
<!-- ko if: $data.component && !$data.template -->
Expand All @@ -9,6 +10,19 @@
<!-- ko template: { name: template, data: $data.data } -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</div>
<!-- /ko -->
<!-- ko ifnot: $data.needRenderWrapper -->
<!-- ko foreach: components -->
<!-- ko if: $data.component && !$data.template -->
<!-- ko component: { name: component, params: { survey: $parent.survey, model: $data.data } } -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $data.template -->
<!-- ko template: { name: template, data: $data.data } -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SurveyModel } from "survey-core";
const template: string = require("./components-container.html");

export class ComponentsContainer {
constructor(public survey: SurveyModel, private container: any) {
constructor(public survey: SurveyModel, private container: any, public needRenderWrapper: boolean = true) {
}
css = "sv-components-column";
get components(): Array<any> {
Expand All @@ -15,7 +15,7 @@ ko.components.register("sv-components-container", {
viewModel: {
createViewModel: (params: any) => {
const survey = params.survey as SurveyModel;
return new ComponentsContainer(survey, params.container);
return new ComponentsContainer(survey, params.container, params.needRenderWrapper);
},
},
template: template
Expand Down
4 changes: 2 additions & 2 deletions src/knockout/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- ko template: { name: koTitleTemplate, afterRender: koAfterRenderHeader } -->
<!-- /ko -->
<!-- ko if: isShowingPage -->
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "header" } } --><!-- /ko -->
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "header", needRenderWrapper: false } } --><!-- /ko -->
<div data-bind="css: $data.bodyContainerCss">
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "left" } } --><!-- /ko -->
<div data-bind="css: bodyCss, style:{maxWidth: renderedWidth}, attr: { id: activePage ? activePage.id : '' }">
Expand All @@ -28,7 +28,7 @@
</div>
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "right" } } --><!-- /ko -->
</div>
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "footer" } } --><!-- /ko -->
<!-- ko component: { name: "sv-components-container", params: { survey: $data, container: "footer", needRenderWrapper: false } } --><!-- /ko -->
<!-- /ko -->
<!-- ko if: state == "completed" && showCompletedPage -->
<div data-bind="html: processedCompletedHtml, css: completedCss"></div>
Expand Down
8 changes: 8 additions & 0 deletions src/react/components/components-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import { ReactElementFactory } from "../element-factory";
export class ComponentsContainer extends React.Component<any, any> {
render(): JSX.Element | null {
const components: Array<ISurveyLayoutElement> = this.props.survey.getContainerContent(this.props.container);
const needRenderWrapper = this.props.needRenderWrapper === false ? false : true;
if(components.length == 0) {
return null;
}
if(!needRenderWrapper) {
return <>
{components.map(component => {
return ReactElementFactory.Instance.createElement(component.component as string, { survey: this.props.survey, model: component.data, key: component.id });
})}
</>;
}
return <div className="sv-components-column">
{components.map(component => {
return ReactElementFactory.Instance.createElement(component.component as string, { survey: this.props.survey, model: component.data, key: component.id });
Expand Down
4 changes: 2 additions & 2 deletions src/react/reactSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class Survey extends SurveyElementBase<any, any>
{customHeader}
<div className={this.css.container}>
{header}
<ComponentsContainer survey={this.survey} container={"header"}></ComponentsContainer>
<ComponentsContainer survey={this.survey} container={"header"} needRenderWrapper={false}></ComponentsContainer>
{renderResult}
<ComponentsContainer survey={this.survey} container={"footer"}></ComponentsContainer>
<ComponentsContainer survey={this.survey} container={"footer"} needRenderWrapper={false}></ComponentsContainer>
</div>
</form>
{ this.survey.showBrandInfo ? <BrandInfo/> : null }
Expand Down

0 comments on commit a3cfa5d

Please sign in to comment.