This commit is contained in:
annampak 2017-11-06 11:57:13 +02:00
parent b49e7e8970
commit 8287f4d43a
6 changed files with 20 additions and 13 deletions

View File

@ -9,4 +9,5 @@ export class Section {
defaultVisibility: boolean; defaultVisibility: boolean;
ordinal: number; ordinal: number;
groupFields: GroupBase<any>[]; groupFields: GroupBase<any>[];
page:number;
} }

View File

@ -4,11 +4,14 @@
<div *ngFor = "let section of dataModel.sections; let i = index;"> <div *ngFor = "let section of dataModel.sections; let i = index;">
<div *ngIf="section.groupFields.length>0 else sectionHeader"> <div *ngIf="section.groupFields.length>0 else sectionHeader">
<h3>{{section.title}}</h3> <div *ngIf="shouldIShow(section);"><h3>{{section.title}}</h3></div>
<div *ngFor="let group of section.groupFields"> <div *ngFor="let group of section.groupFields">
<div *ngIf="shouldIShow(group);" >
<df-group [group]="group" [dataModel]="dataModel" [form]="getSubForm(group.key)"></df-group> <df-group [group]="group" [dataModel]="dataModel" [form]="getSubForm(group.key)"></df-group>
</div> </div>
</div> </div>
</div>
<ng-template #sectionHeader> <ng-template #sectionHeader>
<h2>{{section.title}}</h2> <h2>{{section.title}}</h2>
</ng-template> </ng-template>
@ -45,7 +48,7 @@
</div> </div>
<div class="panel-body" id="collapse-panel" class="panel-collapse"> <div class="panel-body" id="collapse-panel" class="panel-collapse">
<div *ngIf="dataModel.groups.length"> <div *ngIf="dataModel.groups.length">
<toc [dataModel]="dataModel" (setPage)="setPage(2)"></toc> <toc [dataModel]="dataModel" (setPage)="setPage($event)"></toc>
</div> </div>
</div> </div>
</div> </div>

View File

@ -248,11 +248,12 @@ export class DynamicFormComponent implements OnInit {
this.payLoad = JSON.stringify(this.form.value); this.payLoad = JSON.stringify(this.form.value);
} }
shouldIShow(groupFields) { shouldIShow(element) { //pagination , pages are declared in xml for every groupfield
debugger;
if (this.pagination.currentPage == groupFields[0].page){ if (this.pagination.currentPage == element.page){
return true; return true;
} }
else
return false; return false;
@ -277,7 +278,7 @@ export class DynamicFormComponent implements OnInit {
if (page < 1 || page > this.pagination.totalPages) { if (page < 1 || page > this.pagination.totalPages) {
return; return;
} }
var pagesize = 3; var pagesize = 4;
// get pagination object from service // get pagination object from service
this.pagination = this.pagerService.getPagination(this.dataModel.groups, this.dataModel.groups.length, page, pagesize); this.pagination = this.pagerService.getPagination(this.dataModel.groups, this.dataModel.groups.length, page, pagesize);

View File

@ -7,8 +7,8 @@
<li> <li>
<a (click)='scrollToElemID(group.key, group.page)'>{{group.title}}</a> <a (click)='scrollToElemID(group.key, group.page)'>{{group.title}}</a>
<ul *ngFor="let field of group.groupFields"> <ul *ngFor="let field of group.groupFields">
<li *ngIf="field.visible == 'true'"> <li *ngIf="field.visible == 'true' && field.label"> <!-- && field.label for sections without field label as data summery -->
<a (click)='scrollToElemID(field.key)'>{{field.label}}</a> <a (click)='scrollToElemID(field.key, group.page)'>{{field.label}} </a>
</li> </li>
</ul> </ul>
</li> </li>

View File

@ -16,7 +16,7 @@ export class TocComponent implements OnInit{
private headers = new Array(); private headers = new Array();
@Output() @Output()
setPage:EventEmitter<number> = new EventEmitter(); setPage:EventEmitter<number> = new EventEmitter<number>();
ngOnInit(){ ngOnInit(){
var len = this.dataModel.groups.length; // I don't use headers , I use datamodel.groupfields var len = this.dataModel.groups.length; // I don't use headers , I use datamodel.groupfields
@ -26,9 +26,10 @@ export class TocComponent implements OnInit{
} }
scrollToElemID(elemID, page){ scrollToElemID(elemID, _page){
console.log("going to id:"+elemID) console.log("going to id:"+elemID)
// this.setPage.emit(2); var page = parseInt(_page)
this.setPage.emit(page);
scroll("#"+elemID); scroll("#"+elemID);
} }

View File

@ -363,6 +363,7 @@ export class dataModelBuilder {
newSection.id = section._id; newSection.id = section._id;
newSection.title = section.title; newSection.title = section.title;
newSection.ordinal = section._ordinal; newSection.ordinal = section._ordinal;
newSection.page = section._page;
newSection.groupFields = new Array(); newSection.groupFields = new Array();
fieldGroups.forEach(fldgroup => { fieldGroups.forEach(fldgroup => {
if (fldgroup.section == newSection.id) if (fldgroup.section == newSection.id)