links in Toc
This commit is contained in:
parent
7e19087bb6
commit
fdf54f77e8
|
@ -12,6 +12,7 @@ export class GroupBase<T>{
|
||||||
section:string;
|
section:string;
|
||||||
style:string;
|
style:string;
|
||||||
class: string;
|
class: string;
|
||||||
|
page: number;
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
value?: T,
|
value?: T,
|
||||||
|
@ -24,7 +25,8 @@ export class GroupBase<T>{
|
||||||
controlType?: string
|
controlType?: string
|
||||||
section?: string,
|
section?: string,
|
||||||
style?:string
|
style?:string
|
||||||
class?:string
|
class?:string,
|
||||||
|
page?:number
|
||||||
} = {}) {
|
} = {}) {
|
||||||
this.value = options.value;
|
this.value = options.value;
|
||||||
this.key = options.key || '';
|
this.key = options.key || '';
|
||||||
|
@ -37,5 +39,6 @@ export class GroupBase<T>{
|
||||||
this.section = options.section || '';
|
this.section = options.section || '';
|
||||||
this.style = options.style || '';
|
this.style = options.style || '';
|
||||||
this.class = options.class || '';
|
this.class = options.class || '';
|
||||||
|
this.page = options.page || 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,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"></toc>
|
<toc [dataModel]="dataModel" (setPage)="setPage(page)"></toc>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -75,7 +75,6 @@ export class DynamicFormComponent implements OnInit {
|
||||||
this.datasetId = params.datasetId;
|
this.datasetId = params.datasetId;
|
||||||
//this.datasetProperties = params.datasetProperties
|
//this.datasetProperties = params.datasetProperties
|
||||||
});
|
});
|
||||||
|
|
||||||
this.serverService.getDatasetProfileByID(this.id).subscribe(
|
this.serverService.getDatasetProfileByID(this.id).subscribe(
|
||||||
|
|
||||||
response => {
|
response => {
|
||||||
|
@ -100,7 +99,7 @@ export class DynamicFormComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
this.dataModel = new DataModel();
|
this.dataModel = new DataModel();
|
||||||
this.dataModel = this.dataModelService.getDataModel(data);
|
this.dataModel = this.dataModelService.getDataModel(data);debugger;
|
||||||
|
|
||||||
this.form = this.qcs.toFormGroup(this.dataModel.fields, this.dataModel.groups);
|
this.form = this.qcs.toFormGroup(this.dataModel.fields, this.dataModel.groups);
|
||||||
|
|
||||||
|
@ -148,10 +147,9 @@ export class DynamicFormComponent implements OnInit {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
this.serverService.getDatasetByID(this.datasetId).subscribe(
|
this.serverService.getDatasetByID(this.datasetId).subscribe(
|
||||||
(data) => {
|
(data) => {
|
||||||
|
var flatList;
|
||||||
if(data.properties){
|
if(data.properties){
|
||||||
console.log("Found already submitted form, loading that one!");
|
console.log("Found already submitted form, loading that one!");
|
||||||
|
|
||||||
|
@ -160,12 +158,16 @@ export class DynamicFormComponent implements OnInit {
|
||||||
|
|
||||||
let formValues = JSON.parse(data.properties);
|
let formValues = JSON.parse(data.properties);
|
||||||
|
|
||||||
var flatList = flatten(formValues);
|
flatList = flatten(formValues);
|
||||||
|
|
||||||
this.patchForm(flatList);
|
this.patchForm(flatList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//η κληση για το dataset profile pou htan prin pio panw anexarthth
|
||||||
|
|
||||||
|
|
||||||
|
//end- klhsh gia to dataset profiel
|
||||||
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|
||||||
|
@ -244,9 +246,10 @@ export class DynamicFormComponent implements OnInit {
|
||||||
if (page < 1 || page > this.pagination.totalPages) {
|
if (page < 1 || page > this.pagination.totalPages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var pagesize = 3;
|
||||||
// get pagination object from service
|
// get pagination object from service
|
||||||
this.pagination = this.pagerService.getPagination(this.dataModel.groups.length, page);
|
this.pagination = this.pagerService.getPagination(this.dataModel.groups,this.dataModel.groups.length, page, pagesize);
|
||||||
|
|
||||||
|
|
||||||
// get current page of items
|
// get current page of items
|
||||||
this.dataModel.sections.forEach(section => {
|
this.dataModel.sections.forEach(section => {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div *ngFor="let group of dataModel.groups"> <!-- All contents in the first page -->
|
<div *ngFor="let group of dataModel.groups"> <!-- All contents in the first page -->
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a (click)='scrollToElemID(group.key)'>{{group.title}}</a>
|
<a (click)='scrollToElemID(group.key, group.page)'>{{group.title}} {{group.page}}</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'">
|
||||||
<a (click)='scrollToElemID(field.key)'>{{field.label}}</a>
|
<a (click)='scrollToElemID(field.key)'>{{field.label}}</a>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { DataModel } from '../../entities/DataModel';
|
import { DataModel } from '../../entities/DataModel';
|
||||||
|
|
||||||
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
|
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
|
||||||
|
@ -15,6 +15,9 @@ export class TocComponent implements OnInit{
|
||||||
@Input() dataModel: DataModel;
|
@Input() dataModel: DataModel;
|
||||||
private headers = new Array();
|
private headers = new Array();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
setPage:EventEmitter<string> = new EventEmitter();
|
||||||
|
|
||||||
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
|
||||||
for (var i=0; i<len; i++){
|
for (var i=0; i<len; i++){
|
||||||
|
@ -23,8 +26,9 @@ export class TocComponent implements OnInit{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToElemID(elemID){
|
scrollToElemID(elemID, page){
|
||||||
console.log("going to id:"+elemID)
|
console.log("going to id:"+elemID)
|
||||||
|
this.setPage.emit(page);
|
||||||
scroll("#"+elemID);
|
scroll("#"+elemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ export class dataModelBuilder {
|
||||||
|
|
||||||
if (attr.sources) {
|
if (attr.sources) {
|
||||||
newAttribute.sources.push(attr.sources.source);
|
newAttribute.sources.push(attr.sources.source);
|
||||||
|
if (attr.sources.source.length != undefined) {
|
||||||
for (var i = 0; i < attr.sources.source.length; i++) {
|
for (var i = 0; i < attr.sources.source.length; i++) {
|
||||||
if (attr.sources.source[i].url !== undefined) {
|
if (attr.sources.source[i].url !== undefined) {
|
||||||
|
|
||||||
|
@ -259,6 +260,41 @@ export class dataModelBuilder {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attr.sources.source.url !== undefined) {
|
||||||
|
|
||||||
|
|
||||||
|
fields.find(x => x.key == newAttribute.id).url.url = attr.sources.source.url._value;
|
||||||
|
|
||||||
|
this.restBase.proxy_get(attr.sources.source.url._value).subscribe((data) => {
|
||||||
|
console.log(data);
|
||||||
|
newAttribute.sources.forEach(src => {
|
||||||
|
src.params = new Array();
|
||||||
|
data.data.forEach(data => {
|
||||||
|
let prm = new Param();
|
||||||
|
prm.key = data.id;
|
||||||
|
prm.value = data.attributes.name;
|
||||||
|
src.params.push(prm);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
newAttribute.sources.forEach(src => {
|
||||||
|
|
||||||
|
src.params = new Array();
|
||||||
|
for (var i = 0, len = attr.sources.source.value.length; i < len; i++) {
|
||||||
|
let prm = new Param();
|
||||||
|
prm.key = attr.sources.source.value[i]._value;
|
||||||
|
prm.value = attr.sources.source.value[i]._label;
|
||||||
|
src.params.push(prm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
export class PaginationService {
|
export class PaginationService {
|
||||||
getPagination(totalGroups: number, currentPage: number = 1, pageSize: number = 3) {
|
getPagination(groups, totalGroups: number, currentPage: number = 1, pageSize: number = 3) {
|
||||||
// calculate total pages
|
// calculate total pages
|
||||||
let totalPages = Math.ceil(totalGroups / pageSize);
|
let totalPages = Math.ceil(totalGroups / pageSize);
|
||||||
|
|
||||||
|
//each group get the number of its page for toc linking
|
||||||
|
for (var x = 0; x < totalPages ; x++) {debugger;
|
||||||
|
for (var i = 0; i < pageSize; i++) {
|
||||||
|
if (x==0)
|
||||||
|
groups[i].page = x+1;
|
||||||
|
else
|
||||||
|
groups[i+pageSize].page = x+1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let startPage: number, endPage: number;
|
let startPage: number, endPage: number;
|
||||||
if (totalPages <= 10) {
|
if (totalPages <= 10) {
|
||||||
// less than 10 total pages so show all
|
// less than 10 total pages so show all
|
||||||
|
|
Loading…
Reference in New Issue